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

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

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

Powered by Google App Engine
This is Rietveld 408576698