Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2914)

Unified Diff: chrome/browser/chrome_content_browser_client.cc

Issue 9508008: Allow apps with background pages to request process-per-app-instance. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clean up tests. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/app_background_page_apitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_content_browser_client.cc
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 5a898a9a27de3fdaa886864d8837ee019cecb781..24965e40638aff37449227eb904ea67ee6f4de61 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -450,15 +450,19 @@ bool ChromeContentBrowserClient::ShouldUseProcessPerSite(
return false;
// If the URL is part of a hosted app that does not have the background
- // permission, we want to give each instance its own process to improve
+ // permission, or that does not allow JavaScript access to the background
+ // page, we want to give each instance its own process to improve
// responsiveness.
- if (extension->GetType() == Extension::TYPE_HOSTED_APP &&
- !extension->HasAPIPermission(ExtensionAPIPermission::kBackground))
- return false;
+ if (extension->GetType() == Extension::TYPE_HOSTED_APP) {
+ if (!extension->HasAPIPermission(ExtensionAPIPermission::kBackground) ||
+ !extension->allow_background_js_access()) {
+ return false;
+ }
+ }
- // Hosted apps that have the background permission must use process per site,
- // since all instances can make synchronous calls to the background window.
- // Other extensions should use process per site as well.
+ // Hosted apps that have script access to their background page must use
+ // process per site, since all instances can make synchronous calls to the
+ // background window. Other extensions should use process per site as well.
return true;
}
@@ -1167,7 +1171,21 @@ bool ChromeContentBrowserClient::CanCreateWindow(
// the appropriate permission, fail the attempt.
if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) {
ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
- return io_data->GetExtensionInfoMap()->SecurityOriginHasAPIPermission(
+ ExtensionInfoMap* map = io_data->GetExtensionInfoMap();
+
+ // If the opener is not allowed to script its background window, then return
+ // false so that the window.open call returns null. In this case, only
+ // the manifest is permitted to create a background window.
+ // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may
+ // return a recently installed Extension even if this CanCreateWindow call
+ // was made by an old copy of the page in a normal web process. That's ok,
+ // because the permission check below will still fail.
+ const Extension* extension = map->extensions().GetExtensionOrAppByURL(
+ ExtensionURLInfo(source_origin));
+ if (extension && !extension->allow_background_js_access())
+ return false;
+
+ return map->SecurityOriginHasAPIPermission(
source_origin, render_process_id, ExtensionAPIPermission::kBackground);
}
return true;
« no previous file with comments | « no previous file | chrome/browser/extensions/app_background_page_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698