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

Side by Side Diff: extensions/common/extension_api.h

Issue 2266673002: [Extensions] Remove mechanism for non-generated schemas (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lazyboys Created 4 years, 4 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 unified diff | Download patch
OLDNEW
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 10 matching lines...) Expand all
21 namespace base { 21 namespace base {
22 class DictionaryValue; 22 class DictionaryValue;
23 class Value; 23 class Value;
24 } 24 }
25 25
26 class GURL; 26 class GURL;
27 27
28 namespace extensions { 28 namespace extensions {
29 29
30 class Extension; 30 class Extension;
31 class ExtensionsClient;
31 class Feature; 32 class Feature;
32 33
33 // C++ Wrapper for the JSON API definitions in chrome/common/extensions/api/. 34 // C++ Wrapper for the JSON API definitions in chrome/common/extensions/api/.
34 // 35 //
35 // WARNING: This class is accessed on multiple threads in the browser process 36 // WARNING: This class is accessed on multiple threads in the browser process
36 // (see ExtensionFunctionDispatcher). No state should be modified after 37 // (see ExtensionFunctionDispatcher). No state should be modified after
37 // construction. 38 // construction.
38 class ExtensionAPI { 39 class ExtensionAPI {
39 public: 40 public:
40 // Returns a single shared instance of this class. This is the typical use 41 // Returns a single shared instance of this class. This is the typical use
(...skipping 17 matching lines...) Expand all
58 59
59 class OverrideSharedInstanceForTest { 60 class OverrideSharedInstanceForTest {
60 public: 61 public:
61 explicit OverrideSharedInstanceForTest(ExtensionAPI* testing_api); 62 explicit OverrideSharedInstanceForTest(ExtensionAPI* testing_api);
62 ~OverrideSharedInstanceForTest(); 63 ~OverrideSharedInstanceForTest();
63 64
64 private: 65 private:
65 ExtensionAPI* original_api_; 66 ExtensionAPI* original_api_;
66 }; 67 };
67 68
68 // Creates a completely clean instance. Configure using RegisterSchema() and 69 // Creates a completely clean instance. Configure using
69 // RegisterDependencyProvider before use. 70 // RegisterDependencyProvider before use.
70 ExtensionAPI(); 71 ExtensionAPI();
71 virtual ~ExtensionAPI(); 72 virtual ~ExtensionAPI();
72 73
73 // Add a (non-generated) API schema resource.
74 void RegisterSchemaResource(const std::string& api_name, int resource_id);
75
76 // Add a FeatureProvider for APIs. The features are used to specify 74 // Add a FeatureProvider for APIs. The features are used to specify
77 // dependencies and constraints on the availability of APIs. 75 // dependencies and constraints on the availability of APIs.
78 void RegisterDependencyProvider(const std::string& name, 76 void RegisterDependencyProvider(const std::string& name,
79 const FeatureProvider* provider); 77 const FeatureProvider* provider);
80 78
81 // Returns true if the API item called |api_full_name| and all of its 79 // Returns true if the API item called |api_full_name| and all of its
82 // dependencies are available in |context|. 80 // dependencies are available in |context|.
83 // 81 //
84 // |api_full_name| can be either a namespace name (like "bookmarks") or a 82 // |api_full_name| can be either a namespace name (like "bookmarks") or a
85 // member name (like "bookmarks.create"). 83 // member name (like "bookmarks.create").
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // Returns NULL if the feature could not be found. 124 // Returns NULL if the feature could not be found.
127 Feature* GetFeatureDependency(const std::string& dependency_name); 125 Feature* GetFeatureDependency(const std::string& dependency_name);
128 126
129 private: 127 private:
130 FRIEND_TEST_ALL_PREFIXES(ExtensionAPITest, DefaultConfigurationFeatures); 128 FRIEND_TEST_ALL_PREFIXES(ExtensionAPITest, DefaultConfigurationFeatures);
131 FRIEND_TEST_ALL_PREFIXES(ExtensionAPITest, TypesHaveNamespace); 129 FRIEND_TEST_ALL_PREFIXES(ExtensionAPITest, TypesHaveNamespace);
132 friend struct base::DefaultSingletonTraits<ExtensionAPI>; 130 friend struct base::DefaultSingletonTraits<ExtensionAPI>;
133 131
134 void InitDefaultConfiguration(); 132 void InitDefaultConfiguration();
135 133
134 // Returns true if there exists an API with |name|. Declared virtual for
135 // testing purposes.
136 virtual bool IsKnownAPI(const std::string& name, ExtensionsClient* client);
137
136 bool default_configuration_initialized_; 138 bool default_configuration_initialized_;
137 139
138 // Loads a schema. 140 // Loads a schema.
139 void LoadSchema(const std::string& name, const base::StringPiece& schema); 141 void LoadSchema(const std::string& name, const base::StringPiece& schema);
140 142
141 // Map from each API that hasn't been loaded yet to the schema which defines
142 // it. Note that there may be multiple APIs per schema.
143 typedef std::map<std::string, int> UnloadedSchemaMap;
144 UnloadedSchemaMap unloaded_schemas_;
145
146 // Schemas for each namespace. 143 // Schemas for each namespace.
147 using SchemaMap = 144 using SchemaMap =
148 std::map<std::string, std::unique_ptr<const base::DictionaryValue>>; 145 std::map<std::string, std::unique_ptr<const base::DictionaryValue>>;
149 SchemaMap schemas_; 146 SchemaMap schemas_;
150 147
151 // FeatureProviders used for resolving dependencies. 148 // FeatureProviders used for resolving dependencies.
152 typedef std::map<std::string, const FeatureProvider*> FeatureProviderMap; 149 typedef std::map<std::string, const FeatureProvider*> FeatureProviderMap;
153 FeatureProviderMap dependency_providers_; 150 FeatureProviderMap dependency_providers_;
154 151
155 DISALLOW_COPY_AND_ASSIGN(ExtensionAPI); 152 DISALLOW_COPY_AND_ASSIGN(ExtensionAPI);
156 }; 153 };
157 154
158 } // namespace extensions 155 } // namespace extensions
159 156
160 #endif // EXTENSIONS_COMMON_EXTENSION_API_H_ 157 #endif // EXTENSIONS_COMMON_EXTENSION_API_H_
OLDNEW
« no previous file with comments | « chrome/common/extensions/chrome_extensions_client.cc ('k') | extensions/common/extension_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698