| 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> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "base/prefs/scoped_user_pref_update.h" | 16 #include "base/prefs/scoped_user_pref_update.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "components/keyed_service/core/keyed_service.h" | 19 #include "components/keyed_service/core/keyed_service.h" |
| 20 #include "extensions/browser/app_sorting.h" | |
| 21 #include "extensions/browser/blacklist_state.h" | 20 #include "extensions/browser/blacklist_state.h" |
| 22 #include "extensions/browser/extension_scoped_prefs.h" | 21 #include "extensions/browser/extension_scoped_prefs.h" |
| 23 #include "extensions/browser/install_flag.h" | 22 #include "extensions/browser/install_flag.h" |
| 24 #include "extensions/common/constants.h" | 23 #include "extensions/common/constants.h" |
| 25 #include "extensions/common/extension.h" | 24 #include "extensions/common/extension.h" |
| 26 #include "extensions/common/url_pattern_set.h" | 25 #include "extensions/common/url_pattern_set.h" |
| 27 #include "sync/api/string_ordinal.h" | 26 #include "sync/api/string_ordinal.h" |
| 28 | 27 |
| 29 class ExtensionPrefValueMap; | 28 class ExtensionPrefValueMap; |
| 30 class PrefService; | 29 class PrefService; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 typedef ScopedUpdate<base::ListValue, base::Value::TYPE_LIST> | 123 typedef ScopedUpdate<base::ListValue, base::Value::TYPE_LIST> |
| 125 ScopedListUpdate; | 124 ScopedListUpdate; |
| 126 | 125 |
| 127 // Creates an ExtensionPrefs object. | 126 // Creates an ExtensionPrefs object. |
| 128 // Does not take ownership of |prefs| or |extension_pref_value_map|. | 127 // Does not take ownership of |prefs| or |extension_pref_value_map|. |
| 129 // If |extensions_disabled| is true, extension controlled preferences and | 128 // If |extensions_disabled| is true, extension controlled preferences and |
| 130 // content settings do not become effective. ExtensionPrefsObservers should be | 129 // content settings do not become effective. ExtensionPrefsObservers should be |
| 131 // included in |early_observers| if they need to observe events which occur | 130 // included in |early_observers| if they need to observe events which occur |
| 132 // during initialization of the ExtensionPrefs object. | 131 // during initialization of the ExtensionPrefs object. |
| 133 static ExtensionPrefs* Create( | 132 static ExtensionPrefs* Create( |
| 133 content::BrowserContext* browser_context, |
| 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( |
| 143 content::BrowserContext* browser_context, |
| 144 PrefService* prefs, | 144 PrefService* prefs, |
| 145 const base::FilePath& root_dir, | 145 const base::FilePath& root_dir, |
| 146 ExtensionPrefValueMap* extension_pref_value_map, | 146 ExtensionPrefValueMap* extension_pref_value_map, |
| 147 scoped_ptr<AppSorting> app_sorting, | |
| 148 bool extensions_disabled, | 147 bool extensions_disabled, |
| 149 const std::vector<ExtensionPrefsObserver*>& early_observers, | 148 const std::vector<ExtensionPrefsObserver*>& early_observers, |
| 150 scoped_ptr<TimeProvider> time_provider); | 149 scoped_ptr<TimeProvider> time_provider); |
| 151 | 150 |
| 152 ~ExtensionPrefs() override; | 151 ~ExtensionPrefs() override; |
| 153 | 152 |
| 154 // Convenience function to get the ExtensionPrefs for a BrowserContext. | 153 // Convenience function to get the ExtensionPrefs for a BrowserContext. |
| 155 static ExtensionPrefs* Get(content::BrowserContext* context); | 154 static ExtensionPrefs* Get(content::BrowserContext* context); |
| 156 | 155 |
| 157 // Returns all installed extensions from extension preferences provided by | 156 // Returns all installed extensions from extension preferences provided by |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 void ClearLastLaunchTimes(); | 493 void ClearLastLaunchTimes(); |
| 495 | 494 |
| 496 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 495 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 497 | 496 |
| 498 bool extensions_disabled() const { return extensions_disabled_; } | 497 bool extensions_disabled() const { return extensions_disabled_; } |
| 499 | 498 |
| 500 // The underlying PrefService. | 499 // The underlying PrefService. |
| 501 PrefService* pref_service() const { return prefs_; } | 500 PrefService* pref_service() const { return prefs_; } |
| 502 | 501 |
| 503 // The underlying AppSorting. | 502 // The underlying AppSorting. |
| 504 AppSorting* app_sorting() const { return app_sorting_.get(); } | 503 // TODO(treib,kalman): This should be private, and all callers should go |
| 504 // through the ExtensionSystem instead. |
| 505 AppSorting* app_sorting() const; |
| 505 | 506 |
| 506 // Schedules garbage collection of an extension's on-disk data on the next | 507 // Schedules garbage collection of an extension's on-disk data on the next |
| 507 // start of this ExtensionService. Applies only to extensions with isolated | 508 // start of this ExtensionService. Applies only to extensions with isolated |
| 508 // storage. | 509 // storage. |
| 509 void SetNeedsStorageGarbageCollection(bool value); | 510 void SetNeedsStorageGarbageCollection(bool value); |
| 510 bool NeedsStorageGarbageCollection() const; | 511 bool NeedsStorageGarbageCollection() const; |
| 511 | 512 |
| 512 // Used by AppWindowGeometryCache to persist its cache. These methods | 513 // Used by AppWindowGeometryCache to persist its cache. These methods |
| 513 // should not be called directly. | 514 // should not be called directly. |
| 514 const base::DictionaryValue* GetGeometryCache( | 515 const base::DictionaryValue* GetGeometryCache( |
| (...skipping 27 matching lines...) Expand all Loading... |
| 542 friend class ExtensionPrefsComponentExtension; // Unit test. | 543 friend class ExtensionPrefsComponentExtension; // Unit test. |
| 543 friend class ExtensionPrefsUninstallExtension; // Unit test. | 544 friend class ExtensionPrefsUninstallExtension; // Unit test. |
| 544 | 545 |
| 545 enum DisableReasonChange { | 546 enum DisableReasonChange { |
| 546 DISABLE_REASON_ADD, | 547 DISABLE_REASON_ADD, |
| 547 DISABLE_REASON_REMOVE, | 548 DISABLE_REASON_REMOVE, |
| 548 DISABLE_REASON_CLEAR | 549 DISABLE_REASON_CLEAR |
| 549 }; | 550 }; |
| 550 | 551 |
| 551 // See the Create methods. | 552 // See the Create methods. |
| 552 ExtensionPrefs(PrefService* prefs, | 553 ExtensionPrefs(content::BrowserContext* browser_context, |
| 554 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 // Helper function to complete initialization of the values in | 664 // Helper function to complete initialization of the values in |
| 664 // |extension_dict| for an extension install. Also see | 665 // |extension_dict| for an extension install. Also see |
| 665 // PopulateExtensionInfoPrefs(). | 666 // PopulateExtensionInfoPrefs(). |
| 666 void FinishExtensionInfoPrefs( | 667 void FinishExtensionInfoPrefs( |
| 667 const std::string& extension_id, | 668 const std::string& extension_id, |
| 668 const base::Time install_time, | 669 const base::Time install_time, |
| 669 bool needs_sort_ordinal, | 670 bool needs_sort_ordinal, |
| 670 const syncer::StringOrdinal& suggested_page_ordinal, | 671 const syncer::StringOrdinal& suggested_page_ordinal, |
| 671 base::DictionaryValue* extension_dict); | 672 base::DictionaryValue* extension_dict); |
| 672 | 673 |
| 674 content::BrowserContext* browser_context_; |
| 675 |
| 673 // The pref service specific to this set of extension prefs. Owned by the | 676 // The pref service specific to this set of extension prefs. Owned by the |
| 674 // BrowserContext. | 677 // BrowserContext. |
| 675 PrefService* prefs_; | 678 PrefService* prefs_; |
| 676 | 679 |
| 677 // Base extensions install directory. | 680 // Base extensions install directory. |
| 678 base::FilePath install_directory_; | 681 base::FilePath install_directory_; |
| 679 | 682 |
| 680 // Weak pointer, owned by BrowserContext. | 683 // Weak pointer, owned by BrowserContext. |
| 681 ExtensionPrefValueMap* extension_pref_value_map_; | 684 ExtensionPrefValueMap* extension_pref_value_map_; |
| 682 | 685 |
| 683 // Contains all the logic for handling the order for various extension | |
| 684 // properties. | |
| 685 scoped_ptr<AppSorting> app_sorting_; | |
| 686 | |
| 687 scoped_ptr<TimeProvider> time_provider_; | 686 scoped_ptr<TimeProvider> time_provider_; |
| 688 | 687 |
| 689 bool extensions_disabled_; | 688 bool extensions_disabled_; |
| 690 | 689 |
| 691 base::ObserverList<ExtensionPrefsObserver> observer_list_; | 690 base::ObserverList<ExtensionPrefsObserver> observer_list_; |
| 692 | 691 |
| 693 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); | 692 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); |
| 694 }; | 693 }; |
| 695 | 694 |
| 696 } // namespace extensions | 695 } // namespace extensions |
| 697 | 696 |
| 698 #endif // EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ | 697 #endif // EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ |
| OLD | NEW |