| 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 29 matching lines...) Expand all Loading... |
| 74 // "bookmarks.create"). Returns true if the feature and all of its | 75 // "bookmarks.create"). Returns true if the feature and all of its |
| 75 // dependencies are available to the specified context. | 76 // dependencies are available to the specified context. |
| 76 bool IsAvailable(const std::string& api_full_name, | 77 bool IsAvailable(const std::string& api_full_name, |
| 77 const Extension* extension, | 78 const Extension* extension, |
| 78 Feature::Context context); | 79 Feature::Context context); |
| 79 | 80 |
| 80 // Returns true if |name| is a privileged API path. Privileged paths can only | 81 // Returns true if |name| is a privileged API path. Privileged paths can only |
| 81 // be called from extension code which is running in its own designated | 82 // be called from extension code which is running in its own designated |
| 82 // extension process. They cannot be called from extension code running in | 83 // extension process. They cannot be called from extension code running in |
| 83 // content scripts, or other low-privileged contexts. | 84 // content scripts, or other low-privileged contexts. |
| 85 // |
| 86 // TODO(aa): Remove this when everything is ported. |
| 84 bool IsPrivileged(const std::string& name); | 87 bool IsPrivileged(const std::string& name); |
| 85 | 88 |
| 86 // Gets the schema for the extension API with namespace |full_name|. | 89 // Gets the schema for the extension API with namespace |full_name|. |
| 87 // Ownership remains with this object. | 90 // Ownership remains with this object. |
| 88 const base::DictionaryValue* GetSchema(const std::string& full_name); | 91 const base::DictionaryValue* GetSchema(const std::string& full_name); |
| 89 | 92 |
| 90 // Gets the APIs available to |context| given an |extension| and |url|. The | 93 // Gets the APIs available to |context| given an |extension| and |url|. The |
| 91 // extension or URL may not be relevant to all contexts, and may be left | 94 // extension or URL may not be relevant to all contexts, and may be left |
| 92 // NULL/empty. | 95 // NULL/empty. |
| 93 scoped_ptr<std::set<std::string> > GetAPIsForContext( | 96 scoped_ptr<std::set<std::string> > GetAPIsForContext( |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 171 |
| 169 // APIs that are entirely unprivileged. | 172 // APIs that are entirely unprivileged. |
| 170 std::set<std::string> completely_unprivileged_apis_; | 173 std::set<std::string> completely_unprivileged_apis_; |
| 171 | 174 |
| 172 // APIs that are not entirely unprivileged, but have unprivileged components. | 175 // APIs that are not entirely unprivileged, but have unprivileged components. |
| 173 std::set<std::string> partially_unprivileged_apis_; | 176 std::set<std::string> partially_unprivileged_apis_; |
| 174 | 177 |
| 175 // APIs that have URL matching permissions. | 178 // APIs that have URL matching permissions. |
| 176 std::map<std::string, URLPatternSet> url_matching_apis_; | 179 std::map<std::string, URLPatternSet> url_matching_apis_; |
| 177 | 180 |
| 178 typedef std::map<std::string, linked_ptr<Feature> > FeatureMap; | 181 typedef std::map<std::string, linked_ptr<ExtensionAPIFeature> > FeatureMap; |
| 179 typedef std::map<std::string, linked_ptr<FeatureMap> > APIFeatureMap; | 182 FeatureMap features_; |
| 180 APIFeatureMap features_; | |
| 181 | 183 |
| 182 // FeatureProviders used for resolving dependencies. | 184 // FeatureProviders used for resolving dependencies. |
| 183 typedef std::map<std::string, FeatureProvider*> FeatureProviderMap; | 185 typedef std::map<std::string, FeatureProvider*> FeatureProviderMap; |
| 184 FeatureProviderMap dependency_providers_; | 186 FeatureProviderMap dependency_providers_; |
| 185 | 187 |
| 186 DISALLOW_COPY_AND_ASSIGN(ExtensionAPI); | 188 DISALLOW_COPY_AND_ASSIGN(ExtensionAPI); |
| 187 }; | 189 }; |
| 188 | 190 |
| 189 } // extensions | 191 } // extensions |
| 190 | 192 |
| 191 #endif // CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_ | 193 #endif // CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_ |
| OLD | NEW |