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
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_BROWSER_EXTENSION_PREFS_H_
6 #define EXTENSIONS_BROWSER_EXTENSION_PREFS_H_
12 #include "base/basictypes.h"
13 #include "base/memory/linked_ptr.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/observer_list.h"
16 #include "base/prefs/scoped_user_pref_update.h"
17 #include "base/time/time.h"
18 #include "base/values.h"
19 #include "components/keyed_service/core/keyed_service.h"
20 #include "extensions/browser/app_sorting.h"
21 #include "extensions/browser/blacklist_state.h"
22 #include "extensions/browser/extension_scoped_prefs.h"
23 #include "extensions/browser/install_flag.h"
24 #include "extensions/common/constants.h"
25 #include "extensions/common/extension.h"
26 #include "extensions/common/url_pattern_set.h"
27 #include "sync/api/string_ordinal.h"
29 class ExtensionPrefValueMap
;
36 namespace user_prefs
{
37 class PrefRegistrySyncable
;
40 namespace extensions
{
43 class ExtensionPrefsObserver
;
44 class ExtensionPrefsUninstallExtension
;
47 // Class for managing global and per-extension preferences.
49 // This class distinguishes the following kinds of preferences:
50 // - global preferences:
51 // internal state for the extension system in general, not associated
52 // with an individual extension, such as lastUpdateTime.
53 // - per-extension preferences:
54 // meta-preferences describing properties of the extension like
55 // installation time, whether the extension is enabled, etc.
56 // - extension controlled preferences:
57 // browser preferences that an extension controls. For example, an
58 // extension could use the proxy API to specify the browser's proxy
59 // preference. Extension-controlled preferences are stored in
60 // PrefValueStore::extension_prefs(), which this class populates and
61 // maintains as the underlying extensions change.
62 class ExtensionPrefs
: public ExtensionScopedPrefs
, public KeyedService
{
64 typedef std::vector
<linked_ptr
<ExtensionInfo
> > ExtensionsInfo
;
66 // Vector containing identifiers for preferences.
67 typedef std::set
<std::string
> PrefKeySet
;
69 // This enum is used to store the reason an extension's install has been
70 // delayed. Do not remove items or re-order this enum as it is used in
73 DELAY_REASON_NONE
= 0,
75 DELAY_REASON_WAIT_FOR_IDLE
= 2,
76 DELAY_REASON_WAIT_FOR_IMPORTS
= 3,
79 // Creates base::Time classes. The default implementation is just to return
80 // the current time, but tests can inject alternative implementations.
85 virtual ~TimeProvider();
87 // By default, returns the current time (base::Time::Now()).
88 virtual base::Time
GetCurrentTime() const;
91 DISALLOW_COPY_AND_ASSIGN(TimeProvider
);
94 // A wrapper around a ScopedUserPrefUpdate, which allows us to access the
95 // entry of a particular key for an extension. Use this if you need a mutable
96 // record of a dictionary or list in the current settings. Otherwise, prefer
97 // ReadPrefAsT() and UpdateExtensionPref() methods.
98 template <typename T
, base::Value::Type type_enum_value
>
101 ScopedUpdate(ExtensionPrefs
* prefs
,
102 const std::string
& extension_id
,
103 const std::string
& key
);
104 virtual ~ScopedUpdate();
106 // Returns a mutable value for the key (ownership remains with the prefs),
107 // if one exists. Otherwise, returns NULL.
110 // Creates and returns a mutable value for the key (the prefs own the new
111 // value), if one does not already exist. Otherwise, returns the current
116 DictionaryPrefUpdate update_
;
117 const std::string extension_id_
;
118 const std::string key_
;
120 DISALLOW_COPY_AND_ASSIGN(ScopedUpdate
);
122 typedef ScopedUpdate
<base::DictionaryValue
, base::Value::TYPE_DICTIONARY
>
123 ScopedDictionaryUpdate
;
124 typedef ScopedUpdate
<base::ListValue
, base::Value::TYPE_LIST
>
127 // Creates an ExtensionPrefs object.
128 // Does not take ownership of |prefs| or |extension_pref_value_map|.
129 // If |extensions_disabled| is true, extension controlled preferences and
130 // content settings do not become effective. ExtensionPrefsObservers should be
131 // included in |early_observers| if they need to observe events which occur
132 // during initialization of the ExtensionPrefs object.
133 static ExtensionPrefs
* Create(
135 const base::FilePath
& root_dir
,
136 ExtensionPrefValueMap
* extension_pref_value_map
,
137 scoped_ptr
<AppSorting
> app_sorting
,
138 bool extensions_disabled
,
139 const std::vector
<ExtensionPrefsObserver
*>& early_observers
);
141 // A version of Create which allows injection of a custom base::Time provider.
142 // Use this as needed for testing.
143 static ExtensionPrefs
* Create(
145 const base::FilePath
& root_dir
,
146 ExtensionPrefValueMap
* extension_pref_value_map
,
147 scoped_ptr
<AppSorting
> app_sorting
,
148 bool extensions_disabled
,
149 const std::vector
<ExtensionPrefsObserver
*>& early_observers
,
150 scoped_ptr
<TimeProvider
> time_provider
);
152 ~ExtensionPrefs() override
;
154 // Convenience function to get the ExtensionPrefs for a BrowserContext.
155 static ExtensionPrefs
* Get(content::BrowserContext
* context
);
157 // Returns all installed extensions from extension preferences provided by
158 // |pref_service|. This is exposed for ProtectedPrefsWatcher because it needs
159 // access to the extension ID list before the ExtensionService is initialized.
160 static ExtensionIdList
GetExtensionsFrom(const PrefService
* pref_service
);
162 // Add or remove an observer from the ExtensionPrefs.
163 void AddObserver(ExtensionPrefsObserver
* observer
);
164 void RemoveObserver(ExtensionPrefsObserver
* observer
);
166 // Returns true if the specified external extension was uninstalled by the
168 bool IsExternalExtensionUninstalled(const std::string
& id
) const;
170 // Checks whether |extension_id| is disabled. If there's no state pref for
171 // the extension, this will return false. Generally you should use
172 // ExtensionService::IsExtensionEnabled instead.
173 bool IsExtensionDisabled(const std::string
& id
) const;
175 // Get/Set the order that the browser actions appear in the toolbar.
176 ExtensionIdList
GetToolbarOrder();
177 void SetToolbarOrder(const ExtensionIdList
& extension_ids
);
179 // Called when an extension is installed, so that prefs get created.
180 // If |page_ordinal| is invalid then a page will be found for the App.
181 // |install_flags| are a bitmask of extension::InstallFlags.
182 void OnExtensionInstalled(const Extension
* extension
,
183 Extension::State initial_state
,
184 const syncer::StringOrdinal
& page_ordinal
,
186 const std::string
& install_parameter
);
187 // OnExtensionInstalled with no install flags.
188 void OnExtensionInstalled(const Extension
* extension
,
189 Extension::State initial_state
,
190 const syncer::StringOrdinal
& page_ordinal
,
191 const std::string
& install_parameter
) {
192 OnExtensionInstalled(extension
,
199 // Called when an extension is uninstalled, so that prefs get cleaned up.
200 void OnExtensionUninstalled(const std::string
& extension_id
,
201 const Manifest::Location
& location
,
202 bool external_uninstall
);
204 // Called to change the extension's state when it is enabled/disabled.
205 void SetExtensionState(const std::string
& extension_id
, Extension::State
);
207 // Called to change the extension's BlacklistState. Currently only used for
208 // non-malicious extensions.
209 // TODO(oleg): replace SetExtensionBlacklisted by this function.
210 void SetExtensionBlacklistState(const std::string
& extension_id
,
211 BlacklistState state
);
213 // Checks whether |extension_id| is marked as greylisted.
214 // TODO(oleg): Replace IsExtensionBlacklisted by this method.
215 BlacklistState
GetExtensionBlacklistState(const std::string
& extension_id
);
217 // Populates |out| with the ids of all installed extensions.
218 void GetExtensions(ExtensionIdList
* out
);
220 // ExtensionScopedPrefs methods:
221 void UpdateExtensionPref(const std::string
& id
,
222 const std::string
& key
,
223 base::Value
* value
) override
;
225 void DeleteExtensionPrefs(const std::string
& id
) override
;
227 bool ReadPrefAsBoolean(const std::string
& extension_id
,
228 const std::string
& pref_key
,
229 bool* out_value
) const override
;
231 bool ReadPrefAsInteger(const std::string
& extension_id
,
232 const std::string
& pref_key
,
233 int* out_value
) const override
;
235 bool ReadPrefAsString(const std::string
& extension_id
,
236 const std::string
& pref_key
,
237 std::string
* out_value
) const override
;
239 bool ReadPrefAsList(const std::string
& extension_id
,
240 const std::string
& pref_key
,
241 const base::ListValue
** out_value
) const override
;
243 bool ReadPrefAsDictionary(
244 const std::string
& extension_id
,
245 const std::string
& pref_key
,
246 const base::DictionaryValue
** out_value
) const override
;
248 bool HasPrefForExtension(const std::string
& extension_id
) const override
;
250 // Did the extension ask to escalate its permission during an upgrade?
251 bool DidExtensionEscalatePermissions(const std::string
& id
);
253 // If |did_escalate| is true, the preferences for |extension| will be set to
254 // require the install warning when the user tries to enable.
255 void SetDidExtensionEscalatePermissions(
256 const Extension
* extension
,
259 // Getters and setters for disabled reason.
260 int GetDisableReasons(const std::string
& extension_id
) const;
261 bool HasDisableReason(const std::string
& extension_id
,
262 Extension::DisableReason disable_reason
) const;
263 void AddDisableReason(const std::string
& extension_id
,
264 Extension::DisableReason disable_reason
);
265 void RemoveDisableReason(const std::string
& extension_id
,
266 Extension::DisableReason disable_reason
);
267 void ClearDisableReasons(const std::string
& extension_id
);
269 // Gets the set of extensions that have been blacklisted in prefs. This will
270 // return only the blocked extensions, not the "greylist" extensions.
271 // TODO(oleg): Make method names consistent here, in extension service and in
273 std::set
<std::string
> GetBlacklistedExtensions();
275 // Sets whether the extension with |id| is blacklisted.
276 void SetExtensionBlacklisted(const std::string
& extension_id
,
277 bool is_blacklisted
);
279 // Returns the version string for the currently installed extension, or
280 // the empty string if not found.
281 std::string
GetVersionString(const std::string
& extension_id
);
283 // Re-writes the extension manifest into the prefs.
284 // Called to change the extension's manifest when it's re-localized.
285 void UpdateManifest(const Extension
* extension
);
287 // Returns base extensions install directory.
288 const base::FilePath
& install_directory() const { return install_directory_
; }
290 // Returns whether the extension with |id| has its blacklist bit set.
292 // WARNING: this only checks the extension's entry in prefs, so by definition
293 // can only check extensions that prefs knows about. There may be other
294 // sources of blacklist information, such as safebrowsing. You probably want
295 // to use Blacklist::GetBlacklistedIDs rather than this method.
296 bool IsExtensionBlacklisted(const std::string
& id
) const;
298 // Increment the count of how many times we prompted the user to acknowledge
299 // the given extension, and return the new count.
300 int IncrementAcknowledgePromptCount(const std::string
& extension_id
);
302 // Whether the user has acknowledged an external extension.
303 bool IsExternalExtensionAcknowledged(const std::string
& extension_id
);
304 void AcknowledgeExternalExtension(const std::string
& extension_id
);
306 // Whether the user has acknowledged a blacklisted extension.
307 bool IsBlacklistedExtensionAcknowledged(const std::string
& extension_id
);
308 void AcknowledgeBlacklistedExtension(const std::string
& extension_id
);
310 // Whether the external extension was installed during the first run
312 bool IsExternalInstallFirstRun(const std::string
& extension_id
);
313 void SetExternalInstallFirstRun(const std::string
& extension_id
);
315 // Returns true if the extension notification code has already run for the
316 // first time for this profile. Currently we use this flag to mean that any
317 // extensions that would trigger notifications should get silently
318 // acknowledged. This is a fuse. Calling it the first time returns false.
319 // Subsequent calls return true. It's not possible through an API to ever
320 // reset it. Don't call it unless you mean it!
321 bool SetAlertSystemFirstRun();
323 // Returns the last value set via SetLastPingDay. If there isn't such a
324 // pref, the returned Time will return true for is_null().
325 base::Time
LastPingDay(const std::string
& extension_id
) const;
327 // The time stored is based on the server's perspective of day start time, not
329 void SetLastPingDay(const std::string
& extension_id
, const base::Time
& time
);
331 // Similar to the 2 above, but for the extensions blacklist.
332 base::Time
BlacklistLastPingDay() const;
333 void SetBlacklistLastPingDay(const base::Time
& time
);
335 // Similar to LastPingDay/SetLastPingDay, but for sending "days since active"
337 base::Time
LastActivePingDay(const std::string
& extension_id
);
338 void SetLastActivePingDay(const std::string
& extension_id
,
339 const base::Time
& time
);
341 // A bit we use for determining if we should send the "days since active"
342 // ping. A value of true means the item has been active (launched) since the
343 // last update check.
344 bool GetActiveBit(const std::string
& extension_id
);
345 void SetActiveBit(const std::string
& extension_id
, bool active
);
347 // Returns the granted permission set for the extension with |extension_id|,
348 // and NULL if no preferences were found for |extension_id|.
349 // This passes ownership of the returned set to the caller.
350 PermissionSet
* GetGrantedPermissions(const std::string
& extension_id
);
352 // Adds |permissions| to the granted permissions set for the extension with
353 // |extension_id|. The new granted permissions set will be the union of
354 // |permissions| and the already granted permissions.
355 void AddGrantedPermissions(const std::string
& extension_id
,
356 const PermissionSet
* permissions
);
358 // As above, but subtracts the given |permissions| from the granted set.
359 void RemoveGrantedPermissions(const std::string
& extension_id
,
360 const PermissionSet
* permissions
);
362 // Gets the active permission set for the specified extension. This may
363 // differ from the permissions in the manifest due to the optional
364 // permissions API. This passes ownership of the set to the caller.
365 PermissionSet
* GetActivePermissions(const std::string
& extension_id
);
367 // Sets the active |permissions| for the extension with |extension_id|.
368 void SetActivePermissions(const std::string
& extension_id
,
369 const PermissionSet
* permissions
);
371 // Records whether or not this extension is currently running.
372 void SetExtensionRunning(const std::string
& extension_id
, bool is_running
);
374 // Returns whether or not this extension is marked as running. This is used to
375 // restart apps across browser restarts.
376 bool IsExtensionRunning(const std::string
& extension_id
);
378 // Set/Get whether or not the app is active. Used to force a launch of apps
379 // that don't handle onRestarted() on a restart. We can only safely do that if
380 // the app was active when it was last running.
381 void SetIsActive(const std::string
& extension_id
, bool is_active
);
382 bool IsActive(const std::string
& extension_id
);
384 // Returns true if the user enabled this extension to be loaded in incognito
387 // IMPORTANT: you probably want to use extensions::util::IsIncognitoEnabled
388 // instead of this method.
389 bool IsIncognitoEnabled(const std::string
& extension_id
) const;
390 void SetIsIncognitoEnabled(const std::string
& extension_id
, bool enabled
);
392 // Returns true if the user has chosen to allow this extension to inject
393 // scripts into pages with file URLs.
395 // IMPORTANT: you probably want to use extensions::util::AllowFileAccess
396 // instead of this method.
397 bool AllowFileAccess(const std::string
& extension_id
) const;
398 void SetAllowFileAccess(const std::string
& extension_id
, bool allow
);
399 bool HasAllowFileAccessSetting(const std::string
& extension_id
) const;
401 // Saves ExtensionInfo for each installed extension with the path to the
402 // version directory and the location. Blacklisted extensions won't be saved
403 // and neither will external extensions the user has explicitly uninstalled.
404 // Caller takes ownership of returned structure.
405 scoped_ptr
<ExtensionsInfo
> GetInstalledExtensionsInfo() const;
407 // Same as above, but only includes external extensions the user has
408 // explicitly uninstalled.
409 scoped_ptr
<ExtensionsInfo
> GetUninstalledExtensionsInfo() const;
411 // Returns the ExtensionInfo from the prefs for the given extension. If the
412 // extension is not present, NULL is returned.
413 scoped_ptr
<ExtensionInfo
> GetInstalledExtensionInfo(
414 const std::string
& extension_id
) const;
416 // We've downloaded an updated .crx file for the extension, but are waiting
419 // |install_flags| are a bitmask of extension::InstallFlags.
420 void SetDelayedInstallInfo(const Extension
* extension
,
421 Extension::State initial_state
,
423 DelayReason delay_reason
,
424 const syncer::StringOrdinal
& page_ordinal
,
425 const std::string
& install_parameter
);
427 // Removes any delayed install information we have for the given
428 // |extension_id|. Returns true if there was info to remove; false otherwise.
429 bool RemoveDelayedInstallInfo(const std::string
& extension_id
);
431 // Update the prefs to finish the update for an extension.
432 bool FinishDelayedInstallInfo(const std::string
& extension_id
);
434 // Returns the ExtensionInfo from the prefs for delayed install information
435 // for |extension_id|, if we have any. Otherwise returns NULL.
436 scoped_ptr
<ExtensionInfo
> GetDelayedInstallInfo(
437 const std::string
& extension_id
) const;
439 DelayReason
GetDelayedInstallReason(const std::string
& extension_id
) const;
441 // Returns information about all the extensions that have delayed install
443 scoped_ptr
<ExtensionsInfo
> GetAllDelayedInstallInfo() const;
445 // Returns true if the extension is an ephemeral app.
446 bool IsEphemeralApp(const std::string
& extension_id
) const;
448 // Promotes an ephemeral app to a regular installed app.
449 void OnEphemeralAppPromoted(const std::string
& extension_id
);
451 // Returns true if the user repositioned the app on the app launcher via drag
453 bool WasAppDraggedByUser(const std::string
& extension_id
);
455 // Sets a flag indicating that the user repositioned the app on the app
456 // launcher by drag and dropping it.
457 void SetAppDraggedByUser(const std::string
& extension_id
);
459 // Returns true if there is an extension which controls the preference value
460 // for |pref_key| *and* it is specific to incognito mode.
461 bool HasIncognitoPrefValue(const std::string
& pref_key
);
463 // Returns the creation flags mask for the extension.
464 int GetCreationFlags(const std::string
& extension_id
) const;
466 // Returns the creation flags mask for a delayed install extension.
467 int GetDelayedInstallCreationFlags(const std::string
& extension_id
) const;
469 // Returns true if the extension was installed from the Chrome Web Store.
470 bool IsFromWebStore(const std::string
& extension_id
) const;
472 // Returns true if the extension was installed from an App generated from a
474 bool IsFromBookmark(const std::string
& extension_id
) const;
476 // Returns true if the extension was installed as a default app.
477 bool WasInstalledByDefault(const std::string
& extension_id
) const;
479 // Returns true if the extension was installed as an oem app.
480 bool WasInstalledByOem(const std::string
& extension_id
) const;
482 // Helper method to acquire the installation time of an extension.
483 // Returns base::Time() if the installation time could not be parsed or
485 base::Time
GetInstallTime(const std::string
& extension_id
) const;
487 // Returns true if the extension should not be synced.
488 bool DoNotSync(const std::string
& extension_id
) const;
490 // Gets/sets the last launch time of an extension.
491 base::Time
GetLastLaunchTime(const std::string
& extension_id
) const;
492 void SetLastLaunchTime(const std::string
& extension_id
,
493 const base::Time
& time
);
495 // Clear any launch times. This is called by the browsing data remover when
496 // history is cleared.
497 void ClearLastLaunchTimes();
499 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable
* registry
);
501 bool extensions_disabled() const { return extensions_disabled_
; }
503 // The underlying PrefService.
504 PrefService
* pref_service() const { return prefs_
; }
506 // The underlying AppSorting.
507 AppSorting
* app_sorting() const { return app_sorting_
.get(); }
509 // Schedules garbage collection of an extension's on-disk data on the next
510 // start of this ExtensionService. Applies only to extensions with isolated
512 void SetNeedsStorageGarbageCollection(bool value
);
513 bool NeedsStorageGarbageCollection();
515 // Used by AppWindowGeometryCache to persist its cache. These methods
516 // should not be called directly.
517 const base::DictionaryValue
* GetGeometryCache(
518 const std::string
& extension_id
) const;
519 void SetGeometryCache(const std::string
& extension_id
,
520 scoped_ptr
<base::DictionaryValue
> cache
);
522 // Used for verification of installed extension ids. For the Set method, pass
523 // null to remove the preference.
524 const base::DictionaryValue
* GetInstallSignature();
525 void SetInstallSignature(const base::DictionaryValue
* signature
);
527 // The installation parameter associated with the extension.
528 std::string
GetInstallParam(const std::string
& extension_id
) const;
529 void SetInstallParam(const std::string
& extension_id
,
530 const std::string
& install_parameter
);
532 // The total number of times we've disabled an extension due to corrupted
534 int GetCorruptedDisableCount();
535 void IncrementCorruptedDisableCount();
538 friend class ExtensionPrefsBlacklistedExtensions
; // Unit test.
539 friend class ExtensionPrefsComponentExtension
; // Unit test.
540 friend class ExtensionPrefsUninstallExtension
; // Unit test.
542 enum DisableReasonChange
{
544 DISABLE_REASON_REMOVE
,
548 // See the Create methods.
549 ExtensionPrefs(PrefService
* prefs
,
550 const base::FilePath
& root_dir
,
551 ExtensionPrefValueMap
* extension_pref_value_map
,
552 scoped_ptr
<AppSorting
> app_sorting
,
553 scoped_ptr
<TimeProvider
> time_provider
,
554 bool extensions_disabled
,
555 const std::vector
<ExtensionPrefsObserver
*>& early_observers
);
557 // Converts absolute paths in the pref to paths relative to the
558 // install_directory_.
559 void MakePathsRelative();
561 // Converts internal relative paths to be absolute. Used for export to
562 // consumers who expect full paths.
563 void MakePathsAbsolute(base::DictionaryValue
* dict
);
565 // Helper function used by GetInstalledExtensionInfo() and
566 // GetDelayedInstallInfo() to construct an ExtensionInfo from the provided
567 // |extension| dictionary.
568 scoped_ptr
<ExtensionInfo
> GetInstalledInfoHelper(
569 const std::string
& extension_id
,
570 const base::DictionaryValue
* extension
) const;
572 // Interprets the list pref, |pref_key| in |extension_id|'s preferences, as a
573 // URLPatternSet. The |valid_schemes| specify how to parse the URLPatterns.
574 bool ReadPrefAsURLPatternSet(const std::string
& extension_id
,
575 const std::string
& pref_key
,
576 URLPatternSet
* result
,
579 // Converts |new_value| to a list of strings and sets the |pref_key| pref
580 // belonging to |extension_id|.
581 void SetExtensionPrefURLPatternSet(const std::string
& extension_id
,
582 const std::string
& pref_key
,
583 const URLPatternSet
& new_value
);
585 // Read the boolean preference entry and return true if the preference exists
586 // and the preference's value is true; false otherwise.
587 bool ReadPrefAsBooleanAndReturn(const std::string
& extension_id
,
588 const std::string
& key
) const;
590 // Interprets |pref_key| in |extension_id|'s preferences as an
591 // PermissionSet, and passes ownership of the set to the caller.
592 PermissionSet
* ReadPrefAsPermissionSet(const std::string
& extension_id
,
593 const std::string
& pref_key
);
595 // Converts the |new_value| to its value and sets the |pref_key| pref
596 // belonging to |extension_id|.
597 void SetExtensionPrefPermissionSet(const std::string
& extension_id
,
598 const std::string
& pref_key
,
599 const PermissionSet
* new_value
);
601 // Returns an immutable dictionary for extension |id|'s prefs, or NULL if it
603 const base::DictionaryValue
* GetExtensionPref(const std::string
& id
) const;
605 // Modifies the extensions disable reasons to add a new reason, remove an
606 // existing reason, or clear all reasons. Notifies observers if the set of
607 // DisableReasons has changed.
608 // If |change| is DISABLE_REASON_CLEAR, then |reason| is ignored.
609 void ModifyDisableReasons(const std::string
& extension_id
,
611 DisableReasonChange change
);
613 // Fix missing preference entries in the extensions that are were introduced
614 // in a later Chrome version.
615 void FixMissingPrefs(const ExtensionIdList
& extension_ids
);
617 // Installs the persistent extension preferences into |prefs_|'s extension
618 // pref store. Does nothing if extensions_disabled_ is true.
619 void InitPrefStore();
621 // Migrates the permissions data in the pref store.
622 void MigratePermissions(const ExtensionIdList
& extension_ids
);
624 // Migrates the disable reasons from a single enum to a bit mask.
625 void MigrateDisableReasons(const ExtensionIdList
& extension_ids
);
627 // Checks whether there is a state pref for the extension and if so, whether
628 // it matches |check_state|.
629 bool DoesExtensionHaveState(const std::string
& id
,
630 Extension::State check_state
) const;
632 // Reads the list of strings for |pref| from user prefs into
633 // |id_container_out|. Returns false if the pref wasn't found in the user
635 template <class ExtensionIdContainer
>
636 bool GetUserExtensionPrefIntoContainer(
638 ExtensionIdContainer
* id_container_out
);
640 // Writes the list of strings contained in |strings| to |pref| in prefs.
641 template <class ExtensionIdContainer
>
642 void SetExtensionPrefFromContainer(const char* pref
,
643 const ExtensionIdContainer
& strings
);
645 // Helper function to populate |extension_dict| with the values needed
646 // by a newly installed extension. Work is broken up between this
647 // function and FinishExtensionInfoPrefs() to accomodate delayed
650 // |install_flags| are a bitmask of extension::InstallFlags.
651 void PopulateExtensionInfoPrefs(const Extension
* extension
,
652 const base::Time install_time
,
653 Extension::State initial_state
,
655 const std::string
& install_parameter
,
656 base::DictionaryValue
* extension_dict
);
658 void InitExtensionControlledPrefs(ExtensionPrefValueMap
* value_map
);
660 // Helper function to complete initialization of the values in
661 // |extension_dict| for an extension install. Also see
662 // PopulateExtensionInfoPrefs().
663 void FinishExtensionInfoPrefs(
664 const std::string
& extension_id
,
665 const base::Time install_time
,
666 bool needs_sort_ordinal
,
667 const syncer::StringOrdinal
& suggested_page_ordinal
,
668 base::DictionaryValue
* extension_dict
);
670 // The pref service specific to this set of extension prefs. Owned by the
674 // Base extensions install directory.
675 base::FilePath install_directory_
;
677 // Weak pointer, owned by BrowserContext.
678 ExtensionPrefValueMap
* extension_pref_value_map_
;
680 // Contains all the logic for handling the order for various extension
682 scoped_ptr
<AppSorting
> app_sorting_
;
684 scoped_ptr
<TimeProvider
> time_provider_
;
686 bool extensions_disabled_
;
688 ObserverList
<ExtensionPrefsObserver
> observer_list_
;
690 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs
);
693 } // namespace extensions
695 #endif // EXTENSIONS_BROWSER_EXTENSION_PREFS_H_