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 AddDisableReasons(const std::string
& extension_id
, int disable_reasons
);
266 void RemoveDisableReason(const std::string
& extension_id
,
267 Extension::DisableReason disable_reason
);
268 void ClearDisableReasons(const std::string
& extension_id
);
270 // Gets the set of extensions that have been blacklisted in prefs. This will
271 // return only the blocked extensions, not the "greylist" extensions.
272 // TODO(oleg): Make method names consistent here, in extension service and in
274 std::set
<std::string
> GetBlacklistedExtensions();
276 // Sets whether the extension with |id| is blacklisted.
277 void SetExtensionBlacklisted(const std::string
& extension_id
,
278 bool is_blacklisted
);
280 // Returns the version string for the currently installed extension, or
281 // the empty string if not found.
282 std::string
GetVersionString(const std::string
& extension_id
);
284 // Re-writes the extension manifest into the prefs.
285 // Called to change the extension's manifest when it's re-localized.
286 void UpdateManifest(const Extension
* extension
);
288 // Returns base extensions install directory.
289 const base::FilePath
& install_directory() const { return install_directory_
; }
291 // Returns whether the extension with |id| has its blacklist bit set.
293 // WARNING: this only checks the extension's entry in prefs, so by definition
294 // can only check extensions that prefs knows about. There may be other
295 // sources of blacklist information, such as safebrowsing. You probably want
296 // to use Blacklist::GetBlacklistedIDs rather than this method.
297 bool IsExtensionBlacklisted(const std::string
& id
) const;
299 // Increment the count of how many times we prompted the user to acknowledge
300 // the given extension, and return the new count.
301 int IncrementAcknowledgePromptCount(const std::string
& extension_id
);
303 // Whether the user has acknowledged an external extension.
304 bool IsExternalExtensionAcknowledged(const std::string
& extension_id
);
305 void AcknowledgeExternalExtension(const std::string
& extension_id
);
307 // Whether the user has acknowledged a blacklisted extension.
308 bool IsBlacklistedExtensionAcknowledged(const std::string
& extension_id
);
309 void AcknowledgeBlacklistedExtension(const std::string
& extension_id
);
311 // Whether the external extension was installed during the first run
313 bool IsExternalInstallFirstRun(const std::string
& extension_id
);
314 void SetExternalInstallFirstRun(const std::string
& extension_id
);
316 // Returns true if the extension notification code has already run for the
317 // first time for this profile. Currently we use this flag to mean that any
318 // extensions that would trigger notifications should get silently
319 // acknowledged. This is a fuse. Calling it the first time returns false.
320 // Subsequent calls return true. It's not possible through an API to ever
321 // reset it. Don't call it unless you mean it!
322 bool SetAlertSystemFirstRun();
324 // Returns the last value set via SetLastPingDay. If there isn't such a
325 // pref, the returned Time will return true for is_null().
326 base::Time
LastPingDay(const std::string
& extension_id
) const;
328 // The time stored is based on the server's perspective of day start time, not
330 void SetLastPingDay(const std::string
& extension_id
, const base::Time
& time
);
332 // Similar to the 2 above, but for the extensions blacklist.
333 base::Time
BlacklistLastPingDay() const;
334 void SetBlacklistLastPingDay(const base::Time
& time
);
336 // Similar to LastPingDay/SetLastPingDay, but for sending "days since active"
338 base::Time
LastActivePingDay(const std::string
& extension_id
);
339 void SetLastActivePingDay(const std::string
& extension_id
,
340 const base::Time
& time
);
342 // A bit we use for determining if we should send the "days since active"
343 // ping. A value of true means the item has been active (launched) since the
344 // last update check.
345 bool GetActiveBit(const std::string
& extension_id
);
346 void SetActiveBit(const std::string
& extension_id
, bool active
);
348 // Returns the granted permission set for the extension with |extension_id|,
349 // and NULL if no preferences were found for |extension_id|.
350 // This passes ownership of the returned set to the caller.
351 PermissionSet
* GetGrantedPermissions(const std::string
& extension_id
);
353 // Adds |permissions| to the granted permissions set for the extension with
354 // |extension_id|. The new granted permissions set will be the union of
355 // |permissions| and the already granted permissions.
356 void AddGrantedPermissions(const std::string
& extension_id
,
357 const PermissionSet
* permissions
);
359 // As above, but subtracts the given |permissions| from the granted set.
360 void RemoveGrantedPermissions(const std::string
& extension_id
,
361 const PermissionSet
* permissions
);
363 // Gets the active permission set for the specified extension. This may
364 // differ from the permissions in the manifest due to the optional
365 // permissions API. This passes ownership of the set to the caller.
366 PermissionSet
* GetActivePermissions(const std::string
& extension_id
);
368 // Sets the active |permissions| for the extension with |extension_id|.
369 void SetActivePermissions(const std::string
& extension_id
,
370 const PermissionSet
* permissions
);
372 // Records whether or not this extension is currently running.
373 void SetExtensionRunning(const std::string
& extension_id
, bool is_running
);
375 // Returns whether or not this extension is marked as running. This is used to
376 // restart apps across browser restarts.
377 bool IsExtensionRunning(const std::string
& extension_id
);
379 // Set/Get whether or not the app is active. Used to force a launch of apps
380 // that don't handle onRestarted() on a restart. We can only safely do that if
381 // the app was active when it was last running.
382 void SetIsActive(const std::string
& extension_id
, bool is_active
);
383 bool IsActive(const std::string
& extension_id
);
385 // Returns true if the user enabled this extension to be loaded in incognito
388 // IMPORTANT: you probably want to use extensions::util::IsIncognitoEnabled
389 // instead of this method.
390 bool IsIncognitoEnabled(const std::string
& extension_id
) const;
391 void SetIsIncognitoEnabled(const std::string
& extension_id
, bool enabled
);
393 // Returns true if the user has chosen to allow this extension to inject
394 // scripts into pages with file URLs.
396 // IMPORTANT: you probably want to use extensions::util::AllowFileAccess
397 // instead of this method.
398 bool AllowFileAccess(const std::string
& extension_id
) const;
399 void SetAllowFileAccess(const std::string
& extension_id
, bool allow
);
400 bool HasAllowFileAccessSetting(const std::string
& extension_id
) const;
402 // Saves ExtensionInfo for each installed extension with the path to the
403 // version directory and the location. Blacklisted extensions won't be saved
404 // and neither will external extensions the user has explicitly uninstalled.
405 // Caller takes ownership of returned structure.
406 scoped_ptr
<ExtensionsInfo
> GetInstalledExtensionsInfo() const;
408 // Same as above, but only includes external extensions the user has
409 // explicitly uninstalled.
410 scoped_ptr
<ExtensionsInfo
> GetUninstalledExtensionsInfo() const;
412 // Returns the ExtensionInfo from the prefs for the given extension. If the
413 // extension is not present, NULL is returned.
414 scoped_ptr
<ExtensionInfo
> GetInstalledExtensionInfo(
415 const std::string
& extension_id
) const;
417 // We've downloaded an updated .crx file for the extension, but are waiting
420 // |install_flags| are a bitmask of extension::InstallFlags.
421 void SetDelayedInstallInfo(const Extension
* extension
,
422 Extension::State initial_state
,
424 DelayReason delay_reason
,
425 const syncer::StringOrdinal
& page_ordinal
,
426 const std::string
& install_parameter
);
428 // Removes any delayed install information we have for the given
429 // |extension_id|. Returns true if there was info to remove; false otherwise.
430 bool RemoveDelayedInstallInfo(const std::string
& extension_id
);
432 // Update the prefs to finish the update for an extension.
433 bool FinishDelayedInstallInfo(const std::string
& extension_id
);
435 // Returns the ExtensionInfo from the prefs for delayed install information
436 // for |extension_id|, if we have any. Otherwise returns NULL.
437 scoped_ptr
<ExtensionInfo
> GetDelayedInstallInfo(
438 const std::string
& extension_id
) const;
440 DelayReason
GetDelayedInstallReason(const std::string
& extension_id
) const;
442 // Returns information about all the extensions that have delayed install
444 scoped_ptr
<ExtensionsInfo
> GetAllDelayedInstallInfo() const;
446 // Returns true if the extension is an ephemeral app.
447 bool IsEphemeralApp(const std::string
& extension_id
) const;
449 // Promotes an ephemeral app to a regular installed app.
450 void OnEphemeralAppPromoted(const std::string
& extension_id
);
452 // Returns true if the user repositioned the app on the app launcher via drag
454 bool WasAppDraggedByUser(const std::string
& extension_id
);
456 // Sets a flag indicating that the user repositioned the app on the app
457 // launcher by drag and dropping it.
458 void SetAppDraggedByUser(const std::string
& extension_id
);
460 // Returns true if there is an extension which controls the preference value
461 // for |pref_key| *and* it is specific to incognito mode.
462 bool HasIncognitoPrefValue(const std::string
& pref_key
);
464 // Returns the creation flags mask for the extension.
465 int GetCreationFlags(const std::string
& extension_id
) const;
467 // Returns the creation flags mask for a delayed install extension.
468 int GetDelayedInstallCreationFlags(const std::string
& extension_id
) const;
470 // Returns true if the extension was installed from the Chrome Web Store.
471 bool IsFromWebStore(const std::string
& extension_id
) const;
473 // Returns true if the extension was installed from an App generated from a
475 bool IsFromBookmark(const std::string
& extension_id
) const;
477 // Returns true if the extension was installed as a default app.
478 bool WasInstalledByDefault(const std::string
& extension_id
) const;
480 // Returns true if the extension was installed as an oem app.
481 bool WasInstalledByOem(const std::string
& extension_id
) const;
483 // Helper method to acquire the installation time of an extension.
484 // Returns base::Time() if the installation time could not be parsed or
486 base::Time
GetInstallTime(const std::string
& extension_id
) const;
488 // Returns true if the extension should not be synced.
489 bool DoNotSync(const std::string
& extension_id
) const;
491 // Gets/sets the last launch time of an extension.
492 base::Time
GetLastLaunchTime(const std::string
& extension_id
) const;
493 void SetLastLaunchTime(const std::string
& extension_id
,
494 const base::Time
& time
);
496 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable
* registry
);
498 bool extensions_disabled() const { return extensions_disabled_
; }
500 // The underlying PrefService.
501 PrefService
* pref_service() const { return prefs_
; }
503 // The underlying AppSorting.
504 AppSorting
* app_sorting() const { return app_sorting_
.get(); }
506 // Schedules garbage collection of an extension's on-disk data on the next
507 // start of this ExtensionService. Applies only to extensions with isolated
509 void SetNeedsStorageGarbageCollection(bool value
);
510 bool NeedsStorageGarbageCollection();
512 // Used by AppWindowGeometryCache to persist its cache. These methods
513 // should not be called directly.
514 const base::DictionaryValue
* GetGeometryCache(
515 const std::string
& extension_id
) const;
516 void SetGeometryCache(const std::string
& extension_id
,
517 scoped_ptr
<base::DictionaryValue
> cache
);
519 // Used for verification of installed extension ids. For the Set method, pass
520 // null to remove the preference.
521 const base::DictionaryValue
* GetInstallSignature();
522 void SetInstallSignature(const base::DictionaryValue
* signature
);
524 // The installation parameter associated with the extension.
525 std::string
GetInstallParam(const std::string
& extension_id
) const;
526 void SetInstallParam(const std::string
& extension_id
,
527 const std::string
& install_parameter
);
529 // The total number of times we've disabled an extension due to corrupted
531 int GetCorruptedDisableCount();
532 void IncrementCorruptedDisableCount();
535 friend class ExtensionPrefsBlacklistedExtensions
; // Unit test.
536 friend class ExtensionPrefsUninstallExtension
; // Unit test.
538 enum DisableReasonChange
{
540 DISABLE_REASON_REMOVE
,
544 // See the Create methods.
545 ExtensionPrefs(PrefService
* prefs
,
546 const base::FilePath
& root_dir
,
547 ExtensionPrefValueMap
* extension_pref_value_map
,
548 scoped_ptr
<AppSorting
> app_sorting
,
549 scoped_ptr
<TimeProvider
> time_provider
,
550 bool extensions_disabled
,
551 const std::vector
<ExtensionPrefsObserver
*>& early_observers
);
553 // Converts absolute paths in the pref to paths relative to the
554 // install_directory_.
555 void MakePathsRelative();
557 // Converts internal relative paths to be absolute. Used for export to
558 // consumers who expect full paths.
559 void MakePathsAbsolute(base::DictionaryValue
* dict
);
561 // Helper function used by GetInstalledExtensionInfo() and
562 // GetDelayedInstallInfo() to construct an ExtensionInfo from the provided
563 // |extension| dictionary.
564 scoped_ptr
<ExtensionInfo
> GetInstalledInfoHelper(
565 const std::string
& extension_id
,
566 const base::DictionaryValue
* extension
) const;
568 // Interprets the list pref, |pref_key| in |extension_id|'s preferences, as a
569 // URLPatternSet. The |valid_schemes| specify how to parse the URLPatterns.
570 bool ReadPrefAsURLPatternSet(const std::string
& extension_id
,
571 const std::string
& pref_key
,
572 URLPatternSet
* result
,
575 // Converts |new_value| to a list of strings and sets the |pref_key| pref
576 // belonging to |extension_id|.
577 void SetExtensionPrefURLPatternSet(const std::string
& extension_id
,
578 const std::string
& pref_key
,
579 const URLPatternSet
& new_value
);
581 // Read the boolean preference entry and return true if the preference exists
582 // and the preference's value is true; false otherwise.
583 bool ReadPrefAsBooleanAndReturn(const std::string
& extension_id
,
584 const std::string
& key
) const;
586 // Interprets |pref_key| in |extension_id|'s preferences as an
587 // PermissionSet, and passes ownership of the set to the caller.
588 PermissionSet
* ReadPrefAsPermissionSet(const std::string
& extension_id
,
589 const std::string
& pref_key
);
591 // Converts the |new_value| to its value and sets the |pref_key| pref
592 // belonging to |extension_id|.
593 void SetExtensionPrefPermissionSet(const std::string
& extension_id
,
594 const std::string
& pref_key
,
595 const PermissionSet
* new_value
);
597 // Returns an immutable dictionary for extension |id|'s prefs, or NULL if it
599 const base::DictionaryValue
* GetExtensionPref(const std::string
& id
) const;
601 // Modifies the extensions disable reasons to add a new reason, remove an
602 // existing reason, or clear all reasons. Notifies observers if the set of
603 // DisableReasons has changed.
604 // If |change| is DISABLE_REASON_CLEAR, then |reason| is ignored.
605 void ModifyDisableReasons(const std::string
& extension_id
,
607 DisableReasonChange change
);
609 // Fix missing preference entries in the extensions that are were introduced
610 // in a later Chrome version.
611 void FixMissingPrefs(const ExtensionIdList
& extension_ids
);
613 // Installs the persistent extension preferences into |prefs_|'s extension
614 // pref store. Does nothing if extensions_disabled_ is true.
615 void InitPrefStore();
617 // Migrates the permissions data in the pref store.
618 void MigratePermissions(const ExtensionIdList
& extension_ids
);
620 // Migrates the disable reasons from a single enum to a bit mask.
621 void MigrateDisableReasons(const ExtensionIdList
& extension_ids
);
623 // Checks whether there is a state pref for the extension and if so, whether
624 // it matches |check_state|.
625 bool DoesExtensionHaveState(const std::string
& id
,
626 Extension::State check_state
) const;
628 // Reads the list of strings for |pref| from user prefs into
629 // |id_container_out|. Returns false if the pref wasn't found in the user
631 template <class ExtensionIdContainer
>
632 bool GetUserExtensionPrefIntoContainer(
634 ExtensionIdContainer
* id_container_out
);
636 // Writes the list of strings contained in |strings| to |pref| in prefs.
637 template <class ExtensionIdContainer
>
638 void SetExtensionPrefFromContainer(const char* pref
,
639 const ExtensionIdContainer
& strings
);
641 // Helper function to populate |extension_dict| with the values needed
642 // by a newly installed extension. Work is broken up between this
643 // function and FinishExtensionInfoPrefs() to accomodate delayed
646 // |install_flags| are a bitmask of extension::InstallFlags.
647 void PopulateExtensionInfoPrefs(const Extension
* extension
,
648 const base::Time install_time
,
649 Extension::State initial_state
,
651 const std::string
& install_parameter
,
652 base::DictionaryValue
* extension_dict
);
654 void InitExtensionControlledPrefs(ExtensionPrefValueMap
* value_map
);
656 // Helper function to complete initialization of the values in
657 // |extension_dict| for an extension install. Also see
658 // PopulateExtensionInfoPrefs().
659 void FinishExtensionInfoPrefs(
660 const std::string
& extension_id
,
661 const base::Time install_time
,
662 bool needs_sort_ordinal
,
663 const syncer::StringOrdinal
& suggested_page_ordinal
,
664 base::DictionaryValue
* extension_dict
);
666 // The pref service specific to this set of extension prefs. Owned by the
670 // Base extensions install directory.
671 base::FilePath install_directory_
;
673 // Weak pointer, owned by BrowserContext.
674 ExtensionPrefValueMap
* extension_pref_value_map_
;
676 // Contains all the logic for handling the order for various extension
678 scoped_ptr
<AppSorting
> app_sorting_
;
680 scoped_ptr
<TimeProvider
> time_provider_
;
682 bool extensions_disabled_
;
684 ObserverList
<ExtensionPrefsObserver
> observer_list_
;
686 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs
);
689 } // namespace extensions
691 #endif // EXTENSIONS_BROWSER_EXTENSION_PREFS_H_