| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef EXTENSIONS_COMMON_EXTENSION_API_H_ | 5 #ifndef EXTENSIONS_COMMON_EXTENSION_API_H_ |
| 6 #define EXTENSIONS_COMMON_EXTENSION_API_H_ | 6 #define EXTENSIONS_COMMON_EXTENSION_API_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // Determines whether an API, or any parts of that API, are available in | 97 // Determines whether an API, or any parts of that API, are available in |
| 98 // |context|. | 98 // |context|. |
| 99 bool IsAnyFeatureAvailableToContext(const Feature& api, | 99 bool IsAnyFeatureAvailableToContext(const Feature& api, |
| 100 const Extension* extension, | 100 const Extension* extension, |
| 101 Feature::Context context, | 101 Feature::Context context, |
| 102 const GURL& url); | 102 const GURL& url); |
| 103 | 103 |
| 104 // Returns true if |name| is available to WebUI contexts on |url|. | 104 // Returns true if |name| is available to WebUI contexts on |url|. |
| 105 bool IsAvailableToWebUI(const std::string& name, const GURL& url); | 105 bool IsAvailableToWebUI(const std::string& name, const GURL& url); |
| 106 | 106 |
| 107 // Gets the StringPiece for the schema specified by |api_name|. |
| 108 base::StringPiece GetSchemaStringPiece(const std::string& api_name); |
| 109 |
| 107 // Gets the schema for the extension API with namespace |full_name|. | 110 // Gets the schema for the extension API with namespace |full_name|. |
| 108 // Ownership remains with this object. | 111 // Ownership remains with this object. |
| 112 // TODO(devlin): Now that we use GetSchemaStringPiece() in the renderer, we |
| 113 // may not really need this anymore. |
| 109 const base::DictionaryValue* GetSchema(const std::string& full_name); | 114 const base::DictionaryValue* GetSchema(const std::string& full_name); |
| 110 | 115 |
| 111 // Splits a full name from the extension API into its API and child name | 116 // Splits a full name from the extension API into its API and child name |
| 112 // parts. Some examples: | 117 // parts. Some examples: |
| 113 // | 118 // |
| 114 // "bookmarks.create" -> ("bookmarks", "create") | 119 // "bookmarks.create" -> ("bookmarks", "create") |
| 115 // "experimental.input.ui.cursorUp" -> ("experimental.input.ui", "cursorUp") | 120 // "experimental.input.ui.cursorUp" -> ("experimental.input.ui", "cursorUp") |
| 116 // "storage.sync.set" -> ("storage", "sync.get") | 121 // "storage.sync.set" -> ("storage", "sync.get") |
| 117 // "<unknown-api>.monkey" -> ("", "") | 122 // "<unknown-api>.monkey" -> ("", "") |
| 118 // | 123 // |
| (...skipping 18 matching lines...) Expand all Loading... |
| 137 bool default_configuration_initialized_; | 142 bool default_configuration_initialized_; |
| 138 | 143 |
| 139 // Loads a schema. | 144 // Loads a schema. |
| 140 void LoadSchema(const std::string& name, const base::StringPiece& schema); | 145 void LoadSchema(const std::string& name, const base::StringPiece& schema); |
| 141 | 146 |
| 142 // Schemas for each namespace. | 147 // Schemas for each namespace. |
| 143 using SchemaMap = | 148 using SchemaMap = |
| 144 std::map<std::string, std::unique_ptr<const base::DictionaryValue>>; | 149 std::map<std::string, std::unique_ptr<const base::DictionaryValue>>; |
| 145 SchemaMap schemas_; | 150 SchemaMap schemas_; |
| 146 | 151 |
| 152 using StringPieceMap = std::map<std::string, base::StringPiece>; |
| 153 StringPieceMap schema_strings_; |
| 154 |
| 147 // FeatureProviders used for resolving dependencies. | 155 // FeatureProviders used for resolving dependencies. |
| 148 typedef std::map<std::string, const FeatureProvider*> FeatureProviderMap; | 156 typedef std::map<std::string, const FeatureProvider*> FeatureProviderMap; |
| 149 FeatureProviderMap dependency_providers_; | 157 FeatureProviderMap dependency_providers_; |
| 150 | 158 |
| 151 DISALLOW_COPY_AND_ASSIGN(ExtensionAPI); | 159 DISALLOW_COPY_AND_ASSIGN(ExtensionAPI); |
| 152 }; | 160 }; |
| 153 | 161 |
| 154 } // namespace extensions | 162 } // namespace extensions |
| 155 | 163 |
| 156 #endif // EXTENSIONS_COMMON_EXTENSION_API_H_ | 164 #endif // EXTENSIONS_COMMON_EXTENSION_API_H_ |
| OLD | NEW |