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

Unified Diff: extensions/common/extension_api.h

Issue 2494653005: Support API aliases (Closed)
Patch Set: . Created 4 years, 1 month 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/browser/extension_function.cc ('k') | extensions/common/extension_api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/extension_api.h
diff --git a/extensions/common/extension_api.h b/extensions/common/extension_api.h
index 1453340a50e57fce64ba9fd3f5687a500f29feaa..9b46781acf2223b2fa15f5165ce51ed6e9bfec17 100644
--- a/extensions/common/extension_api.h
+++ b/extensions/common/extension_api.h
@@ -31,6 +31,16 @@ class Extension;
class ExtensionsClient;
class Feature;
+// Used when testing Feature availability to specify whether feature aliases
+// should be ignored or not - i.e. if a feature exposed only through an alias
+// should be considered available.
+enum class CheckAliasStatus {
+ // Includes aliases in an availability check.
+ ALLOWED,
+ // Ignores aliases during an availability check.
+ NOT_ALLOWED
+};
+
// C++ Wrapper for the JSON API definitions in chrome/common/extensions/api/.
//
// WARNING: This class is accessed on multiple threads in the browser process
@@ -86,20 +96,29 @@ class ExtensionAPI {
// |extension| or |url| (or both) may determine its availability, but this is
// up to the configuration of the individual feature.
//
+ // |check_alias| determines whether it should be tested whether the API
+ // is available through an alias.
+ //
// TODO(kalman): This is just an unnecessary combination of finding a Feature
// then calling Feature::IsAvailableToContext(..) on it. Just provide that
// FindFeature function and let callers compose if they want.
Feature::Availability IsAvailable(const std::string& api_full_name,
const Extension* extension,
Feature::Context context,
- const GURL& url);
+ const GURL& url,
+ CheckAliasStatus check_alias);
- // Determines whether an API, or any parts of that API, are available in
+ // Determines whether an API, or any parts of that API, can be exposed to
// |context|.
+ //
+ // |check_alias| determines whether it should be tested whether the API
+ // is available through an alias.
+ //
bool IsAnyFeatureAvailableToContext(const Feature& api,
const Extension* extension,
Feature::Context context,
- const GURL& url);
+ const GURL& url,
+ CheckAliasStatus check_alias);
// Gets the StringPiece for the schema specified by |api_name|.
base::StringPiece GetSchemaStringPiece(const std::string& api_name);
@@ -136,6 +155,14 @@ class ExtensionAPI {
// testing purposes.
virtual bool IsKnownAPI(const std::string& name, ExtensionsClient* client);
+ // Checks if |full_name| is available to provided context and extension under
+ // associated API's alias name.
+ Feature::Availability IsAliasAvailable(const std::string& full_name,
+ Feature* feature,
+ const Extension* extension,
+ Feature::Context context,
+ const GURL& url);
+
bool default_configuration_initialized_;
// Loads a schema.
« no previous file with comments | « extensions/browser/extension_function.cc ('k') | extensions/common/extension_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698