You can give default values to get()
function. At extension initialization, you can do:
chrome.storage.local.get({option: "default"}, function(data){
chrome.storage.local.set(data, /*...*/);
});
This will set the value to "default" if absent and conserve current value if present.
Aha, I see the deleted key dilemma.
There are two options:
Avoid deleting keys. Set a key to undefined, or empty string, but keep the key.
Initialize with defaults and then set
{settings_schema: 1}
. This way you can check for options schema version on initialization, and perform upgrade as needed (i.e. add defaults for a new option).