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

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

Issue 7328029: Use process-per-app-instance for hosted apps without background permission. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update tests. Created 9 years, 5 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) 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
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
102 // ExtensionProcessManager.
103 process_manager->RegisterExtensionProcess(extension->id(), process->id());
104
105 if (extension->is_app()) { 101 if (extension->is_app()) {
106 render_view_host->Send( 102 render_view_host->Send(
107 new ExtensionMsg_ActivateApplication(extension->id())); 103 new ExtensionMsg_ActivateApplication(extension->id()));
108 // Record which, if any, installed app is associated with this process. 104 // 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 105 // TODO(aa): Totally lame to store this state in a global map in extension
110 // service. Can we get it from EPM instead? 106 // service. Can we get it from EPM instead?
111 service->SetInstalledAppForRenderer(process->id(), extension); 107 service->SetInstalledAppForRenderer(process->id(), extension);
112 } 108 }
113 109
114 // Some extensions use chrome:// URLs. 110 // Some extensions use chrome:// URLs.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 const Extension* extension = 183 const Extension* extension =
188 profile->GetExtensionService()->GetExtensionByWebExtent(url); 184 profile->GetExtensionService()->GetExtensionByWebExtent(url);
189 if (!extension) 185 if (!extension)
190 return url; 186 return url;
191 187
192 // If the URL is part of an extension's web extent, convert it to an 188 // If the URL is part of an extension's web extent, convert it to an
193 // extension URL. 189 // extension URL.
194 return extension->GetResourceURL(url.path()); 190 return extension->GetResourceURL(url.path());
195 } 191 }
196 192
193 bool ChromeContentBrowserClient::ShouldUseProcessPerSite(Profile* profile,
194 const GURL& url) {
Matt Perry 2011/07/08 22:18:35 rename url to effective_url to clarify expectation
Charlie Reis 2011/07/08 22:49:50 Done.
195 // Non-extension URLs should generally use process-per-site-instance.
196 // We expect url to be the effective URL, so hosted apps URLs should have
197 // an extension scheme by now.
198 if (!url.SchemeIs(chrome::kExtensionScheme))
199 return false;
200
201 if (!profile || !profile->GetExtensionService())
202 return false;
203
204 const Extension* extension =
205 profile->GetExtensionService()->GetExtensionByURL(url);
206 if (!extension)
207 return false;
208
209 // If the URL is part of a hosted app that does not have the background
210 // permission, we want to give each instance its own process to improve
211 // responsiveness.
212 if (extension->GetType() == Extension::TYPE_HOSTED_APP &&
213 !extension->HasAPIPermission(ExtensionAPIPermission::kBackground))
214 return false;
215
216 // Hosted apps that have the background permission must use process per site,
217 // since all instances can make synchronous calls to the background window.
218 // Other extensions should use process per site as well.
219 return true;
220 }
221
197 bool ChromeContentBrowserClient::IsURLSameAsAnySiteInstance(const GURL& url) { 222 bool ChromeContentBrowserClient::IsURLSameAsAnySiteInstance(const GURL& url) {
198 return url == GURL(chrome::kChromeUICrashURL) || 223 return url == GURL(chrome::kChromeUICrashURL) ||
199 url == GURL(chrome::kChromeUIKillURL) || 224 url == GURL(chrome::kChromeUIKillURL) ||
200 url == GURL(chrome::kChromeUIHangURL) || 225 url == GURL(chrome::kChromeUIHangURL) ||
201 url == GURL(chrome::kChromeUIShorthangURL); 226 url == GURL(chrome::kChromeUIShorthangURL);
202 } 227 }
203 228
204 std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName( 229 std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName(
205 const std::string& alias_name) { 230 const std::string& alias_name) {
206 return CharacterEncoding::GetCanonicalEncodingNameByAliasName(alias_name); 231 return CharacterEncoding::GetCanonicalEncodingNameByAliasName(alias_name);
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 #if defined(USE_NSS) 655 #if defined(USE_NSS)
631 crypto::CryptoModuleBlockingPasswordDelegate* 656 crypto::CryptoModuleBlockingPasswordDelegate*
632 ChromeContentBrowserClient::GetCryptoPasswordDelegate( 657 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
633 const GURL& url) { 658 const GURL& url) {
634 return browser::NewCryptoModuleBlockingDialogDelegate( 659 return browser::NewCryptoModuleBlockingDialogDelegate(
635 browser::kCryptoModulePasswordKeygen, url.host()); 660 browser::kCryptoModulePasswordKeygen, url.host());
636 } 661 }
637 #endif 662 #endif
638 663
639 } // namespace chrome 664 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698