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 <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <unordered_map> | 10 #include <unordered_map> |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // and cannot be disabled. | 63 // and cannot be disabled. |
64 // * INSTALLATION_RECOMMENDED: Extension will be installed automatically but | 64 // * INSTALLATION_RECOMMENDED: Extension will be installed automatically but |
65 // can be disabled. | 65 // can be disabled. |
66 enum InstallationMode { | 66 enum InstallationMode { |
67 INSTALLATION_ALLOWED = 0, | 67 INSTALLATION_ALLOWED = 0, |
68 INSTALLATION_BLOCKED, | 68 INSTALLATION_BLOCKED, |
69 INSTALLATION_FORCED, | 69 INSTALLATION_FORCED, |
70 INSTALLATION_RECOMMENDED, | 70 INSTALLATION_RECOMMENDED, |
71 }; | 71 }; |
72 | 72 |
73 explicit ExtensionManagement(PrefService* pref_service); | 73 ExtensionManagement(PrefService* pref_service, bool is_signin_profile); |
74 ~ExtensionManagement() override; | 74 ~ExtensionManagement() override; |
75 | 75 |
76 // KeyedService implementations: | 76 // KeyedService implementations: |
77 void Shutdown() override; | 77 void Shutdown() override; |
78 | 78 |
79 void AddObserver(Observer* observer); | 79 void AddObserver(Observer* observer); |
80 void RemoveObserver(Observer* observer); | 80 void RemoveObserver(Observer* observer); |
81 | 81 |
82 // Get the list of ManagementPolicy::Provider controlled by extension | 82 // Get the list of ManagementPolicy::Provider controlled by extension |
83 // management policy settings. | 83 // management policy settings. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // If |force_managed| is true, only loading from the managed preference store | 146 // If |force_managed| is true, only loading from the managed preference store |
147 // is allowed. Returns NULL if the preference is not present, not allowed to | 147 // is allowed. Returns NULL if the preference is not present, not allowed to |
148 // be loaded from or has the wrong type. | 148 // be loaded from or has the wrong type. |
149 const base::Value* LoadPreference(const char* pref_name, | 149 const base::Value* LoadPreference(const char* pref_name, |
150 bool force_managed, | 150 bool force_managed, |
151 base::Value::Type expected_type); | 151 base::Value::Type expected_type); |
152 | 152 |
153 void OnExtensionPrefChanged(); | 153 void OnExtensionPrefChanged(); |
154 void NotifyExtensionManagementPrefChanged(); | 154 void NotifyExtensionManagementPrefChanged(); |
155 | 155 |
| 156 // Helper to return an extension install list, in format specified by |
| 157 // ExternalPolicyLoader::AddExtension(). |
| 158 std::unique_ptr<base::DictionaryValue> GetInstallListByMode( |
| 159 InstallationMode installation_mode) const; |
| 160 |
| 161 // Helper to update |extension_dict| for forced installs. |
| 162 void UpdateForcedExtensions(const base::DictionaryValue* extension_dict); |
| 163 |
156 // Helper function to access |settings_by_id_| with |id| as key. | 164 // Helper function to access |settings_by_id_| with |id| as key. |
157 // Adds a new IndividualSettings entry to |settings_by_id_| if none exists for | 165 // Adds a new IndividualSettings entry to |settings_by_id_| if none exists for |
158 // |id| yet. | 166 // |id| yet. |
159 internal::IndividualSettings* AccessById(const ExtensionId& id); | 167 internal::IndividualSettings* AccessById(const ExtensionId& id); |
160 | 168 |
161 // Similar to AccessById(), but access |settings_by_update_url_| instead. | 169 // Similar to AccessById(), but access |settings_by_update_url_| instead. |
162 internal::IndividualSettings* AccessByUpdateUrl( | 170 internal::IndividualSettings* AccessByUpdateUrl( |
163 const std::string& update_url); | 171 const std::string& update_url); |
164 | 172 |
165 // A map containing all IndividualSettings applied to an individual extension | 173 // A map containing all IndividualSettings applied to an individual extension |
(...skipping 10 matching lines...) Expand all Loading... |
176 // For extension settings applied to an individual extension (identified by | 184 // For extension settings applied to an individual extension (identified by |
177 // extension ID) or a group of extension (with specified extension update | 185 // extension ID) or a group of extension (with specified extension update |
178 // URL), all unspecified part will take value from |default_settings_|. | 186 // URL), all unspecified part will take value from |default_settings_|. |
179 // For all other extensions, all settings from |default_settings_| will be | 187 // For all other extensions, all settings from |default_settings_| will be |
180 // enforced. | 188 // enforced. |
181 std::unique_ptr<internal::IndividualSettings> default_settings_; | 189 std::unique_ptr<internal::IndividualSettings> default_settings_; |
182 | 190 |
183 // Extension settings applicable to all extensions. | 191 // Extension settings applicable to all extensions. |
184 std::unique_ptr<internal::GlobalSettings> global_settings_; | 192 std::unique_ptr<internal::GlobalSettings> global_settings_; |
185 | 193 |
186 PrefService* pref_service_; | 194 PrefService* pref_service_ = nullptr; |
| 195 bool is_signin_profile_ = false; |
187 | 196 |
188 base::ObserverList<Observer, true> observer_list_; | 197 base::ObserverList<Observer, true> observer_list_; |
189 PrefChangeRegistrar pref_change_registrar_; | 198 PrefChangeRegistrar pref_change_registrar_; |
190 std::vector<std::unique_ptr<ManagementPolicy::Provider>> providers_; | 199 std::vector<std::unique_ptr<ManagementPolicy::Provider>> providers_; |
191 | 200 |
192 DISALLOW_COPY_AND_ASSIGN(ExtensionManagement); | 201 DISALLOW_COPY_AND_ASSIGN(ExtensionManagement); |
193 }; | 202 }; |
194 | 203 |
195 class ExtensionManagementFactory : public BrowserContextKeyedServiceFactory { | 204 class ExtensionManagementFactory : public BrowserContextKeyedServiceFactory { |
196 public: | 205 public: |
(...skipping 14 matching lines...) Expand all Loading... |
211 content::BrowserContext* context) const override; | 220 content::BrowserContext* context) const override; |
212 void RegisterProfilePrefs( | 221 void RegisterProfilePrefs( |
213 user_prefs::PrefRegistrySyncable* registry) override; | 222 user_prefs::PrefRegistrySyncable* registry) override; |
214 | 223 |
215 DISALLOW_COPY_AND_ASSIGN(ExtensionManagementFactory); | 224 DISALLOW_COPY_AND_ASSIGN(ExtensionManagementFactory); |
216 }; | 225 }; |
217 | 226 |
218 } // namespace extensions | 227 } // namespace extensions |
219 | 228 |
220 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_H_ | 229 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_H_ |
OLD | NEW |