Separate StoragePartition for each WebContents

Skip to first unread message

Eryk Rakowski

Sep 10, 2021, 4:38:05 PMSep 10
to Chromium-dev
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?


Charlie Reis

Sep 10, 2021, 5:25:45 PMSep 10
to, Chromium-dev,, 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.  ( 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.


Chromium Developers mailing list:
View archives, change email options, or unsubscribe:
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
To view this discussion on the web visit

Eryk Rakowski

Sep 20, 2021, 1:23:25 AMSep 20
to Chromium-dev, Charles Reis, Chromium-dev,, 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 calls open up new WebContents in the same StoragePartition.
Reply all
Reply to author
0 new messages