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

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: id 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/help_app_launcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()->GetByID(url.host());
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 GetHostedAppByURL(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());
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 GetExtensionOrAppByURL(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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 SiteInstance* site_instance) { 484 SiteInstance* site_instance) {
483 CHECK(site_instance->HasProcess()); 485 CHECK(site_instance->HasProcess());
484 486
485 Profile* profile = Profile::FromBrowserContext( 487 Profile* profile = Profile::FromBrowserContext(
486 site_instance->browsing_instance()->browser_context()); 488 site_instance->browsing_instance()->browser_context());
487 ExtensionService* service = profile->GetExtensionService(); 489 ExtensionService* service = profile->GetExtensionService();
488 if (!service) 490 if (!service)
489 return; 491 return;
490 492
491 const Extension* extension = 493 const Extension* extension =
492 service->GetExtensionByURL(site_instance->site()); 494 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(
493 if (!extension) 495 site_instance->site()));
494 extension = service->GetExtensionByWebExtent(site_instance->site());
495 if (!extension) 496 if (!extension)
496 return; 497 return;
497 498
498 service->process_map()->Insert(extension->id(), 499 service->process_map()->Insert(extension->id(),
499 site_instance->GetProcess()->GetID(), 500 site_instance->GetProcess()->GetID(),
500 site_instance->id()); 501 site_instance->id());
501 BrowserThread::PostTask( 502 BrowserThread::PostTask(
502 BrowserThread::IO, FROM_HERE, 503 BrowserThread::IO, FROM_HERE,
503 base::Bind(&ExtensionInfoMap::RegisterExtensionProcess, 504 base::Bind(&ExtensionInfoMap::RegisterExtensionProcess,
504 profile->GetExtensionInfoMap(), 505 profile->GetExtensionInfoMap(),
505 extension->id(), 506 extension->id(),
506 site_instance->GetProcess()->GetID(), 507 site_instance->GetProcess()->GetID(),
507 site_instance->id())); 508 site_instance->id()));
508 } 509 }
509 510
510 void ChromeContentBrowserClient::SiteInstanceDeleting( 511 void ChromeContentBrowserClient::SiteInstanceDeleting(
511 SiteInstance* site_instance) { 512 SiteInstance* site_instance) {
512 if (!site_instance->HasProcess()) 513 if (!site_instance->HasProcess())
513 return; 514 return;
514 515
515 Profile* profile = Profile::FromBrowserContext( 516 Profile* profile = Profile::FromBrowserContext(
516 site_instance->browsing_instance()->browser_context()); 517 site_instance->browsing_instance()->browser_context());
517 ExtensionService* service = profile->GetExtensionService(); 518 ExtensionService* service = profile->GetExtensionService();
518 if (!service) 519 if (!service)
519 return; 520 return;
520 521
521 const Extension* extension = 522 const Extension* extension =
522 service->GetExtensionByURL(site_instance->site()); 523 service->extensions()->GetExtensionOrAppByURL(
523 if (!extension) 524 ExtensionURLInfo(site_instance->site()));
524 extension = service->GetExtensionByWebExtent(site_instance->site());
525 if (!extension) 525 if (!extension)
526 return; 526 return;
527 527
528 service->process_map()->Remove(extension->id(), 528 service->process_map()->Remove(extension->id(),
529 site_instance->GetProcess()->GetID(), 529 site_instance->GetProcess()->GetID(),
530 site_instance->id()); 530 site_instance->id());
531 BrowserThread::PostTask( 531 BrowserThread::PostTask(
532 BrowserThread::IO, FROM_HERE, 532 BrowserThread::IO, FROM_HERE,
533 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess, 533 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess,
534 profile->GetExtensionInfoMap(), 534 profile->GetExtensionInfoMap(),
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 #if defined(USE_NSS) 1215 #if defined(USE_NSS)
1216 crypto::CryptoModuleBlockingPasswordDelegate* 1216 crypto::CryptoModuleBlockingPasswordDelegate*
1217 ChromeContentBrowserClient::GetCryptoPasswordDelegate( 1217 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
1218 const GURL& url) { 1218 const GURL& url) {
1219 return browser::NewCryptoModuleBlockingDialogDelegate( 1219 return browser::NewCryptoModuleBlockingDialogDelegate(
1220 browser::kCryptoModulePasswordKeygen, url.host()); 1220 browser::kCryptoModulePasswordKeygen, url.host());
1221 } 1221 }
1222 #endif 1222 #endif
1223 1223
1224 } // namespace chrome 1224 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/help_app_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698