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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/app_background_page_apitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chrome_content_browser_client.h" 5 #include "chrome/browser/chrome_content_browser_client.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 Profile* profile = Profile::FromBrowserContext(browser_context); 443 Profile* profile = Profile::FromBrowserContext(browser_context);
444 if (!profile || !profile->GetExtensionService()) 444 if (!profile || !profile->GetExtensionService())
445 return false; 445 return false;
446 446
447 const Extension* extension = profile->GetExtensionService()->extensions()-> 447 const Extension* extension = profile->GetExtensionService()->extensions()->
448 GetExtensionOrAppByURL(ExtensionURLInfo(effective_url)); 448 GetExtensionOrAppByURL(ExtensionURLInfo(effective_url));
449 if (!extension) 449 if (!extension)
450 return false; 450 return false;
451 451
452 // If the URL is part of a hosted app that does not have the background 452 // If the URL is part of a hosted app that does not have the background
453 // permission, we want to give each instance its own process to improve 453 // permission, or that does not allow JavaScript access to the background
454 // page, we want to give each instance its own process to improve
454 // responsiveness. 455 // responsiveness.
455 if (extension->GetType() == Extension::TYPE_HOSTED_APP && 456 if (extension->GetType() == Extension::TYPE_HOSTED_APP) {
456 !extension->HasAPIPermission(ExtensionAPIPermission::kBackground)) 457 if (!extension->HasAPIPermission(ExtensionAPIPermission::kBackground) ||
457 return false; 458 !extension->allow_background_js_access()) {
459 return false;
460 }
461 }
458 462
459 // Hosted apps that have the background permission must use process per site, 463 // Hosted apps that have script access to their background page must use
460 // since all instances can make synchronous calls to the background window. 464 // process per site, since all instances can make synchronous calls to the
461 // Other extensions should use process per site as well. 465 // background window. Other extensions should use process per site as well.
462 return true; 466 return true;
463 } 467 }
464 468
465 bool ChromeContentBrowserClient::IsHandledURL(const GURL& url) { 469 bool ChromeContentBrowserClient::IsHandledURL(const GURL& url) {
466 return ProfileIOData::IsHandledURL(url); 470 return ProfileIOData::IsHandledURL(url);
467 } 471 }
468 472
469 bool ChromeContentBrowserClient::IsSuitableHost( 473 bool ChromeContentBrowserClient::IsSuitableHost(
470 content::RenderProcessHost* process_host, 474 content::RenderProcessHost* process_host,
471 const GURL& site_url) { 475 const GURL& site_url) {
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 bool ChromeContentBrowserClient::CanCreateWindow( 1164 bool ChromeContentBrowserClient::CanCreateWindow(
1161 const GURL& source_origin, 1165 const GURL& source_origin,
1162 WindowContainerType container_type, 1166 WindowContainerType container_type,
1163 content::ResourceContext* context, 1167 content::ResourceContext* context,
1164 int render_process_id) { 1168 int render_process_id) {
1165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1169 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1166 // If the opener is trying to create a background window but doesn't have 1170 // If the opener is trying to create a background window but doesn't have
1167 // the appropriate permission, fail the attempt. 1171 // the appropriate permission, fail the attempt.
1168 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { 1172 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) {
1169 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); 1173 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
1170 return io_data->GetExtensionInfoMap()->SecurityOriginHasAPIPermission( 1174 ExtensionInfoMap* map = io_data->GetExtensionInfoMap();
1175
1176 // If the opener is not allowed to script its background window, then return
1177 // false so that the window.open call returns null. In this case, only
1178 // the manifest is permitted to create a background window.
1179 // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may
1180 // return a recently installed Extension even if this CanCreateWindow call
1181 // was made by an old copy of the page in a normal web process. That's ok,
1182 // because the permission check below will still fail.
1183 const Extension* extension = map->extensions().GetExtensionOrAppByURL(
1184 ExtensionURLInfo(source_origin));
1185 if (extension && !extension->allow_background_js_access())
1186 return false;
1187
1188 return map->SecurityOriginHasAPIPermission(
1171 source_origin, render_process_id, ExtensionAPIPermission::kBackground); 1189 source_origin, render_process_id, ExtensionAPIPermission::kBackground);
1172 } 1190 }
1173 return true; 1191 return true;
1174 } 1192 }
1175 1193
1176 std::string ChromeContentBrowserClient::GetWorkerProcessTitle( 1194 std::string ChromeContentBrowserClient::GetWorkerProcessTitle(
1177 const GURL& url, content::ResourceContext* context) { 1195 const GURL& url, content::ResourceContext* context) {
1178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1196 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1179 // Check if it's an extension-created worker, in which case we want to use 1197 // Check if it's an extension-created worker, in which case we want to use
1180 // the name of the extension. 1198 // the name of the extension.
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 #if defined(USE_NSS) 1490 #if defined(USE_NSS)
1473 crypto::CryptoModuleBlockingPasswordDelegate* 1491 crypto::CryptoModuleBlockingPasswordDelegate*
1474 ChromeContentBrowserClient::GetCryptoPasswordDelegate( 1492 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
1475 const GURL& url) { 1493 const GURL& url) {
1476 return browser::NewCryptoModuleBlockingDialogDelegate( 1494 return browser::NewCryptoModuleBlockingDialogDelegate(
1477 browser::kCryptoModulePasswordKeygen, url.host()); 1495 browser::kCryptoModulePasswordKeygen, url.host());
1478 } 1496 }
1479 #endif 1497 #endif
1480 1498
1481 } // namespace chrome 1499 } // namespace chrome
OLDNEW
« 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