| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_ |
| 6 #define CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_ | 6 #define CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 class ListValue; | 25 class ListValue; |
| 26 class Value; | 26 class Value; |
| 27 } | 27 } |
| 28 | 28 |
| 29 class GURL; | 29 class GURL; |
| 30 class Extension; | 30 class Extension; |
| 31 class ExtensionPermissionSet; | 31 class ExtensionPermissionSet; |
| 32 | 32 |
| 33 namespace extensions { | 33 namespace extensions { |
| 34 | 34 |
| 35 class ExtensionAPIFeature; |
| 35 class Feature; | 36 class Feature; |
| 36 | 37 |
| 37 // C++ Wrapper for the JSON API definitions in chrome/common/extensions/api/. | 38 // C++ Wrapper for the JSON API definitions in chrome/common/extensions/api/. |
| 38 // | 39 // |
| 39 // WARNING: This class is accessed on multiple threads in the browser process | 40 // WARNING: This class is accessed on multiple threads in the browser process |
| 40 // (see ExtensionFunctionDispatcher). No state should be modified after | 41 // (see ExtensionFunctionDispatcher). No state should be modified after |
| 41 // construction. | 42 // construction. |
| 42 class ExtensionAPI : public FeatureProvider { | 43 class ExtensionAPI : public FeatureProvider { |
| 43 public: | 44 public: |
| 44 // Returns a single shared instance of this class. This is the typical use | 45 // Returns a single shared instance of this class. This is the typical use |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 // Removes all APIs from |apis| which are *entirely* privileged. This won't | 152 // Removes all APIs from |apis| which are *entirely* privileged. This won't |
| 152 // include APIs such as "storage" which is entirely unprivileged, nor | 153 // include APIs such as "storage" which is entirely unprivileged, nor |
| 153 // "extension" which has unprivileged components. | 154 // "extension" which has unprivileged components. |
| 154 void RemovePrivilegedAPIs(std::set<std::string>* apis); | 155 void RemovePrivilegedAPIs(std::set<std::string>* apis); |
| 155 | 156 |
| 156 // Adds an APIs that match |url| to |out|. | 157 // Adds an APIs that match |url| to |out|. |
| 157 // NOTE: This only works for non-feature-controlled APIs. | 158 // NOTE: This only works for non-feature-controlled APIs. |
| 158 // TODO(aa): Remove this when all APIs are converted to the feature system. | 159 // TODO(aa): Remove this when all APIs are converted to the feature system. |
| 159 void GetAPIsMatchingURL(const GURL& url, std::set<std::string>* out); | 160 void GetAPIsMatchingURL(const GURL& url, std::set<std::string>* out); |
| 160 | 161 |
| 162 // Returns true if a namespace has been converted to the feature system, or |
| 163 // false otherwise. |
| 164 bool IsControlledByFeatureSystem(const std::string& api_name) const; |
| 165 |
| 161 // Map from each API that hasn't been loaded yet to the schema which defines | 166 // Map from each API that hasn't been loaded yet to the schema which defines |
| 162 // it. Note that there may be multiple APIs per schema. | 167 // it. Note that there may be multiple APIs per schema. |
| 163 std::map<std::string, base::StringPiece> unloaded_schemas_; | 168 std::map<std::string, base::StringPiece> unloaded_schemas_; |
| 164 | 169 |
| 165 // Schemas for each namespace. | 170 // Schemas for each namespace. |
| 166 typedef std::map<std::string, linked_ptr<const DictionaryValue> > SchemaMap; | 171 typedef std::map<std::string, linked_ptr<const DictionaryValue> > SchemaMap; |
| 167 SchemaMap schemas_; | 172 SchemaMap schemas_; |
| 168 | 173 |
| 169 // APIs that are entirely unprivileged. | 174 // APIs that are entirely unprivileged. |
| 170 std::set<std::string> completely_unprivileged_apis_; | 175 std::set<std::string> completely_unprivileged_apis_; |
| 171 | 176 |
| 172 // APIs that are not entirely unprivileged, but have unprivileged components. | 177 // APIs that are not entirely unprivileged, but have unprivileged components. |
| 173 std::set<std::string> partially_unprivileged_apis_; | 178 std::set<std::string> partially_unprivileged_apis_; |
| 174 | 179 |
| 175 // APIs that have URL matching permissions. | 180 // APIs that have URL matching permissions. |
| 176 std::map<std::string, URLPatternSet> url_matching_apis_; | 181 std::map<std::string, URLPatternSet> url_matching_apis_; |
| 177 | 182 |
| 178 typedef std::map<std::string, linked_ptr<Feature> > FeatureMap; | 183 typedef std::map<std::string, linked_ptr<ExtensionAPIFeature> > FeatureMap; |
| 179 typedef std::map<std::string, linked_ptr<FeatureMap> > APIFeatureMap; | 184 FeatureMap features_; |
| 180 APIFeatureMap features_; | |
| 181 | 185 |
| 182 // FeatureProviders used for resolving dependencies. | 186 // FeatureProviders used for resolving dependencies. |
| 183 typedef std::map<std::string, FeatureProvider*> FeatureProviderMap; | 187 typedef std::map<std::string, FeatureProvider*> FeatureProviderMap; |
| 184 FeatureProviderMap dependency_providers_; | 188 FeatureProviderMap dependency_providers_; |
| 185 | 189 |
| 186 DISALLOW_COPY_AND_ASSIGN(ExtensionAPI); | 190 DISALLOW_COPY_AND_ASSIGN(ExtensionAPI); |
| 187 }; | 191 }; |
| 188 | 192 |
| 189 } // extensions | 193 } // extensions |
| 190 | 194 |
| 191 #endif // CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_ | 195 #endif // CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_ |
| OLD | NEW |