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

Unified Diff: chrome/common/extensions/api/extension_api.cc

Issue 14494013: Allow API functions and events to have entries in _api_features.json (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bug in searching for unprivileged Created 7 years, 7 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
Index: chrome/common/extensions/api/extension_api.cc
diff --git a/chrome/common/extensions/api/extension_api.cc b/chrome/common/extensions/api/extension_api.cc
index b158aa98ce371f60a63eb977bbbed5d13c81f47e..831bd4aca6d95e206dbc20f7c944b5623763c4ae 100644
--- a/chrome/common/extensions/api/extension_api.cc
+++ b/chrome/common/extensions/api/extension_api.cc
@@ -352,6 +352,26 @@ void ExtensionAPI::RegisterDependencyProvider(const std::string& name,
dependency_providers_[name] = provider;
}
+bool ExtensionAPI::IsAnyFeatureAvailableToContext(const std::string& api_name,
+ Feature::Context context,
+ const GURL& url) {
+ FeatureProviderMap::iterator provider = dependency_providers_.find("api");
+ CHECK(provider != dependency_providers_.end());
+ std::set<std::string> features = provider->second->GetAllFeatureNames();
+
+ // Check to see if there are any parts of this API that are allowed in this
+ // context.
+ for (std::set<std::string>::iterator i = features.begin();
+ i != features.end(); ++i) {
+ const std::string& feature_name = *i;
+ if (feature_name != api_name && feature_name.find(api_name + ".") == 0) {
+ if (IsAvailable(feature_name, NULL, context, url).is_available())
+ return true;
+ }
+ }
+ return IsAvailable(api_name, NULL, context, url).is_available();
+}
+
Feature::Availability ExtensionAPI::IsAvailable(const std::string& full_name,
const Extension* extension,
Feature::Context context,
« no previous file with comments | « chrome/common/extensions/api/extension_api.h ('k') | chrome/common/extensions/api/extension_api_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698