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

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

Issue 12301013: Ensure extensions and the Chrome Web Store are loaded in new BrowsingInstances. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix review comments. Created 7 years, 10 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
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 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 BrowserThread::PostTask( 968 BrowserThread::PostTask(
969 BrowserThread::IO, FROM_HERE, 969 BrowserThread::IO, FROM_HERE,
970 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess, 970 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess,
971 extensions::ExtensionSystem::Get(profile)->info_map(), 971 extensions::ExtensionSystem::Get(profile)->info_map(),
972 extension->id(), 972 extension->id(),
973 site_instance->GetProcess()->GetID(), 973 site_instance->GetProcess()->GetID(),
974 site_instance->GetId())); 974 site_instance->GetId()));
975 } 975 }
976 976
977 bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation( 977 bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation(
978 SiteInstance* site_instance,
978 const GURL& current_url, 979 const GURL& current_url,
979 const GURL& new_url) { 980 const GURL& new_url) {
980 if (current_url.is_empty()) { 981 if (current_url.is_empty()) {
981 // Always choose a new process when navigating to extension URLs. The 982 // Always choose a new process when navigating to extension URLs. The
982 // process grouping logic will combine all of a given extension's pages 983 // process grouping logic will combine all of a given extension's pages
983 // into the same process. 984 // into the same process.
984 if (new_url.SchemeIs(extensions::kExtensionScheme)) 985 if (new_url.SchemeIs(extensions::kExtensionScheme))
985 return true; 986 return true;
986 987
987 return false; 988 return false;
988 } 989 }
989 990
990 // Also, we must switch if one is an extension and the other is not the exact 991 // Also, we must switch if one is an extension and the other is not the exact
991 // same extension. 992 // same extension.
992 if (current_url.SchemeIs(extensions::kExtensionScheme) || 993 if (current_url.SchemeIs(extensions::kExtensionScheme) ||
993 new_url.SchemeIs(extensions::kExtensionScheme)) { 994 new_url.SchemeIs(extensions::kExtensionScheme)) {
994 if (current_url.GetOrigin() != new_url.GetOrigin()) 995 if (current_url.GetOrigin() != new_url.GetOrigin())
995 return true; 996 return true;
996 } 997 }
997 998
999 // The checks below only matter if we can retrieve which extensions are
1000 // installed.
1001 Profile* profile =
1002 Profile::FromBrowserContext(site_instance->GetBrowserContext());
1003 ExtensionService* service =
1004 extensions::ExtensionSystem::Get(profile)->extension_service();
1005 if (!service)
1006 return false;
1007
1008 // We must swap if the URL is for an extension and we are not using an
1009 // extension process.
1010 const Extension* new_extension =
1011 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(new_url));
1012 // Ignore all hosted apps except the Chrome Web Store, since they do not
1013 // require their own BrowsingInstance (e.g., postMessage is ok).
1014 if (new_extension &&
1015 new_extension->is_hosted_app() &&
1016 new_extension->id() != extension_misc::kWebStoreAppId)
1017 new_extension = NULL;
1018 if (new_extension &&
1019 site_instance->HasProcess() &&
1020 !service->process_map()->Contains(new_extension->id(),
1021 site_instance->GetProcess()->GetID()))
1022 return true;
1023
998 return false; 1024 return false;
999 } 1025 }
1000 1026
1001 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect( 1027 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect(
1002 content::ResourceContext* resource_context, const GURL& current_url, 1028 content::ResourceContext* resource_context, const GURL& current_url,
1003 const GURL& new_url) { 1029 const GURL& new_url) {
1004 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); 1030 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
1005 return extensions::CrossesExtensionProcessBoundary( 1031 return extensions::CrossesExtensionProcessBoundary(
1006 io_data->GetExtensionInfoMap()->extensions(), 1032 io_data->GetExtensionInfoMap()->extensions(),
1007 ExtensionURLInfo(current_url), ExtensionURLInfo(new_url), false); 1033 ExtensionURLInfo(current_url), ExtensionURLInfo(new_url), false);
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after
2049 io_thread_application_locale_ = locale; 2075 io_thread_application_locale_ = locale;
2050 } 2076 }
2051 2077
2052 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread( 2078 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread(
2053 const std::string& locale) { 2079 const std::string& locale) {
2054 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 2080 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
2055 io_thread_application_locale_ = locale; 2081 io_thread_application_locale_ = locale;
2056 } 2082 }
2057 2083
2058 } // namespace chrome 2084 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.h ('k') | content/browser/devtools/devtools_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698