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

Unified Diff: chrome/browser/extensions/extension_service.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: extent 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 side-by-side diff with in-line comments
Download patch
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(

Powered by Google App Engine
This is Rietveld 408576698