OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PREFS_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "chrome/common/extensions/extension.h" | 21 #include "chrome/common/extensions/extension.h" |
22 #include "chrome/common/extensions/url_pattern_set.h" | 22 #include "chrome/common/extensions/url_pattern_set.h" |
23 #include "chrome/common/string_ordinal.h" | 23 #include "chrome/common/string_ordinal.h" |
24 | 24 |
25 class ExtensionPrefValueMap; | 25 class ExtensionPrefValueMap; |
26 class ExtensionSorting; | 26 class ExtensionSorting; |
27 class PrefService; | 27 class PrefService; |
28 class URLPatternSet; | 28 class URLPatternSet; |
29 | 29 |
30 namespace extensions { | 30 namespace extensions { |
| 31 class ExtensionPrefsUninstallExtension; |
31 struct ExtensionOmniboxSuggestion; | 32 struct ExtensionOmniboxSuggestion; |
32 } | |
33 | 33 |
34 // Class for managing global and per-extension preferences. | 34 // Class for managing global and per-extension preferences. |
35 // | 35 // |
36 // This class distinguishes the following kinds of preferences: | 36 // This class distinguishes the following kinds of preferences: |
37 // - global preferences: | 37 // - global preferences: |
38 // internal state for the extension system in general, not associated | 38 // internal state for the extension system in general, not associated |
39 // with an individual extension, such as lastUpdateTime. | 39 // with an individual extension, such as lastUpdateTime. |
40 // - per-extension preferences: | 40 // - per-extension preferences: |
41 // meta-preferences describing properties of the extension like | 41 // meta-preferences describing properties of the extension like |
42 // installation time, whether the extension is enabled, etc. | 42 // installation time, whether the extension is enabled, etc. |
43 // - extension controlled preferences: | 43 // - extension controlled preferences: |
44 // browser preferences that an extension controls. For example, an | 44 // browser preferences that an extension controls. For example, an |
45 // extension could use the proxy API to specify the browser's proxy | 45 // extension could use the proxy API to specify the browser's proxy |
46 // preference. Extension-controlled preferences are stored in | 46 // preference. Extension-controlled preferences are stored in |
47 // PrefValueStore::extension_prefs(), which this class populates and | 47 // PrefValueStore::extension_prefs(), which this class populates and |
48 // maintains as the underlying extensions change. | 48 // maintains as the underlying extensions change. |
49 class ExtensionPrefs : public extensions::ContentSettingsStore::Observer, | 49 class ExtensionPrefs : public ContentSettingsStore::Observer, |
50 public extensions::ManagementPolicy::Provider, | 50 public ManagementPolicy::Provider, |
51 public ExtensionScopedPrefs { | 51 public ExtensionScopedPrefs { |
52 public: | 52 public: |
53 // Key name for a preference that keeps track of per-extension settings. This | 53 // Key name for a preference that keeps track of per-extension settings. This |
54 // is a dictionary object read from the Preferences file, keyed off of | 54 // is a dictionary object read from the Preferences file, keyed off of |
55 // extension ids. | 55 // extension ids. |
56 static const char kExtensionsPref[]; | 56 static const char kExtensionsPref[]; |
57 | 57 |
58 typedef std::vector<linked_ptr<extensions::ExtensionInfo> > ExtensionsInfo; | 58 typedef std::vector<linked_ptr<ExtensionInfo> > ExtensionsInfo; |
59 | 59 |
60 // Vector containing identifiers for preferences. | 60 // Vector containing identifiers for preferences. |
61 typedef std::set<std::string> PrefKeySet; | 61 typedef std::set<std::string> PrefKeySet; |
62 | 62 |
63 // Vector containing identifiers for extensions. | 63 // Vector containing identifiers for extensions. |
64 typedef std::vector<std::string> ExtensionIdSet; | 64 typedef std::vector<std::string> ExtensionIdSet; |
65 | 65 |
66 // This enum is used for the launch type the user wants to use for an | 66 // This enum is used for the launch type the user wants to use for an |
67 // application. | 67 // application. |
68 // Do not remove items or re-order this enum as it is used in preferences | 68 // Do not remove items or re-order this enum as it is used in preferences |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 // Get the order that the browser actions appear in the toolbar. | 107 // Get the order that the browser actions appear in the toolbar. |
108 std::vector<std::string> GetToolbarOrder(); | 108 std::vector<std::string> GetToolbarOrder(); |
109 | 109 |
110 // Set the order that the browser actions appear in the toolbar. | 110 // Set the order that the browser actions appear in the toolbar. |
111 void SetToolbarOrder(const std::vector<std::string>& extension_ids); | 111 void SetToolbarOrder(const std::vector<std::string>& extension_ids); |
112 | 112 |
113 // Called when an extension is installed, so that prefs get created. | 113 // Called when an extension is installed, so that prefs get created. |
114 // If |page_ordinal| is an invalid ordinal, then a page will be found | 114 // If |page_ordinal| is an invalid ordinal, then a page will be found |
115 // for the App. | 115 // for the App. |
116 void OnExtensionInstalled(const extensions::Extension* extension, | 116 void OnExtensionInstalled(const Extension* extension, |
117 extensions::Extension::State initial_state, | 117 Extension::State initial_state, |
118 bool from_webstore, | 118 bool from_webstore, |
119 const StringOrdinal& page_ordinal); | 119 const StringOrdinal& page_ordinal); |
120 | 120 |
121 // Called when an extension is uninstalled, so that prefs get cleaned up. | 121 // Called when an extension is uninstalled, so that prefs get cleaned up. |
122 void OnExtensionUninstalled(const std::string& extension_id, | 122 void OnExtensionUninstalled(const std::string& extension_id, |
123 const extensions::Extension::Location& location, | 123 const Extension::Location& location, |
124 bool external_uninstall); | 124 bool external_uninstall); |
125 | 125 |
126 // Called to change the extension's state when it is enabled/disabled. | 126 // Called to change the extension's state when it is enabled/disabled. |
127 void SetExtensionState(const std::string& extension_id, | 127 void SetExtensionState(const std::string& extension_id, Extension::State); |
128 extensions::Extension::State); | |
129 | 128 |
130 // Returns all installed extensions | 129 // Returns all installed extensions |
131 void GetExtensions(ExtensionIdSet* out); | 130 void GetExtensions(ExtensionIdSet* out); |
132 | 131 |
133 // Returns all installed extensions from |extension_prefs|. This is exposed | 132 // Returns all installed extensions from |extension_prefs|. This is exposed |
134 // for ProtectedPrefsWatcher because it needs access to the extension ID list | 133 // for ProtectedPrefsWatcher because it needs access to the extension ID list |
135 // before the ExtensionService is initialized. | 134 // before the ExtensionService is initialized. |
136 static ExtensionIdSet GetExtensionsFrom( | 135 static ExtensionIdSet GetExtensionsFrom( |
137 const base::DictionaryValue* extension_prefs); | 136 const base::DictionaryValue* extension_prefs); |
138 | 137 |
139 // Getter and setter for browser action visibility. | 138 // Getter and setter for browser action visibility. |
140 bool GetBrowserActionVisibility(const extensions::Extension* extension); | 139 bool GetBrowserActionVisibility(const Extension* extension); |
141 void SetBrowserActionVisibility(const extensions::Extension* extension, | 140 void SetBrowserActionVisibility(const Extension* extension, |
142 bool visible); | 141 bool visible); |
143 | 142 |
144 // Did the extension ask to escalate its permission during an upgrade? | 143 // Did the extension ask to escalate its permission during an upgrade? |
145 bool DidExtensionEscalatePermissions(const std::string& id); | 144 bool DidExtensionEscalatePermissions(const std::string& id); |
146 | 145 |
147 // If |did_escalate| is true, the preferences for |extension| will be set to | 146 // If |did_escalate| is true, the preferences for |extension| will be set to |
148 // require the install warning when the user tries to enable. | 147 // require the install warning when the user tries to enable. |
149 void SetDidExtensionEscalatePermissions( | 148 void SetDidExtensionEscalatePermissions( |
150 const extensions::Extension* extension, | 149 const Extension* extension, |
151 bool did_escalate); | 150 bool did_escalate); |
152 | 151 |
153 // Getter and setters for disabled reason. | 152 // Getter and setters for disabled reason. |
154 extensions::Extension::DisableReason GetDisableReason( | 153 Extension::DisableReason GetDisableReason( |
155 const std::string& extension_id); | 154 const std::string& extension_id); |
156 void SetDisableReason(const std::string& extension_id, | 155 void SetDisableReason(const std::string& extension_id, |
157 extensions::Extension::DisableReason disable_reason); | 156 Extension::DisableReason disable_reason); |
158 void RemoveDisableReason(const std::string& extension_id); | 157 void RemoveDisableReason(const std::string& extension_id); |
159 | 158 |
160 // Returns the version string for the currently installed extension, or | 159 // Returns the version string for the currently installed extension, or |
161 // the empty string if not found. | 160 // the empty string if not found. |
162 std::string GetVersionString(const std::string& extension_id); | 161 std::string GetVersionString(const std::string& extension_id); |
163 | 162 |
164 // Re-writes the extension manifest into the prefs. | 163 // Re-writes the extension manifest into the prefs. |
165 // Called to change the extension's manifest when it's re-localized. | 164 // Called to change the extension's manifest when it's re-localized. |
166 void UpdateManifest(const extensions::Extension* extension); | 165 void UpdateManifest(const Extension* extension); |
167 | 166 |
168 // Returns extension path based on extension ID, or empty FilePath on error. | 167 // Returns extension path based on extension ID, or empty FilePath on error. |
169 FilePath GetExtensionPath(const std::string& extension_id); | 168 FilePath GetExtensionPath(const std::string& extension_id); |
170 | 169 |
171 // Returns base extensions install directory. | 170 // Returns base extensions install directory. |
172 const FilePath& install_directory() const { return install_directory_; } | 171 const FilePath& install_directory() const { return install_directory_; } |
173 | 172 |
174 // Updates the prefs based on the blacklist. | 173 // Updates the prefs based on the blacklist. |
175 void UpdateBlacklist(const std::set<std::string>& blacklist_set); | 174 void UpdateBlacklist(const std::set<std::string>& blacklist_set); |
176 | 175 |
(...skipping 28 matching lines...) Expand all Loading... |
205 void SetAppNotificationClientId(const std::string& extension_id, | 204 void SetAppNotificationClientId(const std::string& extension_id, |
206 const std::string& oauth_client_id); | 205 const std::string& oauth_client_id); |
207 | 206 |
208 // Whether app notifications are disabled for the given app. | 207 // Whether app notifications are disabled for the given app. |
209 bool IsAppNotificationDisabled(const std::string& extension_id) const; | 208 bool IsAppNotificationDisabled(const std::string& extension_id) const; |
210 void SetAppNotificationDisabled(const std::string& extension_id, bool value); | 209 void SetAppNotificationDisabled(const std::string& extension_id, bool value); |
211 | 210 |
212 // ManagementPolicy::Provider | 211 // ManagementPolicy::Provider |
213 // These methods apply admin policy to extensions. | 212 // These methods apply admin policy to extensions. |
214 virtual std::string GetDebugPolicyProviderName() const OVERRIDE; | 213 virtual std::string GetDebugPolicyProviderName() const OVERRIDE; |
215 virtual bool UserMayLoad(const extensions::Extension* extension, | 214 virtual bool UserMayLoad(const Extension* extension, |
216 string16* error) const OVERRIDE; | 215 string16* error) const OVERRIDE; |
217 virtual bool UserMayModifySettings(const extensions::Extension* extension, | 216 virtual bool UserMayModifySettings(const Extension* extension, |
218 string16* error) const OVERRIDE; | 217 string16* error) const OVERRIDE; |
219 virtual bool MustRemainEnabled(const extensions::Extension* extension, | 218 virtual bool MustRemainEnabled(const Extension* extension, |
220 string16* error) const OVERRIDE; | 219 string16* error) const OVERRIDE; |
221 | 220 |
222 // Checks if extensions are blacklisted by default, by policy. | 221 // Checks if extensions are blacklisted by default, by policy. |
223 // The ManagementPolicy::Provider methods also take this into account, and | 222 // The ManagementPolicy::Provider methods also take this into account, and |
224 // should be used instead when the extension ID is known. | 223 // should be used instead when the extension ID is known. |
225 bool ExtensionsBlacklistedByDefault() const; | 224 bool ExtensionsBlacklistedByDefault() const; |
226 | 225 |
227 // Returns the last value set via SetLastPingDay. If there isn't such a | 226 // Returns the last value set via SetLastPingDay. If there isn't such a |
228 // pref, the returned Time will return true for is_null(). | 227 // pref, the returned Time will return true for is_null(). |
229 base::Time LastPingDay(const std::string& extension_id) const; | 228 base::Time LastPingDay(const std::string& extension_id) const; |
(...skipping 14 matching lines...) Expand all Loading... |
244 | 243 |
245 // A bit we use for determining if we should send the "days since active" | 244 // A bit we use for determining if we should send the "days since active" |
246 // ping. A value of true means the item has been active (launched) since the | 245 // ping. A value of true means the item has been active (launched) since the |
247 // last update check. | 246 // last update check. |
248 bool GetActiveBit(const std::string& extension_id); | 247 bool GetActiveBit(const std::string& extension_id); |
249 void SetActiveBit(const std::string& extension_id, bool active); | 248 void SetActiveBit(const std::string& extension_id, bool active); |
250 | 249 |
251 // Returns the granted permission set for the extension with |extension_id|, | 250 // Returns the granted permission set for the extension with |extension_id|, |
252 // and NULL if no preferences were found for |extension_id|. | 251 // and NULL if no preferences were found for |extension_id|. |
253 // This passes ownership of the returned set to the caller. | 252 // This passes ownership of the returned set to the caller. |
254 extensions::PermissionSet* GetGrantedPermissions( | 253 PermissionSet* GetGrantedPermissions(const std::string& extension_id); |
255 const std::string& extension_id); | |
256 | 254 |
257 // Adds |permissions| to the granted permissions set for the extension with | 255 // Adds |permissions| to the granted permissions set for the extension with |
258 // |extension_id|. The new granted permissions set will be the union of | 256 // |extension_id|. The new granted permissions set will be the union of |
259 // |permissions| and the already granted permissions. | 257 // |permissions| and the already granted permissions. |
260 void AddGrantedPermissions(const std::string& extension_id, | 258 void AddGrantedPermissions(const std::string& extension_id, |
261 const extensions::PermissionSet* permissions); | 259 const PermissionSet* permissions); |
262 | 260 |
263 // As above, but subtracts the given |permissions| from the granted set. | 261 // As above, but subtracts the given |permissions| from the granted set. |
264 void RemoveGrantedPermissions(const std::string& extension_id, | 262 void RemoveGrantedPermissions(const std::string& extension_id, |
265 const extensions::PermissionSet* permissions); | 263 const PermissionSet* permissions); |
266 | 264 |
267 // Gets the active permission set for the specified extension. This may | 265 // Gets the active permission set for the specified extension. This may |
268 // differ from the permissions in the manifest due to the optional | 266 // differ from the permissions in the manifest due to the optional |
269 // permissions API. This passes ownership of the set to the caller. | 267 // permissions API. This passes ownership of the set to the caller. |
270 extensions::PermissionSet* GetActivePermissions( | 268 PermissionSet* GetActivePermissions(const std::string& extension_id); |
271 const std::string& extension_id); | |
272 | 269 |
273 // Sets the active |permissions| for the extension with |extension_id|. | 270 // Sets the active |permissions| for the extension with |extension_id|. |
274 void SetActivePermissions(const std::string& extension_id, | 271 void SetActivePermissions(const std::string& extension_id, |
275 const extensions::PermissionSet* permissions); | 272 const PermissionSet* permissions); |
276 | 273 |
277 // Returns the list of events that the given extension has registered for. | 274 // Returns the list of events that the given extension has registered for. |
278 std::set<std::string> GetRegisteredEvents(const std::string& extension_id); | 275 std::set<std::string> GetRegisteredEvents(const std::string& extension_id); |
279 void SetRegisteredEvents(const std::string& extension_id, | 276 void SetRegisteredEvents(const std::string& extension_id, |
280 const std::set<std::string>& events); | 277 const std::set<std::string>& events); |
281 | 278 |
282 // Adds a filter to an event. | 279 // Adds a filter to an event. |
283 void AddFilterToEvent(const std::string& event_name, | 280 void AddFilterToEvent(const std::string& event_name, |
284 const std::string& extension_id, | 281 const std::string& extension_id, |
285 const DictionaryValue* filter); | 282 const DictionaryValue* filter); |
286 | 283 |
287 // Removes a filter from an event. | 284 // Removes a filter from an event. |
288 void RemoveFilterFromEvent(const std::string& event_name, | 285 void RemoveFilterFromEvent(const std::string& event_name, |
289 const std::string& extension_id, | 286 const std::string& extension_id, |
290 const DictionaryValue* filter); | 287 const DictionaryValue* filter); |
291 | 288 |
292 // Returns the dictionary of event filters that the given extension has | 289 // Returns the dictionary of event filters that the given extension has |
293 // registered. | 290 // registered. |
294 const DictionaryValue* GetFilteredEvents( | 291 const DictionaryValue* GetFilteredEvents( |
295 const std::string& extension_id) const; | 292 const std::string& extension_id) const; |
296 | 293 |
297 // Controls the omnibox default suggestion as set by the extension. | 294 // Controls the omnibox default suggestion as set by the extension. |
298 extensions::ExtensionOmniboxSuggestion GetOmniboxDefaultSuggestion( | 295 ExtensionOmniboxSuggestion GetOmniboxDefaultSuggestion( |
299 const std::string& extension_id); | 296 const std::string& extension_id); |
300 void SetOmniboxDefaultSuggestion( | 297 void SetOmniboxDefaultSuggestion( |
301 const std::string& extension_id, | 298 const std::string& extension_id, |
302 const extensions::ExtensionOmniboxSuggestion& suggestion); | 299 const ExtensionOmniboxSuggestion& suggestion); |
303 | 300 |
304 // Returns true if the user enabled this extension to be loaded in incognito | 301 // Returns true if the user enabled this extension to be loaded in incognito |
305 // mode. | 302 // mode. |
306 bool IsIncognitoEnabled(const std::string& extension_id); | 303 bool IsIncognitoEnabled(const std::string& extension_id); |
307 void SetIsIncognitoEnabled(const std::string& extension_id, bool enabled); | 304 void SetIsIncognitoEnabled(const std::string& extension_id, bool enabled); |
308 | 305 |
309 // Returns true if the user has chosen to allow this extension to inject | 306 // Returns true if the user has chosen to allow this extension to inject |
310 // scripts into pages with file URLs. | 307 // scripts into pages with file URLs. |
311 bool AllowFileAccess(const std::string& extension_id); | 308 bool AllowFileAccess(const std::string& extension_id); |
312 void SetAllowFileAccess(const std::string& extension_id, bool allow); | 309 void SetAllowFileAccess(const std::string& extension_id, bool allow); |
313 bool HasAllowFileAccessSetting(const std::string& extension_id) const; | 310 bool HasAllowFileAccessSetting(const std::string& extension_id) const; |
314 | 311 |
315 // Get the launch type preference. If no preference is set, return | 312 // Get the launch type preference. If no preference is set, return |
316 // |default_pref_value|. | 313 // |default_pref_value|. |
317 LaunchType GetLaunchType(const std::string& extension_id, | 314 LaunchType GetLaunchType(const std::string& extension_id, |
318 LaunchType default_pref_value); | 315 LaunchType default_pref_value); |
319 | 316 |
320 void SetLaunchType(const std::string& extension_id, LaunchType launch_type); | 317 void SetLaunchType(const std::string& extension_id, LaunchType launch_type); |
321 | 318 |
322 // Find the right launch container based on the launch type. | 319 // Find the right launch container based on the launch type. |
323 // If |extension|'s prefs do not have a launch type set, then | 320 // If |extension|'s prefs do not have a launch type set, then |
324 // use |default_pref_value|. | 321 // use |default_pref_value|. |
325 extension_misc::LaunchContainer GetLaunchContainer( | 322 extension_misc::LaunchContainer GetLaunchContainer( |
326 const extensions::Extension* extension, | 323 const Extension* extension, |
327 LaunchType default_pref_value); | 324 LaunchType default_pref_value); |
328 | 325 |
329 // Saves ExtensionInfo for each installed extension with the path to the | 326 // Saves ExtensionInfo for each installed extension with the path to the |
330 // version directory and the location. Blacklisted extensions won't be saved | 327 // version directory and the location. Blacklisted extensions won't be saved |
331 // and neither will external extensions the user has explicitly uninstalled. | 328 // and neither will external extensions the user has explicitly uninstalled. |
332 // Caller takes ownership of returned structure. | 329 // Caller takes ownership of returned structure. |
333 ExtensionsInfo* GetInstalledExtensionsInfo(); | 330 ExtensionsInfo* GetInstalledExtensionsInfo(); |
334 | 331 |
335 // Returns the ExtensionInfo from the prefs for the given extension. If the | 332 // Returns the ExtensionInfo from the prefs for the given extension. If the |
336 // extension is not present, NULL is returned. | 333 // extension is not present, NULL is returned. |
337 extensions::ExtensionInfo* GetInstalledExtensionInfo( | 334 ExtensionInfo* GetInstalledExtensionInfo(const std::string& extension_id); |
338 const std::string& extension_id); | |
339 | 335 |
340 // We've downloaded an updated .crx file for the extension, but are waiting | 336 // We've downloaded an updated .crx file for the extension, but are waiting |
341 // for idle time to install it. | 337 // for idle time to install it. |
342 void SetIdleInstallInfo(const std::string& extension_id, | 338 void SetIdleInstallInfo(const std::string& extension_id, |
343 const FilePath& crx_path, | 339 const FilePath& crx_path, |
344 const std::string& version, | 340 const std::string& version, |
345 const base::Time& fetch_time); | 341 const base::Time& fetch_time); |
346 | 342 |
347 // Removes any idle install information we have for the given |extension_id|. | 343 // Removes any idle install information we have for the given |extension_id|. |
348 // Returns true if there was info to remove; false otherwise. | 344 // Returns true if there was info to remove; false otherwise. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 // bookmark. | 419 // bookmark. |
424 bool IsFromBookmark(const std::string& extension_id) const; | 420 bool IsFromBookmark(const std::string& extension_id) const; |
425 | 421 |
426 // Helper method to acquire the installation time of an extension. | 422 // Helper method to acquire the installation time of an extension. |
427 // Returns base::Time() if the installation time could not be parsed or | 423 // Returns base::Time() if the installation time could not be parsed or |
428 // found. | 424 // found. |
429 base::Time GetInstallTime(const std::string& extension_id) const; | 425 base::Time GetInstallTime(const std::string& extension_id) const; |
430 | 426 |
431 static void RegisterUserPrefs(PrefService* prefs); | 427 static void RegisterUserPrefs(PrefService* prefs); |
432 | 428 |
433 extensions::ContentSettingsStore* content_settings_store() { | 429 ContentSettingsStore* content_settings_store() { |
434 return content_settings_store_.get(); | 430 return content_settings_store_.get(); |
435 } | 431 } |
436 | 432 |
437 // The underlying PrefService. | 433 // The underlying PrefService. |
438 PrefService* pref_service() const { return prefs_; } | 434 PrefService* pref_service() const { return prefs_; } |
439 | 435 |
440 // The underlying ExtensionSorting. | 436 // The underlying ExtensionSorting. |
441 ExtensionSorting* extension_sorting() const { | 437 ExtensionSorting* extension_sorting() const { |
442 return extension_sorting_.get(); | 438 return extension_sorting_.get(); |
443 } | 439 } |
444 | 440 |
445 // Describes the URLs that are able to install extensions. See | 441 // Describes the URLs that are able to install extensions. See |
446 // prefs::kExtensionAllowedInstallSites for more information. | 442 // prefs::kExtensionAllowedInstallSites for more information. |
447 URLPatternSet GetAllowedInstallSites(); | 443 URLPatternSet GetAllowedInstallSites(); |
448 | 444 |
449 protected: | 445 protected: |
450 // For unit testing. Enables injecting an artificial clock that is used | 446 // For unit testing. Enables injecting an artificial clock that is used |
451 // to query the current time, when an extension is installed. | 447 // to query the current time, when an extension is installed. |
452 virtual base::Time GetCurrentTime() const; | 448 virtual base::Time GetCurrentTime() const; |
453 | 449 |
454 private: | 450 private: |
455 friend class ExtensionPrefsUninstallExtension; // Unit test. | 451 friend class ExtensionPrefsUninstallExtension; // Unit test. |
456 | 452 |
457 // extensions::ContentSettingsStore::Observer methods: | 453 // extensions::ContentSettingsStore::Observer methods: |
458 virtual void OnContentSettingChanged( | 454 virtual void OnContentSettingChanged(const std::string& extension_id, |
459 const std::string& extension_id, | 455 bool incognito) OVERRIDE; |
460 bool incognito) OVERRIDE; | |
461 | 456 |
462 // ExtensionScopedPrefs methods: | 457 // ExtensionScopedPrefs methods: |
463 virtual void UpdateExtensionPref(const std::string& id, | 458 virtual void UpdateExtensionPref(const std::string& id, |
464 const std::string& key, | 459 const std::string& key, |
465 base::Value* value) OVERRIDE; | 460 base::Value* value) OVERRIDE; |
466 virtual void DeleteExtensionPrefs(const std::string& id) OVERRIDE; | 461 virtual void DeleteExtensionPrefs(const std::string& id) OVERRIDE; |
467 virtual bool ReadExtensionPrefBoolean( | 462 virtual bool ReadExtensionPrefBoolean( |
468 const std::string& extension_id, | 463 const std::string& extension_id, |
469 const std::string& pref_key) const OVERRIDE; | 464 const std::string& pref_key) const OVERRIDE; |
470 virtual bool ReadExtensionPrefInteger(const std::string& extension_id, | 465 virtual bool ReadExtensionPrefInteger(const std::string& extension_id, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 int valid_schemes); | 500 int valid_schemes); |
506 | 501 |
507 // Converts |new_value| to a list of strings and sets the |pref_key| pref | 502 // Converts |new_value| to a list of strings and sets the |pref_key| pref |
508 // belonging to |extension_id|. | 503 // belonging to |extension_id|. |
509 void SetExtensionPrefURLPatternSet(const std::string& extension_id, | 504 void SetExtensionPrefURLPatternSet(const std::string& extension_id, |
510 const std::string& pref_key, | 505 const std::string& pref_key, |
511 const URLPatternSet& new_value); | 506 const URLPatternSet& new_value); |
512 | 507 |
513 // Interprets |pref_key| in |extension_id|'s preferences as an | 508 // Interprets |pref_key| in |extension_id|'s preferences as an |
514 // PermissionSet, and passes ownership of the set to the caller. | 509 // PermissionSet, and passes ownership of the set to the caller. |
515 extensions::PermissionSet* ReadExtensionPrefPermissionSet( | 510 PermissionSet* ReadExtensionPrefPermissionSet(const std::string& extension_id, |
516 const std::string& extension_id, | 511 const std::string& pref_key); |
517 const std::string& pref_key); | |
518 | 512 |
519 // Converts the |new_value| to its value and sets the |pref_key| pref | 513 // Converts the |new_value| to its value and sets the |pref_key| pref |
520 // belonging to |extension_id|. | 514 // belonging to |extension_id|. |
521 void SetExtensionPrefPermissionSet( | 515 void SetExtensionPrefPermissionSet(const std::string& extension_id, |
522 const std::string& extension_id, | 516 const std::string& pref_key, |
523 const std::string& pref_key, | 517 const PermissionSet* new_value); |
524 const extensions::PermissionSet* new_value); | |
525 | 518 |
526 // Returns a dictionary for extension |id|'s prefs or NULL if it doesn't | 519 // Returns a dictionary for extension |id|'s prefs or NULL if it doesn't |
527 // exist. | 520 // exist. |
528 const base::DictionaryValue* GetExtensionPref(const std::string& id) const; | 521 const base::DictionaryValue* GetExtensionPref(const std::string& id) const; |
529 | 522 |
530 // Loads the preferences controlled by the specified extension from their | 523 // Loads the preferences controlled by the specified extension from their |
531 // dictionary and sets them in the |pref_value_map_|. | 524 // dictionary and sets them in the |pref_value_map_|. |
532 void LoadExtensionControlledPrefs(const std::string& id, | 525 void LoadExtensionControlledPrefs(const std::string& id, |
533 ExtensionPrefsScope scope); | 526 ExtensionPrefsScope scope); |
534 | 527 |
535 // Checks if kPrefBlacklist is set to true in the DictionaryValue. | 528 // Checks if kPrefBlacklist is set to true in the DictionaryValue. |
536 // Return false if the value is false or kPrefBlacklist does not exist. | 529 // Return false if the value is false or kPrefBlacklist does not exist. |
537 // This is used to decide if an extension is blacklisted. | 530 // This is used to decide if an extension is blacklisted. |
538 static bool IsBlacklistBitSet(base::DictionaryValue* ext); | 531 static bool IsBlacklistBitSet(base::DictionaryValue* ext); |
539 | 532 |
540 // Fix missing preference entries in the extensions that are were introduced | 533 // Fix missing preference entries in the extensions that are were introduced |
541 // in a later Chrome version. | 534 // in a later Chrome version. |
542 void FixMissingPrefs(const ExtensionIdSet& extension_ids); | 535 void FixMissingPrefs(const ExtensionIdSet& extension_ids); |
543 | 536 |
544 // Installs the persistent extension preferences into |prefs_|'s extension | 537 // Installs the persistent extension preferences into |prefs_|'s extension |
545 // pref store. Does nothing if |extensions_disabled| is true. | 538 // pref store. Does nothing if |extensions_disabled| is true. |
546 void InitPrefStore(bool extensions_disabled); | 539 void InitPrefStore(bool extensions_disabled); |
547 | 540 |
548 // Migrates the permissions data in the pref store. | 541 // Migrates the permissions data in the pref store. |
549 void MigratePermissions(const ExtensionIdSet& extension_ids); | 542 void MigratePermissions(const ExtensionIdSet& extension_ids); |
550 | 543 |
551 // Checks whether there is a state pref for the extension and if so, whether | 544 // Checks whether there is a state pref for the extension and if so, whether |
552 // it matches |check_state|. | 545 // it matches |check_state|. |
553 bool DoesExtensionHaveState(const std::string& id, | 546 bool DoesExtensionHaveState(const std::string& id, |
554 extensions::Extension::State check_state) const; | 547 Extension::State check_state) const; |
555 | 548 |
556 // The pref service specific to this set of extension prefs. Owned by profile. | 549 // The pref service specific to this set of extension prefs. Owned by profile. |
557 PrefService* prefs_; | 550 PrefService* prefs_; |
558 | 551 |
559 // Base extensions install directory. | 552 // Base extensions install directory. |
560 FilePath install_directory_; | 553 FilePath install_directory_; |
561 | 554 |
562 // Weak pointer, owned by Profile. | 555 // Weak pointer, owned by Profile. |
563 ExtensionPrefValueMap* extension_pref_value_map_; | 556 ExtensionPrefValueMap* extension_pref_value_map_; |
564 | 557 |
565 // Contains all the logic for handling the order for various extension | 558 // Contains all the logic for handling the order for various extension |
566 // properties. | 559 // properties. |
567 scoped_ptr<ExtensionSorting> extension_sorting_; | 560 scoped_ptr<ExtensionSorting> extension_sorting_; |
568 | 561 |
569 scoped_refptr<extensions::ContentSettingsStore> content_settings_store_; | 562 scoped_refptr<ContentSettingsStore> content_settings_store_; |
570 | 563 |
571 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); | 564 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); |
572 }; | 565 }; |
573 | 566 |
| 567 } // namespace extensions |
| 568 |
574 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ | 569 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_H_ |
OLD | NEW |