Separate StoragePartition for each WebContents

72 views
Skip to first unread message

Eryk Rakowski

unread,
Sep 10, 2021, 4:38:05 PM9/10/21
to Chromium-dev
Hello,
I'm trying to use different cookie jars for different WebContents, more specifically StoragePartitions. This is currently working with SiteInstance::CreateForGuest, but it's not a viable solution for me as WebUI pages and content scripts injection do not work in SiteInstances marked as guest. I'm trying to use SiteInstance::CreateForUrlInfo with passing StoragePartitionConfig to UrlInfo, but it doesn't seem to work for me. Seems like the SiteInstance gets swapped with incorrect StoragePartition later on. Does anyone have some clue on what's happening?

-Eryk

Charlie Reis

unread,
Sep 10, 2021, 5:25:45 PM9/10/21
to sent...@gmail.com, Chromium-dev, rmce...@chromium.org, Alex Moshchuk
Note that you'll only be able to use a separate StoragePartition for WebContents objects that are in different browsing context groups (i.e., BrowsingInstances), since same-origin documents in two tabs that can script each other must stay in the same process and thus StoragePartition.  (window.open() is one example of creating a second WebContents in the same browsing context group.)

Still, it should be possible to modify things to use a different StoragePartition for most independently created tabs.  rmcelrath@ and alexmos@ were just working on a refactor that might make that easier, and could probably share context.

Charlie


--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/5cdb99ed-0256-4b14-8119-e78fddfeda9en%40chromium.org.

Eryk Rakowski

unread,
Sep 20, 2021, 1:23:25 AM9/20/21
to Chromium-dev, Charles Reis, Chromium-dev, rmce...@chromium.org, Alex Moshchuk, Eryk Rakowski
From what I can tell, CreateForUrlInfo and CreateForURL create a separate BrowsingInstance and I think it's perfectly fine for my use-case if subsequent window.open calls open up new WebContents in the same StoragePartition.
Reply all
Reply to author
Forward
0 new messages