diff options
author | kalman@chromium.org <kalman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-10 21:46:53 +0000 |
---|---|---|
committer | kalman@chromium.org <kalman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-10 21:46:53 +0000 |
commit | 2501ca5dbd5f1a495b306937c7fed7c32698c943 (patch) | |
tree | 97b9f454ca4fa3d41d627db0f3a34b97d4d31583 /extensions/common/extension_api.cc | |
parent | f72e58b294148fd1ec7d281dd06d1a16d49d4a55 (diff) | |
download | chromium_src-2501ca5dbd5f1a495b306937c7fed7c32698c943.zip chromium_src-2501ca5dbd5f1a495b306937c7fed7c32698c943.tar.gz chromium_src-2501ca5dbd5f1a495b306937c7fed7c32698c943.tar.bz2 |
Remove GetContexts() from the public interface of extensions::Feature. It was
being misused in such a way that makes it impossible to add other trusted
extension context types. It's also a nice cleanup, though requires rewriting
the ExtensionAPI::IsPrivileged function with sightly different semantics.
BUG=391944
R=rockot@chromium.org
Review URL: https://codereview.chromium.org/377753003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282437 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions/common/extension_api.cc')
-rw-r--r-- | extensions/common/extension_api.cc | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/extensions/common/extension_api.cc b/extensions/common/extension_api.cc index 95fd3fb..6f67887 100644 --- a/extensions/common/extension_api.cc +++ b/extensions/common/extension_api.cc @@ -262,6 +262,7 @@ bool ExtensionAPI::IsAnyFeatureAvailableToContext(const Feature& api, const GURL& url) { FeatureProviderMap::iterator provider = dependency_providers_.find("api"); CHECK(provider != dependency_providers_.end()); + if (api.IsAvailableToContext(extension, context, url).is_available()) return true; @@ -289,13 +290,17 @@ Feature::Availability ExtensionAPI::IsAvailable(const std::string& full_name, return feature->IsAvailableToContext(extension, context, url); } -bool ExtensionAPI::IsPrivileged(const std::string& full_name) { - Feature* feature = GetFeatureDependency(full_name); - CHECK(feature) << full_name; - DCHECK(!feature->GetContexts()->empty()) << full_name; - // An API is 'privileged' if it can only be run in a blessed context. - return feature->GetContexts()->size() == - feature->GetContexts()->count(Feature::BLESSED_EXTENSION_CONTEXT); +bool ExtensionAPI::IsAvailableInUntrustedContext(const std::string& name, + const Extension* extension) { + return IsAvailable(name, extension, Feature::CONTENT_SCRIPT_CONTEXT, GURL()) + .is_available() || + IsAvailable( + name, extension, Feature::UNBLESSED_EXTENSION_CONTEXT, GURL()) + .is_available() || + IsAvailable(name, extension, Feature::BLESSED_WEB_PAGE_CONTEXT, GURL()) + .is_available() || + IsAvailable(name, extension, Feature::WEB_PAGE_CONTEXT, GURL()) + .is_available(); } const base::DictionaryValue* ExtensionAPI::GetSchema( |