Could someone explain how to properly use unlimitedStorage permission for chrome extension with embedded nacl module

2,004 views
Skip to first unread message

mark.br...@gmail.com

unread,
Apr 17, 2015, 10:20:57 AM4/17/15
to native-cli...@googlegroups.com
Hello,
I have written a Chrome extension that uses a NaCl module that needs access to write the HTML5 FS persistent storage. At this moment in time I can't get Chrome to honour the the unlimitedStorage permission in the manifest.json file to avoid a JS quota request.

From the pp::FileSystem documation it says:
The expected size of the file system. Note that this does not request quota; to do that, you must either invoke requestQuota from JavaScript:http://www.html5rocks.com/en/tutorials/file/filesystem/#toc-requesting-quota or set the unlimitedStorage permission for Chrome Web Store apps:http://code.google.com/chrome/extensions/manifest.html#permissions

However if I just add the unlimitedStorage permission like:

"permissions": ["unlimitedStorage", "tabs", "power"]

I cannot write to the persistent FS from the NaCl code when using a mount such as:

mount_status = mount("", "/persistent", "html5fs", 0, "type=PERSISTENT,expected_size=67108864");

If however I request and accept a quota from JS (which results in a UI popup in Chrome) I can access the FS no problem at all.

I wish to avoid the popup and get the user to accept the quota at install time not runtime, and as suggested by pp::FileSystem documation this should be possible.

Please could someone confirm if I am adding the permission incorrectly..or whether I have mis-understood something.?


Many thanks
Mark. 


Bradley Nelson

unread,
Apr 17, 2015, 7:10:33 PM4/17/15
to Native Client Discuss
Hi Mark,

I think you also need to have the "storage" permission in the list.
Let me know if that corrects the issue.

-BradN

--
You received this message because you are subscribed to the Google Groups "Native-Client-Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to native-client-di...@googlegroups.com.
To post to this group, send email to native-cli...@googlegroups.com.
Visit this group at http://groups.google.com/group/native-client-discuss.
For more options, visit https://groups.google.com/d/optout.

mark.br...@gmail.com

unread,
Apr 20, 2015, 4:57:53 AM4/20/15
to native-cli...@googlegroups.com
Hi Brad,
Thanks for the response, I've tried with "storage" permission and still see the same problem. When running up my page with the plugin loaded I can see that FileSystem is listed in chrome://settings/content 
"content and site data" buy my available quota is still 0 bytes when I check size available. I don't think "unlimitedStorage" permission works it certainly doesn't appear to offer the same functionality as running Chrome with --unlimited-storage flag.

thanks
Mark,.

Bradley Nelson

unread,
Apr 20, 2015, 2:55:20 PM4/20/15
to Native Client Discuss
Hi Mark,

I'm confused about the context in which you're trying to access storage.
Apps and extensions don't appear in chrome://settings/content, only pages.

"unlimitedStorage" will only apply to things run from the origin of the app / extension.
So for example a background page (or window for an app).

This is obviously more narrow than --unlimited-storage, which turns off the quota restriction for all pages / origins.

-BradN

mark.br...@gmail.com

unread,
Apr 20, 2015, 4:23:32 PM4/20/15
to native-cli...@googlegroups.com
Sorry perhaps i confused matters slightly. I'm trying to request and access storage in the context of a nacl module that is wrapped in a chrome extension and embedded in a web page using an embed tag. In particular the nacl module stores a sqlite db in persistent html5 fs.

Without the quota being set writing to the filesystem fails. I'm particularly looking to be able to have the user accept the quota at install time. At present requesting the quota in the context of the webpage is the only way i can get this to work but its not a great user experience for our product because of the associated runtime popup.
Message has been deleted
Message has been deleted

Bradley Nelson

unread,
Apr 21, 2015, 11:19:27 PM4/21/15
to Native Client Discuss
Hi Mark,

When you say wrapped in a chrome extension, what origin is the page with the embed running in?
(i.e. is the page with the embed viewed as something like chrome-extension://xxxxxx/foo.html or some other url?)
If you're injecting the embed in a page outside the extension via a content script, that won't even directly grant permissions to run non-pnacl nacl (are you doing pnacl or nacl?).
I believe if you add the pages from the extension to the web_accessible_resources section in manifest.json and reference them in an embed inside an iframe, the permission to use nacl in the context of the extension will carry over.
The other option is to run the nacl module in the background page of the extension (which will only work if the extension is compute only).

Are you putting this in a site referenced in the  "permissions", with wildcards?
I believe that also doesn't carryover the storage setting (see this note in the manifest.json doc):

Note: This permission applies only to Web SQL Database and application cache (see issue 58985). Also, it doesn't currently work with wildcard subdomains such as http://*.example.com.

Sorry, still grasping to understand the way your extension is structured.

-BradN


On Mon, Apr 20, 2015 at 1:23 PM, <mark.br...@gmail.com> wrote:
Sorry perhaps i confused matters slightly. I'm trying to request and access storage in the context of a nacl module that is wrapped in a chrome extension and embedded in a web page using an embed tag.  In particular the nacl module stores a sqlite db in persistent html5 fs.

Without the quota being set writing to the filesystem fails. I'm particularly looking to be able to have the user accept the quota at install time. At present requesting the quota in the context of the webpage is the only way i can get this to work but its not a great user experience for our product because of the associated runtime popup.

mark.br...@gmail.com

unread,
Apr 22, 2015, 3:01:43 PM4/22/15
to native-cli...@googlegroups.com
Hi Brad,
Thanks for taking to time to explain, i think i now understand how FS quota works. My nacl module is running in the context of an open webpage, loaded in through a custom mime type. Think flash player plugin. So if i understand what you say then my nacl module
shares the filesystem with the webpage and not the extensions background page. Therefore I can only request the quota at runtime since unlimitedStorage permission only applies to the extension context.
Thanks again
Mark.
Message has been deleted

Bradley Nelson

unread,
Apr 22, 2015, 10:16:24 PM4/22/15
to Native Client Discuss
Ah yes forgot about the nacl_modules case.
You should be able to store unlimited data in the background page, but you would have to use postmessage to marshall the data across from you mime type handling nacl module and either some js or another nacl module in the background page (probably js would be simpler if it's just for dumb storage).

-BradN

Reply all
Reply to author
Forward
0 new messages