Chromium Code Reviews| 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 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
| 16 #include "base/string_piece.h" | 16 #include "base/string_piece.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "chrome/common/extensions/features/feature.h" | 18 #include "chrome/common/extensions/features/feature.h" |
| 19 #include "chrome/common/extensions/features/feature_provider.h" | 19 #include "chrome/common/extensions/features/feature_provider.h" |
| 20 #include "chrome/common/extensions/features/simple_feature.h" | |
| 20 #include "extensions/common/url_pattern_set.h" | 21 #include "extensions/common/url_pattern_set.h" |
| 21 | 22 |
| 22 namespace base { | 23 namespace base { |
| 23 class DictionaryValue; | 24 class DictionaryValue; |
| 24 class ListValue; | 25 class ListValue; |
| 25 class Value; | 26 class Value; |
| 26 } | 27 } |
| 27 | 28 |
| 28 class GURL; | 29 class GURL; |
| 29 | 30 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 | 88 |
| 88 // Gets the APIs available to |context| given an |extension| and |url|. The | 89 // Gets the APIs available to |context| given an |extension| and |url|. The |
| 89 // extension or URL may not be relevant to all contexts, and may be left | 90 // extension or URL may not be relevant to all contexts, and may be left |
| 90 // NULL/empty. | 91 // NULL/empty. |
| 91 scoped_ptr<std::set<std::string> > GetAPIsForContext( | 92 scoped_ptr<std::set<std::string> > GetAPIsForContext( |
| 92 Feature::Context context, const Extension* extension, const GURL& url); | 93 Feature::Context context, const Extension* extension, const GURL& url); |
| 93 | 94 |
| 94 // Gets a Feature object describing the API with the specified |full_name|. | 95 // Gets a Feature object describing the API with the specified |full_name|. |
| 95 // This can be either an API namespace (like history, or | 96 // This can be either an API namespace (like history, or |
| 96 // experimental.bookmarks), or it can be an individual function or event. | 97 // experimental.bookmarks), or it can be an individual function or event. |
| 97 virtual Feature* GetFeature(const std::string& full_name) OVERRIDE; | 98 virtual SimpleFeature* GetFeature(const std::string& full_name) OVERRIDE; |
|
not at google - send to devlin
2012/12/12 17:42:41
should return a Feature?
justinlin
2012/12/14 12:26:26
Done.
| |
| 98 | 99 |
| 99 // Splits a full name from the extension API into its API and child name | 100 // Splits a full name from the extension API into its API and child name |
| 100 // parts. Some examples: | 101 // parts. Some examples: |
| 101 // | 102 // |
| 102 // "bookmarks.create" -> ("bookmarks", "create") | 103 // "bookmarks.create" -> ("bookmarks", "create") |
| 103 // "experimental.input.ui.cursorUp" -> ("experimental.input.ui", "cursorUp") | 104 // "experimental.input.ui.cursorUp" -> ("experimental.input.ui", "cursorUp") |
| 104 // "storage.sync.set" -> ("storage", "sync.get") | 105 // "storage.sync.set" -> ("storage", "sync.get") |
| 105 // "<unknown-api>.monkey" -> ("", "") | 106 // "<unknown-api>.monkey" -> ("", "") |
| 106 // | 107 // |
| 107 // The |child_name| parameter can be be NULL if you don't need that part. | 108 // The |child_name| parameter can be be NULL if you don't need that part. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 | 167 |
| 167 // APIs that are entirely unprivileged. | 168 // APIs that are entirely unprivileged. |
| 168 std::set<std::string> completely_unprivileged_apis_; | 169 std::set<std::string> completely_unprivileged_apis_; |
| 169 | 170 |
| 170 // APIs that are not entirely unprivileged, but have unprivileged components. | 171 // APIs that are not entirely unprivileged, but have unprivileged components. |
| 171 std::set<std::string> partially_unprivileged_apis_; | 172 std::set<std::string> partially_unprivileged_apis_; |
| 172 | 173 |
| 173 // APIs that have URL matching permissions. | 174 // APIs that have URL matching permissions. |
| 174 std::map<std::string, URLPatternSet> url_matching_apis_; | 175 std::map<std::string, URLPatternSet> url_matching_apis_; |
| 175 | 176 |
| 176 typedef std::map<std::string, linked_ptr<Feature> > FeatureMap; | 177 typedef std::map<std::string, linked_ptr<SimpleFeature> > FeatureMap; |
|
not at google - send to devlin
2012/12/12 17:42:41
Feature?
justinlin
2012/12/14 12:26:26
Done.
| |
| 177 typedef std::map<std::string, linked_ptr<FeatureMap> > APIFeatureMap; | 178 typedef std::map<std::string, linked_ptr<FeatureMap> > APIFeatureMap; |
| 178 APIFeatureMap features_; | 179 APIFeatureMap features_; |
| 179 | 180 |
| 180 // FeatureProviders used for resolving dependencies. | 181 // FeatureProviders used for resolving dependencies. |
| 181 typedef std::map<std::string, FeatureProvider*> FeatureProviderMap; | 182 typedef std::map<std::string, FeatureProvider*> FeatureProviderMap; |
| 182 FeatureProviderMap dependency_providers_; | 183 FeatureProviderMap dependency_providers_; |
| 183 | 184 |
| 184 DISALLOW_COPY_AND_ASSIGN(ExtensionAPI); | 185 DISALLOW_COPY_AND_ASSIGN(ExtensionAPI); |
| 185 }; | 186 }; |
| 186 | 187 |
| 187 } // extensions | 188 } // extensions |
| 188 | 189 |
| 189 #endif // CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_ | 190 #endif // CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_ |
| OLD | NEW |