Chromium Code Reviews| 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 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1009 BrowserThread::PostTask( | 1009 BrowserThread::PostTask( |
| 1010 BrowserThread::IO, FROM_HERE, | 1010 BrowserThread::IO, FROM_HERE, |
| 1011 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess, | 1011 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess, |
| 1012 extensions::ExtensionSystem::Get(profile)->info_map(), | 1012 extensions::ExtensionSystem::Get(profile)->info_map(), |
| 1013 extension->id(), | 1013 extension->id(), |
| 1014 site_instance->GetProcess()->GetID(), | 1014 site_instance->GetProcess()->GetID(), |
| 1015 site_instance->GetId())); | 1015 site_instance->GetId())); |
| 1016 } | 1016 } |
| 1017 | 1017 |
| 1018 bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation( | 1018 bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation( |
| 1019 SiteInstance* site_instance, | |
| 1019 const GURL& current_url, | 1020 const GURL& current_url, |
| 1020 const GURL& new_url) { | 1021 const GURL& new_url) { |
| 1022 Profile* profile = | |
| 1023 Profile::FromBrowserContext(site_instance->GetBrowserContext()); | |
| 1024 ExtensionService* service = | |
| 1025 extensions::ExtensionSystem::Get(profile)->extension_service(); | |
| 1026 if (!service) | |
|
nasko
2013/02/19 19:20:42
nit: Put a comment on why it is fine to return ear
Charlie Reis
2013/02/22 05:08:40
On second thought, I'm going to reduce the behavio
| |
| 1027 return false; | |
| 1028 | |
| 1021 if (current_url.is_empty()) { | 1029 if (current_url.is_empty()) { |
| 1022 // Always choose a new process when navigating to extension URLs. The | 1030 // Always choose a new process when navigating to extension URLs. The |
| 1023 // process grouping logic will combine all of a given extension's pages | 1031 // process grouping logic will combine all of a given extension's pages |
| 1024 // into the same process. | 1032 // into the same process. |
| 1025 if (new_url.SchemeIs(extensions::kExtensionScheme)) | 1033 if (new_url.SchemeIs(extensions::kExtensionScheme)) |
| 1026 return true; | 1034 return true; |
| 1027 | 1035 |
| 1028 return false; | 1036 return false; |
| 1029 } | 1037 } |
| 1030 | 1038 |
| 1031 // Also, we must switch if one is an extension and the other is not the exact | 1039 // Also, we must switch if one is an extension and the other is not the exact |
| 1032 // same extension. | 1040 // same extension. |
| 1033 if (current_url.SchemeIs(extensions::kExtensionScheme) || | 1041 if (current_url.SchemeIs(extensions::kExtensionScheme) || |
| 1034 new_url.SchemeIs(extensions::kExtensionScheme)) { | 1042 new_url.SchemeIs(extensions::kExtensionScheme)) { |
| 1035 if (current_url.GetOrigin() != new_url.GetOrigin()) | 1043 if (current_url.GetOrigin() != new_url.GetOrigin()) |
| 1036 return true; | 1044 return true; |
| 1037 } | 1045 } |
| 1038 | 1046 |
| 1047 // We must swap if the URL is for an extension and we are not using an | |
| 1048 // extension process. | |
| 1049 const Extension* new_extension = | |
| 1050 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(new_url)); | |
| 1051 // Ignore all hosted apps except the Chrome Web Store, since they do not | |
| 1052 // require their own BrowsingInstance (e.g., postMessage is ok). | |
| 1053 if (new_extension && | |
| 1054 new_extension->is_hosted_app() && | |
| 1055 new_extension->id() != extension_misc::kWebStoreAppId) | |
| 1056 new_extension = NULL; | |
| 1057 if (new_extension && | |
| 1058 site_instance->HasProcess() && | |
|
nasko
2013/02/19 19:20:42
It shouldn't be possible for the site_instance not
Charlie Reis
2013/02/22 05:08:40
Actually, I'm not certain about that, so I'd prefe
| |
| 1059 !service->process_map()->Contains(site_instance->GetProcess()->GetID())) | |
|
nasko
2013/02/19 19:20:42
Why not check with Contains(extension_id, process_
Charlie Reis
2013/02/22 05:08:40
Good call. Done.
| |
| 1060 return true; | |
| 1061 | |
| 1039 return false; | 1062 return false; |
| 1040 } | 1063 } |
| 1041 | 1064 |
| 1042 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect( | 1065 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect( |
| 1043 content::ResourceContext* resource_context, const GURL& current_url, | 1066 content::ResourceContext* resource_context, const GURL& current_url, |
| 1044 const GURL& new_url) { | 1067 const GURL& new_url) { |
| 1045 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 1068 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
| 1046 return extensions::CrossesExtensionProcessBoundary( | 1069 return extensions::CrossesExtensionProcessBoundary( |
| 1047 io_data->GetExtensionInfoMap()->extensions(), | 1070 io_data->GetExtensionInfoMap()->extensions(), |
| 1048 ExtensionURLInfo(current_url), ExtensionURLInfo(new_url), false); | 1071 ExtensionURLInfo(current_url), ExtensionURLInfo(new_url), false); |
| (...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2089 io_thread_application_locale_ = locale; | 2112 io_thread_application_locale_ = locale; |
| 2090 } | 2113 } |
| 2091 | 2114 |
| 2092 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread( | 2115 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread( |
| 2093 const std::string& locale) { | 2116 const std::string& locale) { |
| 2094 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 2117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 2095 io_thread_application_locale_ = locale; | 2118 io_thread_application_locale_ = locale; |
| 2096 } | 2119 } |
| 2097 | 2120 |
| 2098 } // namespace chrome | 2121 } // namespace chrome |
| OLD | NEW |