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

Side by Side Diff: chrome/browser/chrome_content_browser_client.cc

Issue 86973002: Clean up ChromeContentBrowserClient::ShouldSwapProcessesForNavigation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years 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_process_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 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 extensions::ExtensionSystem::Get(profile)->info_map(), 1319 extensions::ExtensionSystem::Get(profile)->info_map(),
1320 extension->id(), 1320 extension->id(),
1321 site_instance->GetProcess()->GetID(), 1321 site_instance->GetProcess()->GetID(),
1322 site_instance->GetId())); 1322 site_instance->GetId()));
1323 } 1323 }
1324 1324
1325 bool ChromeContentBrowserClient::ShouldSwapBrowsingInstancesForNavigation( 1325 bool ChromeContentBrowserClient::ShouldSwapBrowsingInstancesForNavigation(
1326 SiteInstance* site_instance, 1326 SiteInstance* site_instance,
1327 const GURL& current_url, 1327 const GURL& current_url,
1328 const GURL& new_url) { 1328 const GURL& new_url) {
1329 if (current_url.is_empty()) { 1329 // If we don't have an ExtensionService, then rely on the SiteInstance logic
1330 // Always choose a new process when navigating to extension URLs. The 1330 // in RenderViewHostManager to decide when to swap.
nasko 2013/12/03 18:06:59 drive-by nit: There is no RenderViewHostManager an
Charlie Reis 2013/12/03 19:22:55 Oops! I'll fix those comments in another CL. Tha
1331 // process grouping logic will combine all of a given extension's pages
1332 // into the same process.
1333 if (new_url.SchemeIs(extensions::kExtensionScheme))
1334 return true;
1335
1336 return false;
1337 }
1338
1339 // Also, we must switch if one is an extension and the other is not the exact
1340 // same extension.
1341 if (current_url.SchemeIs(extensions::kExtensionScheme) ||
1342 new_url.SchemeIs(extensions::kExtensionScheme)) {
1343 if (current_url.GetOrigin() != new_url.GetOrigin())
1344 return true;
1345 }
1346
1347 // The checks below only matter if we can retrieve which extensions are
1348 // installed.
1349 Profile* profile = 1331 Profile* profile =
1350 Profile::FromBrowserContext(site_instance->GetBrowserContext()); 1332 Profile::FromBrowserContext(site_instance->GetBrowserContext());
1351 ExtensionService* service = 1333 ExtensionService* service =
1352 extensions::ExtensionSystem::Get(profile)->extension_service(); 1334 extensions::ExtensionSystem::Get(profile)->extension_service();
1353 if (!service) 1335 if (!service)
1354 return false; 1336 return false;
1355 1337
1356 // We must swap if the URL is for an extension and we are not using an 1338 // We must use a new BrowsingInstance (forcing a process swap and disabling
1357 // extension process. 1339 // scripting by existing tabs) if one of the URLs is an extension and the
1340 // other is not the exact same extension.
1341 //
1342 // We ignore hosted apps here so that other tabs in their BrowsingInstance can
1343 // use postMessage with them. (The exception is the Chrome Web Store, which
1344 // is a hosted app that requires its own BrowsingInstance.) Navigations
1345 // to/from a hosted app will still trigger a SiteInstance swap in
1346 // RenderViewHostManager.
1347 const Extension* current_extension =
1348 service->extensions()->GetExtensionOrAppByURL(current_url);
1349 if (current_extension &&
1350 current_extension->is_hosted_app() &&
1351 current_extension->id() != extension_misc::kWebStoreAppId)
1352 current_extension = NULL;
1353
1358 const Extension* new_extension = 1354 const Extension* new_extension =
1359 service->extensions()->GetExtensionOrAppByURL(new_url); 1355 service->extensions()->GetExtensionOrAppByURL(new_url);
1360 // Ignore all hosted apps except the Chrome Web Store, since they do not
1361 // require their own BrowsingInstance (e.g., postMessage is ok).
1362 if (new_extension && 1356 if (new_extension &&
1363 new_extension->is_hosted_app() && 1357 new_extension->is_hosted_app() &&
1364 new_extension->id() != extension_misc::kWebStoreAppId) 1358 new_extension->id() != extension_misc::kWebStoreAppId)
1365 new_extension = NULL; 1359 new_extension = NULL;
1360
1361 // First do a process check. We should force a BrowsingInstance swap if the
1362 // current process doesn't know about new_extension, even if current_extension
1363 // is somehow the same as new_extension.
1366 if (new_extension && 1364 if (new_extension &&
1367 site_instance->HasProcess() && 1365 site_instance->HasProcess() &&
1368 !service->process_map()->Contains(new_extension->id(), 1366 !service->process_map()->Contains(new_extension->id(),
1369 site_instance->GetProcess()->GetID())) 1367 site_instance->GetProcess()->GetID()))
1370 return true; 1368 return true;
1371 1369
1372 return false; 1370 // Otherwise, swap BrowsingInstances if current_extension and new_extension
1371 // differ.
1372 return current_extension != new_extension;
1373 } 1373 }
1374 1374
1375 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect( 1375 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect(
1376 content::ResourceContext* resource_context, const GURL& current_url, 1376 content::ResourceContext* resource_context, const GURL& current_url,
1377 const GURL& new_url) { 1377 const GURL& new_url) {
1378 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); 1378 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
1379 return extensions::CrossesExtensionProcessBoundary( 1379 return extensions::CrossesExtensionProcessBoundary(
1380 io_data->GetExtensionInfoMap()->extensions(), 1380 io_data->GetExtensionInfoMap()->extensions(),
1381 current_url, new_url, false); 1381 current_url, new_url, false);
1382 } 1382 }
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after
2639 return IsExtensionOrSharedModuleWhitelisted(url, extension_set, 2639 return IsExtensionOrSharedModuleWhitelisted(url, extension_set,
2640 allowed_file_handle_origins_) || 2640 allowed_file_handle_origins_) ||
2641 IsHostAllowedByCommandLine(url, extension_set, 2641 IsHostAllowedByCommandLine(url, extension_set,
2642 switches::kAllowNaClFileHandleAPI); 2642 switches::kAllowNaClFileHandleAPI);
2643 #else 2643 #else
2644 return false; 2644 return false;
2645 #endif 2645 #endif
2646 } 2646 }
2647 2647
2648 } // namespace chrome 2648 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/app_process_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698