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

Unified Diff: extensions/common/extension_api.cc

Issue 377753003: Remove GetContexts() from the public interface of extensions::Feature. It was (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 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 | « extensions/common/extension_api.h ('k') | extensions/common/extension_api_stub.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/extension_api.cc
diff --git a/extensions/common/extension_api.cc b/extensions/common/extension_api.cc
index 95fd3fb8822ab0f4e3cb991b778edb2e625e81c3..6f67887cde87993c6d7d351b9f4b49d25483dea0 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(
« no previous file with comments | « extensions/common/extension_api.h ('k') | extensions/common/extension_api_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698