Thank you for your help. I am trying to use the WebRequest API to get
the cookie data in the onHeadersReceived event and store it in
LocalStorage. Storing the data works, but somehow I can't remove the
cookie data from the request to prevent Chrome from saving the actual
cookie. When I add "blocking" to the extraInfoSpec parameter, the
event doesn't fire anymore for XmlHttpRequests made from the
extension.
Here is the code for the event handler:
chrome.webRequest.onHeadersReceived.addListener(
function(details) {
console.log(details.url);
// Save the cookie, remove it from the headers etc..
return { responseHeaders: details.responseHeaders };
},
{ urls: ["<all_urls>"] },
["blocking", "responseHeaders"]
);
I have added the following values to the permissions-field in my
manifest:
"<all_urls>", "http://*/", "https://*/", "webRequest",
"webRequestBlocking"
Do you know what I'm doing wrong? The event fires for all requests,
except the XmlHttpRequests from my extension. Without "blocking" the
event does fire for these requests.
I have the same issue with the onBeforeSendHeaders event (I need to
add the cookie data to the headers in that event).
- Luuk
On 1 mrt, 13:16, Mike West <
mk...@chromium.org> wrote:
> As you've noted, extensions' requests share the same profile as the
> user's normal requests. This, generally, is desirable, as extensions
> often make requests on a user's behalf
>
> At the moment, there's no mechanism to create a separate cookie jar
> for extensions. You can fake something similar, however, by using the
> WebRequest API to strip cookies from outgoing requests, or replace
> them with new cookies. One suggestion would be to educate your users
> about Chrome's built-in multi-profile support. That seems like a
> better long-term solution to the problem you're encountering, as it
> would allow users to log in with multiple accounts at the same time.
> That's not something that your extension can control on it's own,
> however.
>
> Relatedly, I think it might be worthwhile to propose an extension to
> the XMLHttpRequest spec that would allow developers to make cookieless
> requests.
>
> -Mike
>