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

Unified Diff: chrome/common/extensions/extension_set.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/extension_set.h ('k') | chrome/common/extensions/extension_set_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/extension_set.cc
diff --git a/chrome/common/extensions/extension_set.cc b/chrome/common/extensions/extension_set.cc
index c99220b407214057e8ff24164a8cd11dcf6c51f7..d6d18f7115f7847f61d141b57ada7c1391eb1fd2 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 {
« no previous file with comments | « chrome/common/extensions/extension_set.h ('k') | chrome/common/extensions/extension_set_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698