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

Unified Diff: chrome/browser/chrome_content_browser_client.cc

Issue 9965091: Clean up RenderViewHostManager swapping logic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix review comments. Created 8 years, 7 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
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 3552195c8aac15a3d0601de99ea8149239da6f50..f356c05deb15d71fd00dc1fd9ce16b3a13500971 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -267,6 +267,21 @@ bool IsIsolatedAppInProcess(const GURL& site_url,
return false;
}
+// If |url| has an extension or isolated app (not a hosted app) associated with
+// it, return it. Otherwise return null.
+const Extension* GetExtensionOrIsolatedApp(const GURL& url,
+ ExtensionService* service) {
+ const Extension* extension =
+ service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(url));
+ // Ignore hosted apps that aren't isolated apps.
+ if (extension &&
+ extension->is_hosted_app() &&
+ !extension->is_storage_isolated())
+ extension = NULL;
+ return extension;
+}
+
+
bool CertMatchesFilter(const net::X509Certificate& cert,
const base::DictionaryValue& filter) {
// TODO(markusheintz): This is the minimal required filter implementation.
@@ -647,28 +662,29 @@ void ChromeContentBrowserClient::SiteInstanceDeleting(
site_instance->GetId()));
}
-bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation(
+bool ChromeContentBrowserClient::ShouldSwapBrowsingInstanceForNavigation(
+ content::BrowserContext* browser_context,
const GURL& current_url,
const GURL& new_url) {
- if (current_url.is_empty()) {
- // Always choose a new process when navigating to extension URLs. The
- // process grouping logic will combine all of a given extension's pages
- // into the same process.
- if (new_url.SchemeIs(chrome::kExtensionScheme))
- return true;
-
+ Profile* profile = Profile::FromBrowserContext(browser_context);
+ ExtensionService* service = profile->GetExtensionService();
+ if (!service)
return false;
- }
- // Also, we must switch if one is an extension and the other is not the exact
- // same extension.
- if (current_url.SchemeIs(chrome::kExtensionScheme) ||
- new_url.SchemeIs(chrome::kExtensionScheme)) {
- if (current_url.GetOrigin() != new_url.GetOrigin())
- return true;
- }
-
- return false;
+ // We must use a new BrowsingInstance (forcing a process swap and disabling
+ // scripting by existing tabs) if one of the URLs is an extension and the
+ // other is not the exact same extension.
+ //
+ // We ignore hosted apps here so that other tabs in their BrowsingInstance can
+ // script them. Navigations to/from a hosted app will still trigger a
+ // SiteInstance swap in RenderViewHostManager.
+ //
+ // However, we do use a new BrowsingInstance for isolated apps, which should
+ // not be scriptable by other tabs.
+ const Extension* current_extension =
+ GetExtensionOrIsolatedApp(current_url, service);
+ const Extension* new_extension = GetExtensionOrIsolatedApp(new_url, service);
+ return current_extension != new_extension;
}
bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect(
« no previous file with comments | « chrome/browser/chrome_content_browser_client.h ('k') | content/browser/debugger/devtools_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698