OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 page, then return | |
1177 // false so that the window.open call returns null. The browser will still | |
1178 // 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
| |
1179 // succeeds. | |
1180 // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may | |
1181 // return a recently installed Extension even this CanCreateWindow call was | |
1182 // made by an old copy of the page in a normal web process. That's ok, | |
1183 // because the permission check below will still fail. | |
1184 const Extension* extension = map->extensions().GetExtensionOrAppByURL( | |
1185 ExtensionURLInfo(source_origin)); | |
1186 if (extension && !extension->allow_background_js_access()) | |
1187 return false; | |
1188 | |
1189 return map->SecurityOriginHasAPIPermission( | |
1171 source_origin, render_process_id, ExtensionAPIPermission::kBackground); | 1190 source_origin, render_process_id, ExtensionAPIPermission::kBackground); |
1172 } | 1191 } |
1173 return true; | 1192 return true; |
1174 } | 1193 } |
1175 | 1194 |
1176 std::string ChromeContentBrowserClient::GetWorkerProcessTitle( | 1195 std::string ChromeContentBrowserClient::GetWorkerProcessTitle( |
1177 const GURL& url, content::ResourceContext* context) { | 1196 const GURL& url, content::ResourceContext* context) { |
1178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1197 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
1179 // Check if it's an extension-created worker, in which case we want to use | 1198 // Check if it's an extension-created worker, in which case we want to use |
1180 // the name of the extension. | 1199 // the name of the extension. |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1472 #if defined(USE_NSS) | 1491 #if defined(USE_NSS) |
1473 crypto::CryptoModuleBlockingPasswordDelegate* | 1492 crypto::CryptoModuleBlockingPasswordDelegate* |
1474 ChromeContentBrowserClient::GetCryptoPasswordDelegate( | 1493 ChromeContentBrowserClient::GetCryptoPasswordDelegate( |
1475 const GURL& url) { | 1494 const GURL& url) { |
1476 return browser::NewCryptoModuleBlockingDialogDelegate( | 1495 return browser::NewCryptoModuleBlockingDialogDelegate( |
1477 browser::kCryptoModulePasswordKeygen, url.host()); | 1496 browser::kCryptoModulePasswordKeygen, url.host()); |
1478 } | 1497 } |
1479 #endif | 1498 #endif |
1480 | 1499 |
1481 } // namespace chrome | 1500 } // namespace chrome |
OLD | NEW |