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 <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 | 103 |
104 // Get the ManagementPolicy::Provider controlled by extension management | 104 // Get the ManagementPolicy::Provider controlled by extension management |
105 // policy settings. | 105 // policy settings. |
106 ManagementPolicy::Provider* GetProvider(); | 106 ManagementPolicy::Provider* GetProvider(); |
107 | 107 |
108 // Checks if extensions are blacklisted by default, by policy. When true, | 108 // Checks if extensions are blacklisted by default, by policy. When true, |
109 // this means that even extensions without an ID should be blacklisted (e.g. | 109 // this means that even extensions without an ID should be blacklisted (e.g. |
110 // from the command line, or when loaded as an unpacked extension). | 110 // from the command line, or when loaded as an unpacked extension). |
111 bool BlacklistedByDefault(); | 111 bool BlacklistedByDefault(); |
112 | 112 |
113 // Returns the force install list, in format specified by | |
114 // ExternalPolicyLoader::AddExtension(). | |
115 scoped_ptr<base::DictionaryValue> GetForceInstallList() const; | |
116 | |
117 // Returns if an extension with id |id| is allowed to install or not. | |
118 bool IsInstallationAllowed(const ExtensionId& id) const; | |
119 | |
113 // Helper function to read |settings_by_id_| with |id| as key. Returns a | 120 // Helper function to read |settings_by_id_| with |id| as key. Returns a |
114 // constant reference to default settings if |id| does not exist. | 121 // constant reference to default settings if |id| does not exist. |
115 const IndividualSettings& ReadById(const ExtensionId& id) const; | 122 const IndividualSettings& ReadById(const ExtensionId& id) const; |
116 | 123 |
117 // Returns a constant reference to |global_settings_|. | 124 // Returns a constant reference to |global_settings_|. |
118 const GlobalSettings& ReadGlobalSettings() const; | 125 const GlobalSettings& ReadGlobalSettings() const; |
119 | 126 |
127 // Allow preference from user preference store, for testing purpose. | |
128 void AllowUserPreferenceForTesting() const; | |
Joao da Silva
2014/09/07 14:30:21
Revert these changes. See the comment on the brows
| |
129 | |
120 private: | 130 private: |
121 // Load all extension management preferences from |pref_service|, and | 131 // Load all extension management preferences from |pref_service|, and |
122 // refresh the settings. | 132 // refresh the settings. |
123 void Refresh(); | 133 void Refresh(); |
124 | 134 |
125 // Load preference with name |pref_name| and expected type |expected_type|. | 135 // Load preference with name |pref_name| and expected type |expected_type|. |
126 // If |force_managed| is true, only loading from the managed preference store | 136 // If |force_managed| is true, only loading from the managed preference store |
127 // is allowed. Returns NULL if the preference is not present, not allowed to | 137 // is allowed. Returns NULL if the preference is not present, not allowed to |
128 // be loaded from or has the wrong type. | 138 // be loaded from or has the wrong type. |
129 const base::Value* LoadPreference(const char* pref_name, | 139 const base::Value* LoadPreference(const char* pref_name, |
(...skipping 19 matching lines...) Expand all Loading... | |
149 // For extension settings applied to an individual extension (identified by | 159 // For extension settings applied to an individual extension (identified by |
150 // extension ID) or a group of extension (with specified extension update | 160 // extension ID) or a group of extension (with specified extension update |
151 // URL), all unspecified part will take value from |default_settings_|. | 161 // URL), all unspecified part will take value from |default_settings_|. |
152 // For all other extensions, all settings from |default_settings_| will be | 162 // For all other extensions, all settings from |default_settings_| will be |
153 // enforced. | 163 // enforced. |
154 IndividualSettings default_settings_; | 164 IndividualSettings default_settings_; |
155 | 165 |
156 // Extension settings applicable to all extensions. | 166 // Extension settings applicable to all extensions. |
157 GlobalSettings global_settings_; | 167 GlobalSettings global_settings_; |
158 | 168 |
169 mutable bool allow_user_preference_; | |
170 | |
159 PrefService* pref_service_; | 171 PrefService* pref_service_; |
160 | 172 |
161 ObserverList<Observer, true> observer_list_; | 173 ObserverList<Observer, true> observer_list_; |
162 PrefChangeRegistrar pref_change_registrar_; | 174 PrefChangeRegistrar pref_change_registrar_; |
163 scoped_ptr<ManagementPolicy::Provider> provider_; | 175 scoped_ptr<ManagementPolicy::Provider> provider_; |
164 | 176 |
165 DISALLOW_COPY_AND_ASSIGN(ExtensionManagement); | 177 DISALLOW_COPY_AND_ASSIGN(ExtensionManagement); |
166 }; | 178 }; |
167 | 179 |
168 class ExtensionManagementFactory : public BrowserContextKeyedServiceFactory { | 180 class ExtensionManagementFactory : public BrowserContextKeyedServiceFactory { |
(...skipping 11 matching lines...) Expand all Loading... | |
180 // BrowserContextKeyedServiceExtensionManagementFactory: | 192 // BrowserContextKeyedServiceExtensionManagementFactory: |
181 virtual KeyedService* BuildServiceInstanceFor( | 193 virtual KeyedService* BuildServiceInstanceFor( |
182 content::BrowserContext* context) const OVERRIDE; | 194 content::BrowserContext* context) const OVERRIDE; |
183 | 195 |
184 DISALLOW_COPY_AND_ASSIGN(ExtensionManagementFactory); | 196 DISALLOW_COPY_AND_ASSIGN(ExtensionManagementFactory); |
185 }; | 197 }; |
186 | 198 |
187 } // namespace extensions | 199 } // namespace extensions |
188 | 200 |
189 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_H_ | 201 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_H_ |
OLD | NEW |