var storage = {
    // `sync` if you want.
    // remember about QUOTAS https://developer.chrome.com/extensions/storage.html#sync-properties
    area: chrome.storage.local,
    default_options: {
        // one key for every option
        o_search_urls: 1,
        o_history_enabled: 0,
        o_history_result_count: '100',
        o_history_query_length: '3',
        o_fontsize: '12',
        o_show_other_devices: 1
    }
};

// function initStorageArea() {    
//     chrome.storage.local.get("o_storage_area").then((result) => {
//         console.log("Storage init: " + result.o_storage_area);
//         setStorageArea(result.o_storage_area || "local");
//     });
// }
// function saveStorageArea(storageArea) {    
//     chrome.storage.local.set({ "o_storage_area": storageArea }).then(() => {
//         console.log("Storage save: " + storageArea);
//         setStorageArea(storageArea);
//     });
// }

function setStorageArea(storageArea) {
    console.log("Storage set: " + storageArea);
    storage.area
        = storageArea == "local"
        ? chrome.storage.local
        : chrome.storage.sync;
}

// initStorageArea();
setStorageArea("local");
