summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net/chrome_url_request_context.cc
diff options
context:
space:
mode:
authorrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-31 01:09:42 +0000
committerrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-31 01:09:42 +0000
commit57a777f7584961290e87e6e4149c0ed042334425 (patch)
tree94ccff83d4ac08208da52890d4e4ae8e33a0f946 /chrome/browser/net/chrome_url_request_context.cc
parent151793fa77c13c94709ab5525a8f3fd9a5301450 (diff)
downloadchromium_src-57a777f7584961290e87e6e4149c0ed042334425.zip
chromium_src-57a777f7584961290e87e6e4149c0ed042334425.tar.gz
chromium_src-57a777f7584961290e87e6e4149c0ed042334425.tar.bz2
Hook up extension apps notification permission, take two
This is the chromium side of a change which will wait to land on the webkit side landing. (https://bugs.webkit.org/show_bug.cgi?id=36625) It changes the NotificationPresenter to pass the sourceURL, rather than the SecurityOrigin in checking permission. The full URL is required to match the app extent. BUG=32361, 31024 TEST=NONE Review URL: http://codereview.chromium.org/1383001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43162 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net/chrome_url_request_context.cc')
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc40
1 files changed, 18 insertions, 22 deletions
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index be1e63b..101e0c2 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -748,32 +748,28 @@ std::string ChromeURLRequestContext::GetDefaultLocaleForExtension(
bool ChromeURLRequestContext::CheckURLAccessToExtensionPermission(
const GURL& url,
- const std::string& application_id,
const char* permission_name) {
- DCHECK(!application_id.empty());
+ ExtensionInfoMap::iterator info;
+ if (url.SchemeIs(chrome::kExtensionScheme)) {
+ // If the url is an extension scheme, we just look it up by extension id.
+ std::string id = url.host();
+ info = extension_info_.find(id);
+ } else {
+ // Otherwise, we scan for a matching extent. Overlapping extents are
+ // disallowed, so only one will match.
+ info = extension_info_.begin();
+ while (info != extension_info_.end() &&
+ !info->second->extent.ContainsURL(url))
+ ++info;
+ }
- // Get the information about the specified extension. If the extension isn't
- // installed, then permission is not granted.
- ExtensionInfoMap::iterator info = extension_info_.find(application_id);
if (info == extension_info_.end())
return false;
- // Check that the extension declares the required permission.
- std::vector<std::string>& permissions = info->second->api_permissions;
- if (permissions.end() == std::find(permissions.begin(), permissions.end(),
- permission_name)) {
- return false;
- }
-
- // Check that the extension declares the source URL in its extent.
- Extension::URLPatternList& extent = info->second->extent;
- for (Extension::URLPatternList::iterator pattern = extent.begin();
- pattern != extent.end(); ++pattern) {
- if (pattern->MatchesUrl(url))
- return true;
- }
-
- return false;
+ std::vector<std::string>& api_permissions = info->second->api_permissions;
+ return std::find(api_permissions.begin(),
+ api_permissions.end(),
+ permission_name) != api_permissions.end();
}
const std::string& ChromeURLRequestContext::GetUserAgent(
@@ -945,7 +941,7 @@ ChromeURLRequestContextFactory::ChromeURLRequestContextFactory(Profile* profile)
new ChromeURLRequestContext::ExtensionInfo(
(*iter)->path(),
(*iter)->default_locale(),
- std::vector<URLPattern>(),
+ (*iter)->web_extent(),
(*iter)->api_permissions()));
}
}