| 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_EXTENSIONS_CLIENT_H_ | 5 #ifndef EXTENSIONS_COMMON_EXTENSIONS_CLIENT_H_ |
| 6 #define EXTENSIONS_COMMON_EXTENSIONS_CLIENT_H_ | 6 #define EXTENSIONS_COMMON_EXTENSIONS_CLIENT_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
| 14 | 14 |
| 15 class GURL; | 15 class GURL; |
| 16 | 16 |
| 17 namespace extensions { | 17 namespace extensions { |
| 18 | 18 |
| 19 class APIPermissionSet; | 19 class APIPermissionSet; |
| 20 class Extension; | 20 class Extension; |
| 21 class FeatureProvider; | 21 class FeatureProvider; |
| 22 class JSONFeatureProviderSource; |
| 22 class ManifestPermissionSet; | 23 class ManifestPermissionSet; |
| 23 class PermissionMessage; | 24 class PermissionMessage; |
| 24 class PermissionMessageProvider; | 25 class PermissionMessageProvider; |
| 25 class SimpleFeature; | 26 class SimpleFeature; |
| 26 class URLPatternSet; | 27 class URLPatternSet; |
| 27 | 28 |
| 28 // Sets up global state for the extensions system. Should be Set() once in each | 29 // Sets up global state for the extensions system. Should be Set() once in each |
| 29 // process. This should be implemented by the client of the extensions system. | 30 // process. This should be implemented by the client of the extensions system. |
| 30 class ExtensionsClient { | 31 class ExtensionsClient { |
| 31 public: | 32 public: |
| 32 typedef std::vector<std::string> ScriptingWhitelist; | 33 typedef std::vector<std::string> ScriptingWhitelist; |
| 33 | 34 |
| 34 virtual ~ExtensionsClient() {} | 35 virtual ~ExtensionsClient() {} |
| 35 | 36 |
| 36 // Initializes global state. Not done in the constructor because unit tests | 37 // Initializes global state. Not done in the constructor because unit tests |
| 37 // can create additional ExtensionsClients because the utility thread runs | 38 // can create additional ExtensionsClients because the utility thread runs |
| 38 // in-process. | 39 // in-process. |
| 39 virtual void Initialize() = 0; | 40 virtual void Initialize() = 0; |
| 40 | 41 |
| 41 // Returns the global PermissionMessageProvider to use to provide permission | 42 // Returns the global PermissionMessageProvider to use to provide permission |
| 42 // warning strings. | 43 // warning strings. |
| 43 virtual const PermissionMessageProvider& GetPermissionMessageProvider() | 44 virtual const PermissionMessageProvider& GetPermissionMessageProvider() |
| 44 const = 0; | 45 const = 0; |
| 45 | 46 |
| 46 // Create a FeatureProvider for a specific feature type, e.g. "permission". | 47 // Create a FeatureProvider for a specific feature type, e.g. "permission". |
| 47 virtual scoped_ptr<FeatureProvider> CreateFeatureProvider( | 48 virtual scoped_ptr<FeatureProvider> CreateFeatureProvider( |
| 48 const std::string& name) const = 0; | 49 const std::string& name) const = 0; |
| 49 | 50 |
| 51 // Create a JSONFeatureProviderSource for a specific feature type, |
| 52 // e.g. "permission". Currently, all features are loaded from |
| 53 // JSONFeatureProviderSources. |
| 54 // This is used primarily in CreateFeatureProvider, above. |
| 55 virtual scoped_ptr<JSONFeatureProviderSource> CreateFeatureProviderSource( |
| 56 const std::string& name) const = 0; |
| 57 |
| 50 // Takes the list of all hosts and filters out those with special | 58 // Takes the list of all hosts and filters out those with special |
| 51 // permission strings. Adds the regular hosts to |new_hosts|, | 59 // permission strings. Adds the regular hosts to |new_hosts|, |
| 52 // and adds the special permission messages to |messages|. | 60 // and adds the special permission messages to |messages|. |
| 53 virtual void FilterHostPermissions( | 61 virtual void FilterHostPermissions( |
| 54 const URLPatternSet& hosts, | 62 const URLPatternSet& hosts, |
| 55 URLPatternSet* new_hosts, | 63 URLPatternSet* new_hosts, |
| 56 std::set<PermissionMessage>* messages) const = 0; | 64 std::set<PermissionMessage>* messages) const = 0; |
| 57 | 65 |
| 58 // Replaces the scripting whitelist with |whitelist|. Used in the renderer; | 66 // Replaces the scripting whitelist with |whitelist|. Used in the renderer; |
| 59 // only used for testing in the browser process. | 67 // only used for testing in the browser process. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 84 // Return the extensions client. | 92 // Return the extensions client. |
| 85 static ExtensionsClient* Get(); | 93 static ExtensionsClient* Get(); |
| 86 | 94 |
| 87 // Initialize the extensions system with this extensions client. | 95 // Initialize the extensions system with this extensions client. |
| 88 static void Set(ExtensionsClient* client); | 96 static void Set(ExtensionsClient* client); |
| 89 }; | 97 }; |
| 90 | 98 |
| 91 } // namespace extensions | 99 } // namespace extensions |
| 92 | 100 |
| 93 #endif // EXTENSIONS_COMMON_EXTENSIONS_CLIENT_H_ | 101 #endif // EXTENSIONS_COMMON_EXTENSIONS_CLIENT_H_ |
| OLD | NEW |