diff options
author | yoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-13 01:47:44 +0000 |
---|---|---|
committer | yoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-13 01:47:44 +0000 |
commit | 615d88f4d005b8f9f79b5bf65ac21d927a46fda2 (patch) | |
tree | 489be1953f84aa25184cd37a3145eae70260ea66 /chrome/common/extensions/extension_set.cc | |
parent | ee5a21bc9171c6b1d4c852b226e2545bb2340f6f (diff) | |
download | chromium_src-615d88f4d005b8f9f79b5bf65ac21d927a46fda2.zip chromium_src-615d88f4d005b8f9f79b5bf65ac21d927a46fda2.tar.gz chromium_src-615d88f4d005b8f9f79b5bf65ac21d927a46fda2.tar.bz2 |
Move/replace/rename URL-based extension getters from ExtensionService to/in ExtensionSet.
ExtensionService::GetExtensionByURL -> GetByID with the host
ExtensionService::GetExtensionByWebExtent -> GetHostedAppByURL
GetByURL -> GetExtensionOrAppByURL
BUG=104091
TEST=existing tests
Review URL: http://codereview.chromium.org/8827013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114148 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/extension_set.cc')
-rw-r--r-- | chrome/common/extensions/extension_set.cc | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/chrome/common/extensions/extension_set.cc b/chrome/common/extensions/extension_set.cc index c99220b..d6d18f7 100644 --- a/chrome/common/extensions/extension_set.cc +++ b/chrome/common/extensions/extension_set.cc @@ -49,20 +49,22 @@ void ExtensionSet::Clear() { extensions_.clear(); } -std::string ExtensionSet::GetIDByURL(const ExtensionURLInfo& info) const { +std::string ExtensionSet::GetExtensionOrAppIDByURL( + const ExtensionURLInfo& info) const { DCHECK(!info.origin().isNull()); if (info.url().SchemeIs(chrome::kExtensionScheme)) return info.origin().isUnique() ? "" : info.url().host(); - const Extension* extension = GetByURL(info); + const Extension* extension = GetExtensionOrAppByURL(info); if (!extension) return ""; return extension->id(); } -const Extension* ExtensionSet::GetByURL(const ExtensionURLInfo& info) const { +const Extension* ExtensionSet::GetExtensionOrAppByURL( + const ExtensionURLInfo& info) const { // In the common case, the document's origin will correspond to its URL, // but in some rare cases involving sandboxing, the two will be different. // We catch those cases by checking whether the document's origin is unique. @@ -74,10 +76,26 @@ const Extension* ExtensionSet::GetByURL(const ExtensionURLInfo& info) const { if (info.url().SchemeIs(chrome::kExtensionScheme)) return GetByID(info.url().host()); - ExtensionMap::const_iterator i = extensions_.begin(); - for (; i != extensions_.end(); ++i) { - if (i->second->web_extent().MatchesURL(info.url())) - return i->second.get(); + return GetHostedAppByURL(info); +} + +const Extension* ExtensionSet::GetHostedAppByURL( + const ExtensionURLInfo& info) const { + for (ExtensionMap::const_iterator iter = extensions_.begin(); + iter != extensions_.end(); ++iter) { + if (iter->second->web_extent().MatchesURL(info.url())) + return iter->second.get(); + } + + return NULL; +} + +const Extension* ExtensionSet::GetHostedAppByOverlappingWebExtent( + const URLPatternSet& extent) const { + for (ExtensionMap::const_iterator iter = extensions_.begin(); + iter != extensions_.end(); ++iter) { + if (iter->second->web_extent().OverlapsWith(extent)) + return iter->second.get(); } return NULL; @@ -85,8 +103,8 @@ const Extension* ExtensionSet::GetByURL(const ExtensionURLInfo& info) const { bool ExtensionSet::InSameExtent(const GURL& old_url, const GURL& new_url) const { - return GetByURL(ExtensionURLInfo(old_url)) == - GetByURL(ExtensionURLInfo(new_url)); + return GetExtensionOrAppByURL(ExtensionURLInfo(old_url)) == + GetExtensionOrAppByURL(ExtensionURLInfo(new_url)); } const Extension* ExtensionSet::GetByID(const std::string& id) const { |