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..b4b7c3e2d51568d0dea7886408921927f858d897 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,22 @@ 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 page, then return |
+ // false so that the window.open call returns null. The browser will still |
+ // create the background page as long as the permission check below |
Mihai Parparita -not on Chrome
2012/03/01 02:48:11
Where does the creation happen?
Charlie Reis
2012/03/01 20:12:12
Right, as you noted, this comment was wrong and ha
|
+ // succeeds. |
+ // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may |
+ // return a recently installed Extension even 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; |