Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

chrome.storage is undefined in chrome extension

I'm developing a Google Chrome extension, and have been working on one for a while. So it's been installed for a while, and I updated the manifest file to include the "storage" permission and reloaded the extension. However, when I try it in the console, chrome.storage is undefined. I restarted Chrome and still nothing.

My manifest file looks like this:

{
    ... snip ...
    "permissions": [
        "tabs",
        "http://*/*",
        "https://*/*",
        "chrome://favicon/",
        "storage"
    ]
}

I could reinstall the application, but I'm hesitant, since: Will it be the same for the existing users of the extension? It says in the documentation that the permission won't show any warnings or temporarily block the extension for adding more permissions.

My question is mainly, how will the existing users of my extension be affected? Will they get a warning and have the extension disabled until they actively enable it? Or is it just a local develpment issue?

like image 417
Erik Rothoff Avatar asked Sep 10 '12 16:09

Erik Rothoff


People also ask

How to get undefined key in chrome storage?

chrome.storage.local.get('myKey', function(data) {console.log(JSON.stringify(data))}) and in that case ‘undefined’ is returned too. slosd

What is the chrome storage API?

Use the chrome.storage API to store, retrieve, and track changes to user data. This API has been optimized to meet the specific storage needs of extensions. It provides the same storage capabilities as the localStorage API with the following key differences:

How do I store user data in Chrome extensions?

Use the chrome.storage API to store, retrieve, and track changes to user data. This API has been optimized to meet the specific storage needs of extensions. It provides the same storage capabilities as the localStorage API with the following key differences: User data can be automatically synced with Chrome sync (using storage.sync ).

Is the storage area of Chrome OS encrypted?

The storage area isn't encrypted. The storage.managed storage is read-only. chrome.storage is not a big truck. It's a series of tubes.


1 Answers

Your manifest looks fine. Did you reload your extension after making the change?

I pasted your manifest permissions into a new extension and called:

console.log(chrome.storage);

And recieved the following:

chrome.storage output

Note "local" and "sync", the two types of storage available to the extension.

like image 112
marky-b Avatar answered Oct 18 '22 00:10

marky-b