OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/app/breakpad_mac.h" | 8 #include "chrome/app/breakpad_mac.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/character_encoding.h" | 10 #include "chrome/browser/character_encoding.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 profile->GetExtensionProcessManager(); | 91 profile->GetExtensionProcessManager(); |
92 CHECK(process_manager); | 92 CHECK(process_manager); |
93 | 93 |
94 // This can happen if somebody typos a chrome-extension:// URL. | 94 // This can happen if somebody typos a chrome-extension:// URL. |
95 const Extension* extension = service->GetExtensionByURL(site); | 95 const Extension* extension = service->GetExtensionByURL(site); |
96 if (!extension) | 96 if (!extension) |
97 return; | 97 return; |
98 | 98 |
99 site_instance->GetProcess()->mark_is_extension_process(); | 99 site_instance->GetProcess()->mark_is_extension_process(); |
100 | 100 |
101 // Register the association between extension and process with | 101 // Register the association between extension and SiteInstance with |
102 // ExtensionProcessManager. | 102 // ExtensionProcessManager. |
103 process_manager->RegisterExtensionProcess(extension->id(), process->id()); | 103 // TODO(creis): Use this to replace SetInstalledAppForRenderer below. |
| 104 process_manager->RegisterExtensionSiteInstance(site_instance->id(), |
| 105 extension->id()); |
104 | 106 |
105 if (extension->is_app()) { | 107 if (extension->is_app()) { |
106 render_view_host->Send( | 108 render_view_host->Send( |
107 new ExtensionMsg_ActivateApplication(extension->id())); | 109 new ExtensionMsg_ActivateApplication(extension->id())); |
108 // Record which, if any, installed app is associated with this process. | 110 // Record which, if any, installed app is associated with this process. |
109 // TODO(aa): Totally lame to store this state in a global map in extension | 111 // TODO(aa): Totally lame to store this state in a global map in extension |
110 // service. Can we get it from EPM instead? | 112 // service. Can we get it from EPM instead? |
111 service->SetInstalledAppForRenderer(process->id(), extension); | 113 service->SetInstalledAppForRenderer(process->id(), extension); |
112 } | 114 } |
113 | 115 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 const Extension* extension = | 189 const Extension* extension = |
188 profile->GetExtensionService()->GetExtensionByWebExtent(url); | 190 profile->GetExtensionService()->GetExtensionByWebExtent(url); |
189 if (!extension) | 191 if (!extension) |
190 return url; | 192 return url; |
191 | 193 |
192 // If the URL is part of an extension's web extent, convert it to an | 194 // If the URL is part of an extension's web extent, convert it to an |
193 // extension URL. | 195 // extension URL. |
194 return extension->GetResourceURL(url.path()); | 196 return extension->GetResourceURL(url.path()); |
195 } | 197 } |
196 | 198 |
| 199 bool ChromeContentBrowserClient::ShouldUseProcessPerSite( |
| 200 Profile* profile, |
| 201 const GURL& effective_url) { |
| 202 // Non-extension URLs should generally use process-per-site-instance. |
| 203 // Because we expect to use the effective URL, hosted apps URLs should have |
| 204 // an extension scheme by now. |
| 205 if (!effective_url.SchemeIs(chrome::kExtensionScheme)) |
| 206 return false; |
| 207 |
| 208 if (!profile || !profile->GetExtensionService()) |
| 209 return false; |
| 210 |
| 211 const Extension* extension = |
| 212 profile->GetExtensionService()->GetExtensionByURL(effective_url); |
| 213 if (!extension) |
| 214 return false; |
| 215 |
| 216 // If the URL is part of a hosted app that does not have the background |
| 217 // permission, we want to give each instance its own process to improve |
| 218 // responsiveness. |
| 219 if (extension->GetType() == Extension::TYPE_HOSTED_APP && |
| 220 !extension->HasAPIPermission(ExtensionAPIPermission::kBackground)) |
| 221 return false; |
| 222 |
| 223 // Hosted apps that have the background permission must use process per site, |
| 224 // since all instances can make synchronous calls to the background window. |
| 225 // Other extensions should use process per site as well. |
| 226 return true; |
| 227 } |
| 228 |
197 bool ChromeContentBrowserClient::IsURLSameAsAnySiteInstance(const GURL& url) { | 229 bool ChromeContentBrowserClient::IsURLSameAsAnySiteInstance(const GURL& url) { |
198 return url == GURL(chrome::kChromeUICrashURL) || | 230 return url == GURL(chrome::kChromeUICrashURL) || |
199 url == GURL(chrome::kChromeUIKillURL) || | 231 url == GURL(chrome::kChromeUIKillURL) || |
200 url == GURL(chrome::kChromeUIHangURL) || | 232 url == GURL(chrome::kChromeUIHangURL) || |
201 url == GURL(chrome::kChromeUIShorthangURL); | 233 url == GURL(chrome::kChromeUIShorthangURL); |
202 } | 234 } |
203 | 235 |
204 std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName( | 236 std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName( |
205 const std::string& alias_name) { | 237 const std::string& alias_name) { |
206 return CharacterEncoding::GetCanonicalEncodingNameByAliasName(alias_name); | 238 return CharacterEncoding::GetCanonicalEncodingNameByAliasName(alias_name); |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 #if defined(USE_NSS) | 662 #if defined(USE_NSS) |
631 crypto::CryptoModuleBlockingPasswordDelegate* | 663 crypto::CryptoModuleBlockingPasswordDelegate* |
632 ChromeContentBrowserClient::GetCryptoPasswordDelegate( | 664 ChromeContentBrowserClient::GetCryptoPasswordDelegate( |
633 const GURL& url) { | 665 const GURL& url) { |
634 return browser::NewCryptoModuleBlockingDialogDelegate( | 666 return browser::NewCryptoModuleBlockingDialogDelegate( |
635 browser::kCryptoModulePasswordKeygen, url.host()); | 667 browser::kCryptoModulePasswordKeygen, url.host()); |
636 } | 668 } |
637 #endif | 669 #endif |
638 | 670 |
639 } // namespace chrome | 671 } // namespace chrome |
OLD | NEW |