OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ | 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ |
6 #define EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ | 6 #define EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // Creates an ExtensionPrefs object. | 127 // Creates an ExtensionPrefs object. |
128 // Does not take ownership of |prefs| or |extension_pref_value_map|. | 128 // Does not take ownership of |prefs| or |extension_pref_value_map|. |
129 // If |extensions_disabled| is true, extension controlled preferences and | 129 // If |extensions_disabled| is true, extension controlled preferences and |
130 // content settings do not become effective. ExtensionPrefsObservers should be | 130 // content settings do not become effective. ExtensionPrefsObservers should be |
131 // included in |early_observers| if they need to observe events which occur | 131 // included in |early_observers| if they need to observe events which occur |
132 // during initialization of the ExtensionPrefs object. | 132 // during initialization of the ExtensionPrefs object. |
133 static ExtensionPrefs* Create( | 133 static ExtensionPrefs* Create( |
134 PrefService* prefs, | 134 PrefService* prefs, |
135 const base::FilePath& root_dir, | 135 const base::FilePath& root_dir, |
136 ExtensionPrefValueMap* extension_pref_value_map, | 136 ExtensionPrefValueMap* extension_pref_value_map, |
137 scoped_ptr<AppSorting> app_sorting, | |
138 bool extensions_disabled, | 137 bool extensions_disabled, |
139 const std::vector<ExtensionPrefsObserver*>& early_observers); | 138 const std::vector<ExtensionPrefsObserver*>& early_observers); |
140 | 139 |
141 // A version of Create which allows injection of a custom base::Time provider. | 140 // A version of Create which allows injection of a custom base::Time provider. |
142 // Use this as needed for testing. | 141 // Use this as needed for testing. |
143 static ExtensionPrefs* Create( | 142 static ExtensionPrefs* Create( |
144 PrefService* prefs, | 143 PrefService* prefs, |
145 const base::FilePath& root_dir, | 144 const base::FilePath& root_dir, |
146 ExtensionPrefValueMap* extension_pref_value_map, | 145 ExtensionPrefValueMap* extension_pref_value_map, |
147 scoped_ptr<AppSorting> app_sorting, | |
148 bool extensions_disabled, | 146 bool extensions_disabled, |
149 const std::vector<ExtensionPrefsObserver*>& early_observers, | 147 const std::vector<ExtensionPrefsObserver*>& early_observers, |
150 scoped_ptr<TimeProvider> time_provider); | 148 scoped_ptr<TimeProvider> time_provider); |
151 | 149 |
152 ~ExtensionPrefs() override; | 150 ~ExtensionPrefs() override; |
153 | 151 |
154 // Convenience function to get the ExtensionPrefs for a BrowserContext. | 152 // Convenience function to get the ExtensionPrefs for a BrowserContext. |
155 static ExtensionPrefs* Get(content::BrowserContext* context); | 153 static ExtensionPrefs* Get(content::BrowserContext* context); |
156 | 154 |
| 155 // Set an ExtensionPrefs instance to be returned from Get() above. |
| 156 static void SetInstanceForTesting(ExtensionPrefs* prefs); |
| 157 |
157 // Returns all installed extensions from extension preferences provided by | 158 // Returns all installed extensions from extension preferences provided by |
158 // |pref_service|. This is exposed for ProtectedPrefsWatcher because it needs | 159 // |pref_service|. This is exposed for ProtectedPrefsWatcher because it needs |
159 // access to the extension ID list before the ExtensionService is initialized. | 160 // access to the extension ID list before the ExtensionService is initialized. |
160 static ExtensionIdList GetExtensionsFrom(const PrefService* pref_service); | 161 static ExtensionIdList GetExtensionsFrom(const PrefService* pref_service); |
161 | 162 |
162 // Add or remove an observer from the ExtensionPrefs. | 163 // Add or remove an observer from the ExtensionPrefs. |
163 void AddObserver(ExtensionPrefsObserver* observer); | 164 void AddObserver(ExtensionPrefsObserver* observer); |
164 void RemoveObserver(ExtensionPrefsObserver* observer); | 165 void RemoveObserver(ExtensionPrefsObserver* observer); |
165 | 166 |
166 // Returns true if the specified external extension was uninstalled by the | 167 // Returns true if the specified external extension was uninstalled by the |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 void ClearLastLaunchTimes(); | 495 void ClearLastLaunchTimes(); |
495 | 496 |
496 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 497 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
497 | 498 |
498 bool extensions_disabled() const { return extensions_disabled_; } | 499 bool extensions_disabled() const { return extensions_disabled_; } |
499 | 500 |
500 // The underlying PrefService. | 501 // The underlying PrefService. |
501 PrefService* pref_service() const { return prefs_; } | 502 PrefService* pref_service() const { return prefs_; } |
502 | 503 |
503 // The underlying AppSorting. | 504 // The underlying AppSorting. |
504 AppSorting* app_sorting() const { return app_sorting_.get(); } | 505 void set_app_sorting(AppSorting* app_sorting) { app_sorting_ = app_sorting; } |
| 506 AppSorting* app_sorting() const { return app_sorting_; } |
505 | 507 |
506 // Schedules garbage collection of an extension's on-disk data on the next | 508 // 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 // start of this ExtensionService. Applies only to extensions with isolated |
508 // storage. | 510 // storage. |
509 void SetNeedsStorageGarbageCollection(bool value); | 511 void SetNeedsStorageGarbageCollection(bool value); |
510 bool NeedsStorageGarbageCollection() const; | 512 bool NeedsStorageGarbageCollection() const; |
511 | 513 |
512 // Used by AppWindowGeometryCache to persist its cache. These methods | 514 // Used by AppWindowGeometryCache to persist its cache. These methods |
513 // should not be called directly. | 515 // should not be called directly. |
514 const base::DictionaryValue* GetGeometryCache( | 516 const base::DictionaryValue* GetGeometryCache( |
(...skipping 30 matching lines...) Expand all Loading... |
545 enum DisableReasonChange { | 547 enum DisableReasonChange { |
546 DISABLE_REASON_ADD, | 548 DISABLE_REASON_ADD, |
547 DISABLE_REASON_REMOVE, | 549 DISABLE_REASON_REMOVE, |
548 DISABLE_REASON_CLEAR | 550 DISABLE_REASON_CLEAR |
549 }; | 551 }; |
550 | 552 |
551 // See the Create methods. | 553 // See the Create methods. |
552 ExtensionPrefs(PrefService* prefs, | 554 ExtensionPrefs(PrefService* prefs, |
553 const base::FilePath& root_dir, | 555 const base::FilePath& root_dir, |
554 ExtensionPrefValueMap* extension_pref_value_map, | 556 ExtensionPrefValueMap* extension_pref_value_map, |
555 scoped_ptr<AppSorting> app_sorting, | |
556 scoped_ptr<TimeProvider> time_provider, | 557 scoped_ptr<TimeProvider> time_provider, |
557 bool extensions_disabled, | 558 bool extensions_disabled, |
558 const std::vector<ExtensionPrefsObserver*>& early_observers); | 559 const std::vector<ExtensionPrefsObserver*>& early_observers); |
559 | 560 |
560 // Converts absolute paths in the pref to paths relative to the | 561 // Converts absolute paths in the pref to paths relative to the |
561 // install_directory_. | 562 // install_directory_. |
562 void MakePathsRelative(); | 563 void MakePathsRelative(); |
563 | 564 |
564 // Converts internal relative paths to be absolute. Used for export to | 565 // Converts internal relative paths to be absolute. Used for export to |
565 // consumers who expect full paths. | 566 // consumers who expect full paths. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 PrefService* prefs_; | 676 PrefService* prefs_; |
676 | 677 |
677 // Base extensions install directory. | 678 // Base extensions install directory. |
678 base::FilePath install_directory_; | 679 base::FilePath install_directory_; |
679 | 680 |
680 // Weak pointer, owned by BrowserContext. | 681 // Weak pointer, owned by BrowserContext. |
681 ExtensionPrefValueMap* extension_pref_value_map_; | 682 ExtensionPrefValueMap* extension_pref_value_map_; |
682 | 683 |
683 // Contains all the logic for handling the order for various extension | 684 // Contains all the logic for handling the order for various extension |
684 // properties. | 685 // properties. |
685 scoped_ptr<AppSorting> app_sorting_; | 686 AppSorting* app_sorting_; |
686 | 687 |
687 scoped_ptr<TimeProvider> time_provider_; | 688 scoped_ptr<TimeProvider> time_provider_; |
688 | 689 |
689 bool extensions_disabled_; | 690 bool extensions_disabled_; |
690 | 691 |
691 base::ObserverList<ExtensionPrefsObserver> observer_list_; | 692 base::ObserverList<ExtensionPrefsObserver> observer_list_; |
692 | 693 |
693 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); | 694 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); |
694 }; | 695 }; |
695 | 696 |
696 } // namespace extensions | 697 } // namespace extensions |
697 | 698 |
698 #endif // EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ | 699 #endif // EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ |
OLD | NEW |