[Qtwebengine] Sharing data between QWebEngineProfiles

Allan Sandfeld Jensen kde at carewolf.com
Thu Aug 20 15:12:14 CEST 2015


On Thursday 20 August 2015, Florian Bruhin wrote:
> * Allan Sandfeld Jensen <kde at carewolf.com> [2015-08-20 13:37:37 +0200]:
> > On Thursday 20 August 2015, Florian Bruhin wrote:
> > > Hi,
> > > 
> > > I (from qutebrowser[1]) and Emdek (from Otter Browser[2]) discussed
> > > what's still missing for us from QtWebEngine, and one point which came
> > > up and wasn't discussed already is sharing data between multiple
> > > QWebEngineProfiles.
> > > 
> > > Our use-case is to have per-domain and possibly per-tab settings, e.g.
> > > the user want to configure the user-agent differently based on the
> > > page they're visiting.
> > > 
> > > This means you'll end up with having a new QWebEngineProfile for every
> > > tab - however, that also means every tab will have its own persistent
> > > storage, cookie store, and cache - right?
> > > 
> > > Is it possible/planned to share data between QWebEngineProfiles so one
> > > can implement this kind of thing?
> > > 
> > > I guess one possibility is to use the same storageName for all of them
> > > - but will that work?
> > 
> > No, that would not be how profiles are supposed to be used. If you need
> > different user-agent string per page, we should probably make a separate
> > API for that (in fact the Chromium API we use already have separate
> > mechanisms for overriding user-agent on a per page basis.
> 
> But I wonder - what's the reason things like httpUserAgent or
> persistentCookiesPolicy (i.e. things you might want to set
> per-tab/domain/...) are in QWebEngineProfile rather than
> QWebEngineSettings?
> 
> I guess it would be possible to control those per page using the new
> QWebEngineCookieStoreClient and QWebEngineUrlRequestInterceptor APIs,
> right? But I still feel like this kind of thing should be simpler and
> probably be in QWebEngineSettings which can be set per-page.
> 
The profile exists because it matches a Chromium API called BrowserContext. We 
simply can not control many of these settings per page, but only per 
BrowserContext. This is supposed to replace global and static settings that 
used to be in QWebSettings, and you are not really expected to have more than 
one profile, with the except of possibly on of incognito and one normal.

`Allan





More information about the QtWebEngine mailing list