Using the Cookies API, how can I determine which tab a cookie was changed on?

17 views
Skip to first unread message

Chris Casale

unread,
Aug 28, 2015, 10:34:24 PM8/28/15
to Chromium-extensions
I'm currently using chrome.cookies.onChanged in a background script to detect cookie changes, but there's no method to determine where the cookie was added or removed if I have multiple tabs open.  How can I determine when cookie changes are made, where they're being made?

Ideally I'd use a content script for this, but content scripts don't have access to the cookies API, so without doing it in a background script, I can't see any way around this.  It was recommended I try using Object.observe() instead of the cookies API in a content script, but that doesn't work on global methods, so I can't see any way to observe all cookies.

Any help is greatly appreciated!

Antony Sargent

unread,
Aug 31, 2015, 1:05:24 PM8/31/15
to Chris Casale, Chromium-extensions
Unfortunately the way the cookies API is designed, I don't think there is any easy and reliable way to determine this. The cookies changes could be due to network requests from any open tab (either top-level frame or iframes, and either from regular DOM elements or XHR's within the frame) or possibly even from service workers. 

You might be able to correlate cookies events to tabs by listening to other events in either the webNavigation or webRequest APIs.




--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/97d981cf-88a1-4d77-a989-bbfb303c905f%40chromium.org.
For more options, visit https://groups.google.com/a/chromium.org/d/optout.

Reply all
Reply to author
Forward
0 new messages