OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_H_ |
7 | 7 |
8 #include "base/containers/scoped_ptr_hash_map.h" | 8 #include "base/containers/scoped_ptr_hash_map.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | |
10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/scoped_vector.h" | |
11 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
12 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
13 #include "base/prefs/pref_change_registrar.h" | 15 #include "base/prefs/pref_change_registrar.h" |
14 #include "base/values.h" | 16 #include "base/values.h" |
15 #include "components/keyed_service/content/browser_context_keyed_service_factory .h" | 17 #include "components/keyed_service/content/browser_context_keyed_service_factory .h" |
16 #include "components/keyed_service/core/keyed_service.h" | 18 #include "components/keyed_service/core/keyed_service.h" |
17 #include "extensions/browser/management_policy.h" | 19 #include "extensions/browser/management_policy.h" |
18 #include "extensions/common/extension.h" | 20 #include "extensions/common/extension.h" |
19 #include "extensions/common/manifest.h" | 21 #include "extensions/common/manifest.h" |
20 | 22 |
21 class GURL; | 23 class GURL; |
22 class PrefService; | 24 class PrefService; |
23 | 25 |
24 namespace content { | 26 namespace content { |
25 class BrowserContext; | 27 class BrowserContext; |
26 } // namespace content | 28 } // namespace content |
27 | 29 |
28 namespace extensions { | 30 namespace extensions { |
29 | 31 |
30 namespace internal { | 32 namespace internal { |
31 | 33 |
32 struct IndividualSettings; | 34 struct IndividualSettings; |
33 struct GlobalSettings; | 35 struct GlobalSettings; |
34 | 36 |
35 } // namespace internal | 37 } // namespace internal |
36 | 38 |
39 class APIPermissionSet; | |
40 class PermissionSet; | |
41 | |
37 // Tracks the management policies that affect extensions and provides interfaces | 42 // Tracks the management policies that affect extensions and provides interfaces |
38 // for observing and obtaining the global settings for all extensions, as well | 43 // for observing and obtaining the global settings for all extensions, as well |
39 // as per-extension settings. | 44 // as per-extension settings. |
40 class ExtensionManagement : public KeyedService { | 45 class ExtensionManagement : public KeyedService { |
41 public: | 46 public: |
42 // Observer class for extension management settings changes. | 47 // Observer class for extension management settings changes. |
43 class Observer { | 48 class Observer { |
44 public: | 49 public: |
45 virtual ~Observer() {} | 50 virtual ~Observer() {} |
46 | 51 |
(...skipping 11 matching lines...) Expand all Loading... | |
58 enum InstallationMode { | 63 enum InstallationMode { |
59 INSTALLATION_ALLOWED = 0, | 64 INSTALLATION_ALLOWED = 0, |
60 INSTALLATION_BLOCKED, | 65 INSTALLATION_BLOCKED, |
61 INSTALLATION_FORCED, | 66 INSTALLATION_FORCED, |
62 INSTALLATION_RECOMMENDED, | 67 INSTALLATION_RECOMMENDED, |
63 }; | 68 }; |
64 | 69 |
65 explicit ExtensionManagement(PrefService* pref_service); | 70 explicit ExtensionManagement(PrefService* pref_service); |
66 ~ExtensionManagement() override; | 71 ~ExtensionManagement() override; |
67 | 72 |
73 // KeyedService implementations. | |
Finnur
2014/10/30 14:16:59
nit: The agreed upon syntax for this was:
// Inter
binjin
2014/10/30 16:41:11
Done.
| |
74 virtual void ShutDown(); | |
Finnur
2014/10/30 14:16:59
delete 'virtual' and add 'override' at the end.
binjin
2014/10/30 16:41:11
Done. Also found that I mis-spelled the method nam
| |
75 | |
68 void AddObserver(Observer* observer); | 76 void AddObserver(Observer* observer); |
69 void RemoveObserver(Observer* observer); | 77 void RemoveObserver(Observer* observer); |
70 | 78 |
71 // Get the ManagementPolicy::Provider controlled by extension management | 79 // Get the list of ManagementPolicy::Provider controlled by extension |
72 // policy settings. | 80 // management policy settings. |
73 ManagementPolicy::Provider* GetProvider() const; | 81 std::vector<ManagementPolicy::Provider*> GetProviders() const; |
74 | 82 |
75 // Checks if extensions are blacklisted by default, by policy. When true, | 83 // Checks if extensions are blacklisted by default, by policy. When true, |
76 // this means that even extensions without an ID should be blacklisted (e.g. | 84 // this means that even extensions without an ID should be blacklisted (e.g. |
77 // from the command line, or when loaded as an unpacked extension). | 85 // from the command line, or when loaded as an unpacked extension). |
78 bool BlacklistedByDefault() const; | 86 bool BlacklistedByDefault() const; |
79 | 87 |
80 // Returns installation mode for an extension. | 88 // Returns installation mode for an extension. |
81 InstallationMode GetInstallationMode(const ExtensionId& id) const; | 89 InstallationMode GetInstallationMode(const ExtensionId& id) const; |
82 | 90 |
83 // Returns the force install list, in format specified by | 91 // Returns the force install list, in format specified by |
84 // ExternalPolicyLoader::AddExtension(). | 92 // ExternalPolicyLoader::AddExtension(). |
85 scoped_ptr<base::DictionaryValue> GetForceInstallList() const; | 93 scoped_ptr<base::DictionaryValue> GetForceInstallList() const; |
86 | 94 |
87 // Like GetForceInstallList(), but returns recommended install list instead. | 95 // Like GetForceInstallList(), but returns recommended install list instead. |
88 scoped_ptr<base::DictionaryValue> GetRecommendedInstallList() const; | 96 scoped_ptr<base::DictionaryValue> GetRecommendedInstallList() const; |
89 | 97 |
90 // Returns if an extension with id |id| is explicitly allowed by enterprise | 98 // Returns if an extension with id |id| is explicitly allowed by enterprise |
91 // policy or not. | 99 // policy or not. |
92 bool IsInstallationExplicitlyAllowed(const ExtensionId& id) const; | 100 bool IsInstallationExplicitlyAllowed(const ExtensionId& id) const; |
93 | 101 |
94 // Returns true if an extension download should be allowed to proceed. | 102 // Returns true if an extension download should be allowed to proceed. |
95 bool IsOffstoreInstallAllowed(const GURL& url, | 103 bool IsOffstoreInstallAllowed(const GURL& url, |
96 const GURL& referrer_url) const; | 104 const GURL& referrer_url) const; |
97 | 105 |
98 // Returns true if an extension with manifest type |manifest_type| is | 106 // Returns true if an extension with manifest type |manifest_type| is |
99 // allowed to be installed. | 107 // allowed to be installed. |
100 bool IsAllowedManifestType(Manifest::Type manifest_type) const; | 108 bool IsAllowedManifestType(Manifest::Type manifest_type) const; |
101 | 109 |
110 // Returns the list of blocked API permissions for the extension |id|. | |
111 const APIPermissionSet& GetBlockedAPIPermissions(const ExtensionId& id) const; | |
112 | |
113 // Returns blocked permission set for extension |id|. | |
114 scoped_refptr<const PermissionSet> GetBlockedPermissions( | |
115 const ExtensionId& id) const; | |
116 | |
117 // Returns true if every permission in |perms| is allowed for extension |id|. | |
118 bool IsPermissionSetAllowed(const ExtensionId& id, | |
119 scoped_refptr<const PermissionSet> perms) const; | |
120 | |
102 private: | 121 private: |
103 typedef base::ScopedPtrHashMap<ExtensionId, internal::IndividualSettings> | 122 typedef base::ScopedPtrHashMap<ExtensionId, internal::IndividualSettings> |
104 SettingsIdMap; | 123 SettingsIdMap; |
105 friend class ExtensionManagementServiceTest; | 124 friend class ExtensionManagementServiceTest; |
106 | 125 |
107 // Load all extension management preferences from |pref_service|, and | 126 // Load all extension management preferences from |pref_service|, and |
108 // refresh the settings. | 127 // refresh the settings. |
109 void Refresh(); | 128 void Refresh(); |
110 | 129 |
111 // Load preference with name |pref_name| and expected type |expected_type|. | 130 // Load preference with name |pref_name| and expected type |expected_type|. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 // enforced. | 165 // enforced. |
147 scoped_ptr<internal::IndividualSettings> default_settings_; | 166 scoped_ptr<internal::IndividualSettings> default_settings_; |
148 | 167 |
149 // Extension settings applicable to all extensions. | 168 // Extension settings applicable to all extensions. |
150 scoped_ptr<internal::GlobalSettings> global_settings_; | 169 scoped_ptr<internal::GlobalSettings> global_settings_; |
151 | 170 |
152 PrefService* pref_service_; | 171 PrefService* pref_service_; |
153 | 172 |
154 ObserverList<Observer, true> observer_list_; | 173 ObserverList<Observer, true> observer_list_; |
155 PrefChangeRegistrar pref_change_registrar_; | 174 PrefChangeRegistrar pref_change_registrar_; |
156 scoped_ptr<ManagementPolicy::Provider> provider_; | 175 ScopedVector<ManagementPolicy::Provider> providers_; |
157 | 176 |
158 DISALLOW_COPY_AND_ASSIGN(ExtensionManagement); | 177 DISALLOW_COPY_AND_ASSIGN(ExtensionManagement); |
159 }; | 178 }; |
160 | 179 |
161 class ExtensionManagementFactory : public BrowserContextKeyedServiceFactory { | 180 class ExtensionManagementFactory : public BrowserContextKeyedServiceFactory { |
162 public: | 181 public: |
163 static ExtensionManagement* GetForBrowserContext( | 182 static ExtensionManagement* GetForBrowserContext( |
164 content::BrowserContext* context); | 183 content::BrowserContext* context); |
165 static ExtensionManagementFactory* GetInstance(); | 184 static ExtensionManagementFactory* GetInstance(); |
166 | 185 |
(...skipping 10 matching lines...) Expand all Loading... | |
177 content::BrowserContext* context) const override; | 196 content::BrowserContext* context) const override; |
178 void RegisterProfilePrefs( | 197 void RegisterProfilePrefs( |
179 user_prefs::PrefRegistrySyncable* registry) override; | 198 user_prefs::PrefRegistrySyncable* registry) override; |
180 | 199 |
181 DISALLOW_COPY_AND_ASSIGN(ExtensionManagementFactory); | 200 DISALLOW_COPY_AND_ASSIGN(ExtensionManagementFactory); |
182 }; | 201 }; |
183 | 202 |
184 } // namespace extensions | 203 } // namespace extensions |
185 | 204 |
186 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_H_ | 205 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_H_ |
OLD | NEW |