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

Side by Side Diff: chrome/browser/extensions/extension_process_manager.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
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "chrome/browser/extensions/extension_process_manager.h" 7 #include "chrome/browser/extensions/extension_process_manager.h"
8 8
9 #include "chrome/browser/ui/browser_window.h" 9 #include "chrome/browser/ui/browser_window.h"
10 #include "content/browser/browsing_instance.h" 10 #include "content/browser/browsing_instance.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 virtual void CreateBackgroundHost(const Extension* extension, 47 virtual void CreateBackgroundHost(const Extension* extension,
48 const GURL& url); 48 const GURL& url);
49 virtual SiteInstance* GetSiteInstanceForURL(const GURL& url); 49 virtual SiteInstance* GetSiteInstanceForURL(const GURL& url);
50 50
51 private: 51 private:
52 // content::NotificationObserver: 52 // content::NotificationObserver:
53 virtual void Observe(int type, 53 virtual void Observe(int type,
54 const content::NotificationSource& source, 54 const content::NotificationSource& source,
55 const content::NotificationDetails& details); 55 const content::NotificationDetails& details);
56 56
57 // Returns the extension for an URL, which can either be a chrome-extension
58 // URL or a web app URL.
59 const Extension* GetExtensionOrAppByURL(const GURL& url);
60
61 // Returns true if the extension is allowed to run in incognito mode. 57 // Returns true if the extension is allowed to run in incognito mode.
62 bool IsIncognitoEnabled(const Extension* extension); 58 bool IsIncognitoEnabled(const Extension* extension);
63 59
64 ExtensionProcessManager* original_manager_; 60 ExtensionProcessManager* original_manager_;
65 }; 61 };
66 62
67 static void CreateBackgroundHostForExtensionLoad( 63 static void CreateBackgroundHostForExtensionLoad(
68 ExtensionProcessManager* manager, const Extension* extension) { 64 ExtensionProcessManager* manager, const Extension* extension) {
69 // Start the process for the master page, if it exists and we're not lazy. 65 // Start the process for the master page, if it exists and we're not lazy.
70 if (!CommandLine::ForCurrentProcess()->HasSwitch( 66 if (!CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 135
140 ExtensionHost* ExtensionProcessManager::CreateViewHost( 136 ExtensionHost* ExtensionProcessManager::CreateViewHost(
141 const GURL& url, Browser* browser, content::ViewType view_type) { 137 const GURL& url, Browser* browser, content::ViewType view_type) {
142 // A NULL browser may only be given for pop-up views. 138 // A NULL browser may only be given for pop-up views.
143 DCHECK(browser || 139 DCHECK(browser ||
144 (!browser && view_type == chrome::VIEW_TYPE_EXTENSION_POPUP)); 140 (!browser && view_type == chrome::VIEW_TYPE_EXTENSION_POPUP));
145 Profile* profile = 141 Profile* profile =
146 Profile::FromBrowserContext(browsing_instance_->browser_context()); 142 Profile::FromBrowserContext(browsing_instance_->browser_context());
147 ExtensionService* service = profile->GetExtensionService(); 143 ExtensionService* service = profile->GetExtensionService();
148 if (service) { 144 if (service) {
149 const Extension* extension = service->GetExtensionByURL(url); 145 const Extension* extension =
146 service->extensions()->GetByID(url.host());
150 if (extension) 147 if (extension)
151 return CreateViewHost(extension, url, browser, view_type); 148 return CreateViewHost(extension, url, browser, view_type);
152 } 149 }
153 return NULL; 150 return NULL;
154 } 151 }
155 152
156 ExtensionHost* ExtensionProcessManager::CreatePopupHost( 153 ExtensionHost* ExtensionProcessManager::CreatePopupHost(
157 const Extension* extension, const GURL& url, Browser* browser) { 154 const Extension* extension, const GURL& url, Browser* browser) {
158 return CreateViewHost( 155 return CreateViewHost(
159 extension, url, browser, chrome::VIEW_TYPE_EXTENSION_POPUP); 156 extension, url, browser, chrome::VIEW_TYPE_EXTENSION_POPUP);
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 if (IsIncognitoEnabled(extension)) 429 if (IsIncognitoEnabled(extension))
433 ExtensionProcessManager::CreateBackgroundHost(extension, url); 430 ExtensionProcessManager::CreateBackgroundHost(extension, url);
434 } else { 431 } else {
435 // Do nothing. If an extension is spanning, then its original-profile 432 // Do nothing. If an extension is spanning, then its original-profile
436 // background page is shared with incognito, so we don't create another. 433 // background page is shared with incognito, so we don't create another.
437 } 434 }
438 } 435 }
439 436
440 SiteInstance* IncognitoExtensionProcessManager::GetSiteInstanceForURL( 437 SiteInstance* IncognitoExtensionProcessManager::GetSiteInstanceForURL(
441 const GURL& url) { 438 const GURL& url) {
442 const Extension* extension = GetExtensionOrAppByURL(url);
443 if (!extension || extension->incognito_split_mode()) {
444 return ExtensionProcessManager::GetSiteInstanceForURL(url);
445 } else {
446 return original_manager_->GetSiteInstanceForURL(url);
447 }
448 }
449
450 const Extension* IncognitoExtensionProcessManager::GetExtensionOrAppByURL(
451 const GURL& url) {
452 Profile* profile = 439 Profile* profile =
453 Profile::FromBrowserContext(browsing_instance_->browser_context()); 440 Profile::FromBrowserContext(browsing_instance_->browser_context());
454 ExtensionService* service = profile->GetExtensionService(); 441 ExtensionService* service = profile->GetExtensionService();
455 if (!service) 442 if (service) {
456 return NULL; 443 const Extension* extension = service->extensions()->GetExtensionOrAppByURL(
457 return (url.SchemeIs(chrome::kExtensionScheme)) ? 444 ExtensionURLInfo(url));
458 service->GetExtensionByURL(url) : service->GetExtensionByWebExtent(url); 445 if (extension && !extension->incognito_split_mode())
446 return original_manager_->GetSiteInstanceForURL(url);
447 }
448 return ExtensionProcessManager::GetSiteInstanceForURL(url);
459 } 449 }
460 450
461 bool IncognitoExtensionProcessManager::IsIncognitoEnabled( 451 bool IncognitoExtensionProcessManager::IsIncognitoEnabled(
462 const Extension* extension) { 452 const Extension* extension) {
463 // Keep in sync with duplicate in extension_info_map.cc. 453 // Keep in sync with duplicate in extension_info_map.cc.
464 Profile* profile = 454 Profile* profile =
465 Profile::FromBrowserContext(browsing_instance_->browser_context()); 455 Profile::FromBrowserContext(browsing_instance_->browser_context());
466 ExtensionService* service = profile->GetExtensionService(); 456 ExtensionService* service = profile->GetExtensionService();
467 return service && service->IsIncognitoEnabled(extension->id()); 457 return service && service->IsIncognitoEnabled(extension->id());
468 } 458 }
(...skipping 21 matching lines...) Expand all
490 if (service && service->is_ready()) 480 if (service && service->is_ready())
491 CreateBackgroundHostsForProfileStartup(this, service->extensions()); 481 CreateBackgroundHostsForProfileStartup(this, service->extensions());
492 } 482 }
493 break; 483 break;
494 } 484 }
495 default: 485 default:
496 ExtensionProcessManager::Observe(type, source, details); 486 ExtensionProcessManager::Observe(type, source, details);
497 break; 487 break;
498 } 488 }
499 } 489 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_navigation_observer.cc ('k') | chrome/browser/extensions/extension_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698