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

Unified Diff: chrome/common/extensions/extension_set.cc

Issue 16625012: Remove ExtensionURLInfo, make security decisions in render process (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address feedback Created 7 years, 5 months 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 ee538bfd0d084c1304026f93132a3a63ebe84172..5c6861c4328c68e1830319ab6fad6d939784c703 100644
--- a/chrome/common/extensions/extension_set.cc
+++ b/chrome/common/extensions/extension_set.cc
@@ -11,19 +11,8 @@
#include "chrome/common/url_constants.h"
#include "extensions/common/constants.h"
-using WebKit::WebSecurityOrigin;
using extensions::Extension;
-ExtensionURLInfo::ExtensionURLInfo(WebSecurityOrigin origin, const GURL& url)
- : origin_(origin),
- url_(url) {
- DCHECK(!origin_.isNull());
-}
-
-ExtensionURLInfo::ExtensionURLInfo(const GURL& url)
- : url_(url) {
-}
-
ExtensionSet::const_iterator::const_iterator() {}
ExtensionSet::const_iterator::const_iterator(const const_iterator& other)
@@ -75,41 +64,28 @@ void ExtensionSet::Clear() {
extensions_.clear();
}
-std::string ExtensionSet::GetExtensionOrAppIDByURL(
- const ExtensionURLInfo& info) const {
- DCHECK(!info.origin().isNull());
-
- if (info.url().SchemeIs(extensions::kExtensionScheme))
- return info.origin().isUnique() ? std::string() : info.url().host();
+std::string ExtensionSet::GetExtensionOrAppIDByURL(const GURL& url) const {
+ if (url.SchemeIs(extensions::kExtensionScheme))
+ return url.host();
- const Extension* extension = GetExtensionOrAppByURL(info);
+ const Extension* extension = GetExtensionOrAppByURL(url);
if (!extension)
return std::string();
return extension->id();
}
-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.
- // If that's not the case, then we conclude that the document's security
- // context is well-described by its URL and proceed to use only the URL.
- if (!info.origin().isNull() && info.origin().isUnique())
- return NULL;
-
- if (info.url().SchemeIs(extensions::kExtensionScheme))
- return GetByID(info.url().host());
+const Extension* ExtensionSet::GetExtensionOrAppByURL(const GURL& url) const {
+ if (url.SchemeIs(extensions::kExtensionScheme))
+ return GetByID(url.host());
- return GetHostedAppByURL(info);
+ return GetHostedAppByURL(url);
}
-const Extension* ExtensionSet::GetHostedAppByURL(
- const ExtensionURLInfo& info) const {
+const Extension* ExtensionSet::GetHostedAppByURL(const GURL& url) const {
for (ExtensionMap::const_iterator iter = extensions_.begin();
iter != extensions_.end(); ++iter) {
- if (iter->second->web_extent().MatchesURL(info.url()))
+ if (iter->second->web_extent().MatchesURL(url))
return iter->second.get();
}
@@ -129,8 +105,8 @@ const Extension* ExtensionSet::GetHostedAppByOverlappingWebExtent(
bool ExtensionSet::InSameExtent(const GURL& old_url,
const GURL& new_url) const {
- return GetExtensionOrAppByURL(ExtensionURLInfo(old_url)) ==
- GetExtensionOrAppByURL(ExtensionURLInfo(new_url));
+ return GetExtensionOrAppByURL(old_url) ==
+ GetExtensionOrAppByURL(new_url);
}
const Extension* ExtensionSet::GetByID(const std::string& id) const {
@@ -150,31 +126,16 @@ std::set<std::string> ExtensionSet::GetIDs() const {
return ids;
}
-bool ExtensionSet::ExtensionBindingsAllowed(
- const ExtensionURLInfo& info) const {
- if (info.origin().isUnique() || IsSandboxedPage(info))
- return false;
-
- if (info.url().SchemeIs(extensions::kExtensionScheme))
+bool ExtensionSet::ExtensionBindingsAllowed(const GURL& url) const {
+ if (url.SchemeIs(extensions::kExtensionScheme))
return true;
ExtensionMap::const_iterator i = extensions_.begin();
for (; i != extensions_.end(); ++i) {
if (i->second->location() == extensions::Manifest::COMPONENT &&
- i->second->web_extent().MatchesURL(info.url()))
+ i->second->web_extent().MatchesURL(url))
return true;
}
return false;
}
-
-bool ExtensionSet::IsSandboxedPage(const ExtensionURLInfo& info) const {
- if (info.url().SchemeIs(extensions::kExtensionScheme)) {
- const Extension* extension = GetByID(info.url().host());
- if (extension) {
- return extensions::SandboxedPageInfo::IsSandboxedPage(extension,
- info.url().path());
- }
- }
- return false;
-}
« 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