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

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

Issue 8827013: Move/replace/rename URL-based extension getters from ExtensionService to/in ExtensionSet. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: origins Created 9 years 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 <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include "chrome/browser/ssl/ssl_blocking_page.h" 50 #include "chrome/browser/ssl/ssl_blocking_page.h"
51 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" 51 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h"
52 #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h" 52 #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h"
53 #include "chrome/browser/tab_contents/tab_util.h" 53 #include "chrome/browser/tab_contents/tab_util.h"
54 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 54 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
55 #include "chrome/browser/ui/webui/chrome_web_ui_factory.h" 55 #include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
56 #include "chrome/common/child_process_logging.h" 56 #include "chrome/common/child_process_logging.h"
57 #include "chrome/common/chrome_constants.h" 57 #include "chrome/common/chrome_constants.h"
58 #include "chrome/common/chrome_switches.h" 58 #include "chrome/common/chrome_switches.h"
59 #include "chrome/common/extensions/extension.h" 59 #include "chrome/common/extensions/extension.h"
60 #include "chrome/common/extensions/extension_set.h"
60 #include "chrome/common/logging_chrome.h" 61 #include "chrome/common/logging_chrome.h"
61 #include "chrome/common/pref_names.h" 62 #include "chrome/common/pref_names.h"
62 #include "chrome/common/render_messages.h" 63 #include "chrome/common/render_messages.h"
63 #include "chrome/common/url_constants.h" 64 #include "chrome/common/url_constants.h"
64 #include "content/browser/browser_url_handler.h" 65 #include "content/browser/browser_url_handler.h"
65 #include "content/browser/browsing_instance.h" 66 #include "content/browser/browsing_instance.h"
66 #include "content/browser/plugin_process_host.h" 67 #include "content/browser/plugin_process_host.h"
67 #include "content/browser/renderer_host/render_view_host.h" 68 #include "content/browser/renderer_host/render_view_host.h"
68 #include "content/browser/resource_context.h" 69 #include "content/browser/resource_context.h"
69 #include "content/browser/site_instance.h" 70 #include "content/browser/site_instance.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // Default to a normal renderer cause it is lower privileged. This should only 172 // Default to a normal renderer cause it is lower privileged. This should only
172 // occur if the URL on a site instance is either malformed, or uninitialized. 173 // occur if the URL on a site instance is either malformed, or uninitialized.
173 // If it is malformed, then there is no need for better privileges anyways. 174 // If it is malformed, then there is no need for better privileges anyways.
174 // If it is uninitialized, but eventually settles on being an a scheme other 175 // If it is uninitialized, but eventually settles on being an a scheme other
175 // than normal webrenderer, the navigation logic will correct us out of band 176 // than normal webrenderer, the navigation logic will correct us out of band
176 // anyways. 177 // anyways.
177 if (!url.is_valid()) 178 if (!url.is_valid())
178 return PRIV_NORMAL; 179 return PRIV_NORMAL;
179 180
180 if (url.SchemeIs(chrome::kExtensionScheme)) { 181 if (url.SchemeIs(chrome::kExtensionScheme)) {
181 const Extension* extension = service->GetExtensionByURL(url); 182 const Extension* extension =
183 service->extensions()->GetByURL(ExtensionURLInfo(url));
182 if (extension && extension->is_storage_isolated()) 184 if (extension && extension->is_storage_isolated())
183 return PRIV_ISOLATED; 185 return PRIV_ISOLATED;
184 if (extension && extension->is_hosted_app()) 186 if (extension && extension->is_hosted_app())
185 return PRIV_HOSTED; 187 return PRIV_HOSTED;
186 188
187 return PRIV_EXTENSION; 189 return PRIV_EXTENSION;
188 } 190 }
189 191
190 return PRIV_NORMAL; 192 return PRIV_NORMAL;
191 } 193 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 GURL ChromeContentBrowserClient::GetEffectiveURL( 371 GURL ChromeContentBrowserClient::GetEffectiveURL(
370 content::BrowserContext* browser_context, const GURL& url) { 372 content::BrowserContext* browser_context, const GURL& url) {
371 Profile* profile = Profile::FromBrowserContext(browser_context); 373 Profile* profile = Profile::FromBrowserContext(browser_context);
372 // Get the effective URL for the given actual URL. If the URL is part of an 374 // Get the effective URL for the given actual URL. If the URL is part of an
373 // installed app, the effective URL is an extension URL with the ID of that 375 // installed app, the effective URL is an extension URL with the ID of that
374 // extension as the host. This has the effect of grouping apps together in 376 // extension as the host. This has the effect of grouping apps together in
375 // a common SiteInstance. 377 // a common SiteInstance.
376 if (!profile || !profile->GetExtensionService()) 378 if (!profile || !profile->GetExtensionService())
377 return url; 379 return url;
378 380
379 const Extension* extension = 381 const Extension* extension = profile->GetExtensionService()->extensions()->
380 profile->GetExtensionService()->GetExtensionByWebExtent(url); 382 GetByWebExtent(ExtensionURLInfo(url));
381 if (!extension) 383 if (!extension)
382 return url; 384 return url;
383 385
384 // Bookmark apps do not use the hosted app process model, and should be 386 // Bookmark apps do not use the hosted app process model, and should be
385 // treated as normal URLs. 387 // treated as normal URLs.
386 if (extension->from_bookmark()) 388 if (extension->from_bookmark())
387 return url; 389 return url;
388 390
389 // If the URL is part of an extension's web extent, convert it to an 391 // If the URL is part of an extension's web extent, convert it to an
390 // extension URL. 392 // extension URL.
391 return extension->GetResourceURL(url.path()); 393 return extension->GetResourceURL(url.path());
Aaron Boodman 2011/12/09 16:05:20 This is kinda funky. We could just return extensio
Yoyo Zhou 2011/12/09 19:59:09 Doesn't that lose the path?
392 } 394 }
393 395
394 bool ChromeContentBrowserClient::ShouldUseProcessPerSite( 396 bool ChromeContentBrowserClient::ShouldUseProcessPerSite(
395 content::BrowserContext* browser_context, const GURL& effective_url) { 397 content::BrowserContext* browser_context, const GURL& effective_url) {
396 // Non-extension URLs should generally use process-per-site-instance. 398 // Non-extension URLs should generally use process-per-site-instance.
397 // Because we expect to use the effective URL, URLs for hosted apps (apart 399 // Because we expect to use the effective URL, URLs for hosted apps (apart
398 // from bookmark apps) should have an extension scheme by now. 400 // from bookmark apps) should have an extension scheme by now.
399 if (!effective_url.SchemeIs(chrome::kExtensionScheme)) 401 if (!effective_url.SchemeIs(chrome::kExtensionScheme))
400 return false; 402 return false;
401 403
402 Profile* profile = Profile::FromBrowserContext(browser_context); 404 Profile* profile = Profile::FromBrowserContext(browser_context);
403 if (!profile || !profile->GetExtensionService()) 405 if (!profile || !profile->GetExtensionService())
404 return false; 406 return false;
405 407
406 const Extension* extension = 408 const Extension* extension = profile->GetExtensionService()->extensions()->
407 profile->GetExtensionService()->GetExtensionByURL(effective_url); 409 GetByURL(ExtensionURLInfo(effective_url));
408 if (!extension) 410 if (!extension)
409 return false; 411 return false;
410 412
411 // If the URL is part of a hosted app that does not have the background 413 // If the URL is part of a hosted app that does not have the background
412 // permission, we want to give each instance its own process to improve 414 // permission, we want to give each instance its own process to improve
413 // responsiveness. 415 // responsiveness.
414 if (extension->GetType() == Extension::TYPE_HOSTED_APP && 416 if (extension->GetType() == Extension::TYPE_HOSTED_APP &&
415 !extension->HasAPIPermission(ExtensionAPIPermission::kBackground)) 417 !extension->HasAPIPermission(ExtensionAPIPermission::kBackground))
416 return false; 418 return false;
417 419
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 SiteInstance* site_instance) { 480 SiteInstance* site_instance) {
479 CHECK(site_instance->HasProcess()); 481 CHECK(site_instance->HasProcess());
480 482
481 Profile* profile = Profile::FromBrowserContext( 483 Profile* profile = Profile::FromBrowserContext(
482 site_instance->browsing_instance()->browser_context()); 484 site_instance->browsing_instance()->browser_context());
483 ExtensionService* service = profile->GetExtensionService(); 485 ExtensionService* service = profile->GetExtensionService();
484 if (!service) 486 if (!service)
485 return; 487 return;
486 488
487 const Extension* extension = 489 const Extension* extension =
488 service->GetExtensionByURL(site_instance->site()); 490 service->extensions()->GetByURL(ExtensionURLInfo(site_instance->site()));
489 if (!extension)
490 extension = service->GetExtensionByWebExtent(site_instance->site());
491 if (!extension) 491 if (!extension)
492 return; 492 return;
493 493
494 service->process_map()->Insert(extension->id(), 494 service->process_map()->Insert(extension->id(),
495 site_instance->GetProcess()->GetID(), 495 site_instance->GetProcess()->GetID(),
496 site_instance->id()); 496 site_instance->id());
497 BrowserThread::PostTask( 497 BrowserThread::PostTask(
498 BrowserThread::IO, FROM_HERE, 498 BrowserThread::IO, FROM_HERE,
499 base::Bind(&ExtensionInfoMap::RegisterExtensionProcess, 499 base::Bind(&ExtensionInfoMap::RegisterExtensionProcess,
500 profile->GetExtensionInfoMap(), 500 profile->GetExtensionInfoMap(),
501 extension->id(), 501 extension->id(),
502 site_instance->GetProcess()->GetID(), 502 site_instance->GetProcess()->GetID(),
503 site_instance->id())); 503 site_instance->id()));
504 } 504 }
505 505
506 void ChromeContentBrowserClient::SiteInstanceDeleting( 506 void ChromeContentBrowserClient::SiteInstanceDeleting(
507 SiteInstance* site_instance) { 507 SiteInstance* site_instance) {
508 if (!site_instance->HasProcess()) 508 if (!site_instance->HasProcess())
509 return; 509 return;
510 510
511 Profile* profile = Profile::FromBrowserContext( 511 Profile* profile = Profile::FromBrowserContext(
512 site_instance->browsing_instance()->browser_context()); 512 site_instance->browsing_instance()->browser_context());
513 ExtensionService* service = profile->GetExtensionService(); 513 ExtensionService* service = profile->GetExtensionService();
514 if (!service) 514 if (!service)
515 return; 515 return;
516 516
517 const Extension* extension = 517 const Extension* extension =
518 service->GetExtensionByURL(site_instance->site()); 518 service->extensions()->GetByURL(ExtensionURLInfo(site_instance->site()));
519 if (!extension)
520 extension = service->GetExtensionByWebExtent(site_instance->site());
521 if (!extension) 519 if (!extension)
522 return; 520 return;
523 521
524 service->process_map()->Remove(extension->id(), 522 service->process_map()->Remove(extension->id(),
525 site_instance->GetProcess()->GetID(), 523 site_instance->GetProcess()->GetID(),
526 site_instance->id()); 524 site_instance->id());
527 BrowserThread::PostTask( 525 BrowserThread::PostTask(
528 BrowserThread::IO, FROM_HERE, 526 BrowserThread::IO, FROM_HERE,
529 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess, 527 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess,
530 profile->GetExtensionInfoMap(), 528 profile->GetExtensionInfoMap(),
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 #if defined(USE_NSS) 1209 #if defined(USE_NSS)
1212 crypto::CryptoModuleBlockingPasswordDelegate* 1210 crypto::CryptoModuleBlockingPasswordDelegate*
1213 ChromeContentBrowserClient::GetCryptoPasswordDelegate( 1211 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
1214 const GURL& url) { 1212 const GURL& url) {
1215 return browser::NewCryptoModuleBlockingDialogDelegate( 1213 return browser::NewCryptoModuleBlockingDialogDelegate(
1216 browser::kCryptoModulePasswordKeygen, url.host()); 1214 browser::kCryptoModulePasswordKeygen, url.host());
1217 } 1215 }
1218 #endif 1216 #endif
1219 1217
1220 } // namespace chrome 1218 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698