Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(580)

Side by Side Diff: chrome/browser/extensions/extension_management.h

Issue 2144313002: Plumbing for login apps device policy to extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/singleton.h" 15 #include "base/memory/singleton.h"
16 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "components/keyed_service/content/browser_context_keyed_service_factory .h" 18 #include "components/keyed_service/content/browser_context_keyed_service_factory .h"
19 #include "components/keyed_service/core/keyed_service.h" 19 #include "components/keyed_service/core/keyed_service.h"
20 #include "components/prefs/pref_change_registrar.h" 20 #include "components/prefs/pref_change_registrar.h"
21 #include "extensions/browser/management_policy.h" 21 #include "extensions/browser/management_policy.h"
22 #include "extensions/common/extension_id.h" 22 #include "extensions/common/extension_id.h"
23 #include "extensions/common/manifest.h" 23 #include "extensions/common/manifest.h"
24 24
25 class GURL; 25 class GURL;
26 class PrefService; 26 class Profile;
27 27
28 namespace content { 28 namespace content {
29 class BrowserContext; 29 class BrowserContext;
30 } // namespace content 30 } // namespace content
31 31
32 namespace extensions { 32 namespace extensions {
33 33
34 namespace internal { 34 namespace internal {
35 35
36 struct IndividualSettings; 36 struct IndividualSettings;
(...skipping 26 matching lines...) Expand all
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 explicit ExtensionManagement(Profile* profile);
Devlin 2017/03/03 17:24:48 nit: I think I'd prefer we just pass in a bool is_
achuithb 2017/03/06 15:26:04 Done.
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 private: 132 private:
133 using SettingsIdMap = 133 using SettingsIdMap =
134 std::unordered_map<ExtensionId, 134 std::unordered_map<ExtensionId,
135 std::unique_ptr<internal::IndividualSettings>>; 135 std::unique_ptr<internal::IndividualSettings>>;
136 using SettingsUpdateUrlMap = 136 using SettingsUpdateUrlMap =
137 std::unordered_map<std::string, 137 std::unordered_map<std::string,
138 std::unique_ptr<internal::IndividualSettings>>; 138 std::unique_ptr<internal::IndividualSettings>>;
139 friend class ExtensionManagementServiceTest; 139 friend class ExtensionManagementServiceTest;
140 140
141 // Load all extension management preferences from |pref_service|, and 141 // Load all extension management preferences from the pref service, and
142 // refresh the settings. 142 // refresh the settings.
143 void Refresh(); 143 void Refresh();
144 144
145 // Load preference with name |pref_name| and expected type |expected_type|. 145 // Load preference with name |pref_name| and expected type |expected_type|.
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 update |extension_dict| for forced installs.
157 void UpdateForcedExtensions(const base::DictionaryValue* extension_dict);
158
159 // Helper to return an extension install list, in format specified by
160 // ExternalPolicyLoader::AddExtension().
161 std::unique_ptr<base::DictionaryValue> GetInstallListByMode(
162 InstallationMode installation_mode) const;
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
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 Profile* profile_ = nullptr;
187 195
188 base::ObserverList<Observer, true> observer_list_; 196 base::ObserverList<Observer, true> observer_list_;
189 PrefChangeRegistrar pref_change_registrar_; 197 PrefChangeRegistrar pref_change_registrar_;
190 std::vector<std::unique_ptr<ManagementPolicy::Provider>> providers_; 198 std::vector<std::unique_ptr<ManagementPolicy::Provider>> providers_;
191 199
192 DISALLOW_COPY_AND_ASSIGN(ExtensionManagement); 200 DISALLOW_COPY_AND_ASSIGN(ExtensionManagement);
193 }; 201 };
194 202
195 class ExtensionManagementFactory : public BrowserContextKeyedServiceFactory { 203 class ExtensionManagementFactory : public BrowserContextKeyedServiceFactory {
196 public: 204 public:
(...skipping 14 matching lines...) Expand all
211 content::BrowserContext* context) const override; 219 content::BrowserContext* context) const override;
212 void RegisterProfilePrefs( 220 void RegisterProfilePrefs(
213 user_prefs::PrefRegistrySyncable* registry) override; 221 user_prefs::PrefRegistrySyncable* registry) override;
214 222
215 DISALLOW_COPY_AND_ASSIGN(ExtensionManagementFactory); 223 DISALLOW_COPY_AND_ASSIGN(ExtensionManagementFactory);
216 }; 224 };
217 225
218 } // namespace extensions 226 } // namespace extensions
219 227
220 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_H_ 228 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_management.cc » ('j') | chrome/browser/extensions/extension_management.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698