Custom process model based on URL

Made a cool mod to CEF that you'd like to share with others? Discuss CEF modifications here, and view modifications that others have made.

Custom process model based on URL

Postby Kintoun » Fri Feb 19, 2016 8:20 pm

Seen this request posted before, so sharing the solution I created. We only have the process models as defined here - ... ess-models

I needed a way however to have local pages all loaded in the same process (web based UI) but still have external pages loaded in the default process-per-site-instance. I did this by implementing content::ContentBrowserClient::ShouldUseProcessPerSite in CefContentBrowserClient. It forwards the request to the application BrowserProcessHandler which my client code implements. It then returns either true or false depending on the site/host/etc of the URL.

Code: Select all
bool CefContentBrowserClient::ShouldUseProcessPerSite(
  content::BrowserContext* browser_context, const GURL& effective_url) {
  if (effective_url.is_valid())
    CefRefPtr<CefApp> app = CefContentClient::Get()->application();
    if (app.get()) {
      CefRefPtr<CefBrowserProcessHandler> handler =
      if (handler.get()) {
        return handler->ShouldUseProcessPerSite(effective_url.spec());

  return false;

You can see another example of this in how Chrome implements ShouldUseProcessPerSite in ChromeContentBrowserClient for its WebUI schemes.

On a side note I believe there is a bug with Chromium process-per-site (2171 branch). During site instance creation when it makes it to navigation it relies on a previous same site being registered in the site process map to use the same process. If you create two site instances with the same site quickly enough they will end up not sharing the same process (of course with process-per-site on). Neither has been registered with the site process map yet. Is this intended? Seems non-trivial to address. Where can I report this?
Posts: 1
Joined: Fri Feb 19, 2016 7:04 pm

Return to Modifications Forum

Who is online

Users browsing this forum: No registered users and 1 guest