Hey Aaron, thanks for the followup. I have the content script set to run at document_start.
I'm not sure I follow about the localStorage limitation in content scripts; I wrote a small test which demonstrates that referencing and modifying "localStorage" in a content script modifies the same localStorage that the webpage has access to. This is with Mac Chrome 4.0.249.12. I could use the page's localStorage as a cache but as you mentioned that has the downside of creating localStorage all over the place, which is likely to never go away. A more tidy hack would be to use session storage (which I think is coming soon to Chrome) as a cache, but then I would have access to the data I need only on subsequent loads of the page during that browser session -- not the first load. I guess the ideal solution for my needs would be for content scripts to be able to access the background page's localStorage directly, and barring that, to have a lower-latency connection to the background page. Since the latency was purposefully engineered for performance reasons, the former is probably the more realistic feature request. On Sat, Nov 28, 2009 at 11:51 AM, Aaron Boodman <[email protected]> wrote: > Hmm... interesting problem. > > This is the first example I'm seen that really shows the need to be > able to access extension local storage from content scripts -- that it > goes beyond an issue of convenience. Are you using run_at: > document_start for your content script? That will improve latency to > some extent. > > It is also possible (though not easy) to get access to a web page's > local storage. You're right that this is a bit of a hack, and spreads > your state out over multiple places. I would just treat the page's > local storage as a cache, and name it with some key that is unlikely > to collide (__myextension__...). > > The normal way of just calling window.localStorage will not work, > because we've not implemented the connection from local storage to > content scripts yet. But you can work around that with: > > http://code.google.com/chrome/extensions/content_scripts.html#host-page-communication > > - a > -- You received this message because you are subscribed to the Google Groups "Chromium-extensions" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/chromium-extensions?hl=en.
