Index: chrome/browser/extensions/extension_service.cc |
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc |
index 3a6ff8b2c19c3b7e30b2d520324bd35a828c7d36..4c34eb363264d9c63647d9f8b99bab1573682601 100644 |
--- a/chrome/browser/extensions/extension_service.cc |
+++ b/chrome/browser/extensions/extension_service.cc |
@@ -253,8 +253,10 @@ static const char* kAllowedDownloadURLPatterns[] = { |
bool ExtensionService::IsDownloadFromGallery(const GURL& download_url, |
const GURL& referrer_url) { |
- const Extension* download_extension = GetExtensionByWebExtent(download_url); |
- const Extension* referrer_extension = GetExtensionByWebExtent(referrer_url); |
+ const Extension* download_extension = |
+ extensions()->GetByWebExtent(download_url); |
+ const Extension* referrer_extension = |
+ extensions()->GetByWebExtent(referrer_url); |
const Extension* webstore_app = GetWebStoreApp(); |
bool referrer_valid = (referrer_extension == webstore_app); |
@@ -305,13 +307,7 @@ bool ExtensionService::IsDownloadFromGallery(const GURL& download_url, |
} |
const Extension* ExtensionService::GetInstalledApp(const GURL& url) { |
- // Check for hosted app. |
- const Extension* app = GetExtensionByWebExtent(url); |
- if (app) |
- return app; |
- |
- // Check for packaged app. |
- app = GetExtensionByURL(url); |
+ const Extension* app = extensions_.GetByURL(ExtensionURLInfo(url)); |
if (app && app->is_app()) |
return app; |
@@ -2152,56 +2148,11 @@ const Extension* ExtensionService::GetWebStoreApp() { |
return GetExtensionById(extension_misc::kWebStoreAppId, false); |
} |
-const Extension* ExtensionService::GetExtensionByURL(const GURL& url) { |
- return url.scheme() != chrome::kExtensionScheme ? NULL : |
- GetExtensionById(url.host(), false); |
-} |
- |
-const Extension* ExtensionService::GetExtensionByWebExtent(const GURL& url) { |
- // TODO(yoz): Should be ExtensionSet::GetByURL. |
- for (ExtensionSet::const_iterator iter = extensions_.begin(); |
- iter != extensions_.end(); ++iter) { |
- if ((*iter)->web_extent().MatchesURL(url)) |
- return *iter; |
- } |
- return NULL; |
-} |
- |
-const Extension* ExtensionService::GetDisabledExtensionByWebExtent( |
- const GURL& url) { |
- // TODO(yoz): Should be ExtensionSet::GetByURL. |
- for (ExtensionSet::const_iterator iter = disabled_extensions_.begin(); |
- iter != disabled_extensions_.end(); ++iter) { |
- if ((*iter)->web_extent().MatchesURL(url)) |
- return *iter; |
- } |
- return NULL; |
-} |
- |
bool ExtensionService::ExtensionBindingsAllowed(const GURL& url) { |
- // Allow bindings for all packaged extensions. |
- // Note that GetExtensionByURL may return an Extension for hosted apps |
- // (excluding bookmark apps) if the URL came from GetEffectiveURL. |
- const Extension* extension = GetExtensionByURL(url); |
- if (extension && extension->GetType() != Extension::TYPE_HOSTED_APP) |
- return true; |
- |
- // Allow bindings for all component, hosted apps. |
- if (!extension) |
- extension = GetExtensionByWebExtent(url); |
- return (extension && extension->location() == Extension::COMPONENT); |
-} |
- |
-const Extension* ExtensionService::GetExtensionByOverlappingWebExtent( |
- const URLPatternSet& extent) { |
- // TODO(yoz): Should be in ExtensionSet. |
- for (ExtensionSet::const_iterator iter = extensions_.begin(); |
- iter != extensions_.end(); ++iter) { |
- if ((*iter)->web_extent().OverlapsWith(extent)) |
- return *iter; |
- } |
- |
- return NULL; |
+ // Allow bindings for all packaged extensions and component hosted apps. |
+ const Extension* extension = extensions_.GetByURL(ExtensionURLInfo(url)); |
+ return extension && (!extension->is_hosted_app() || |
+ extension->location() == Extension::COMPONENT); |
} |
const SkBitmap& ExtensionService::GetOmniboxIcon( |