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

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

Issue 220353002: Remove //chrome dependency from ExtensionPrefs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
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 20 matching lines...) Expand all
31 class BrowserContext; 31 class BrowserContext;
32 } 32 }
33 33
34 namespace user_prefs { 34 namespace user_prefs {
35 class PrefRegistrySyncable; 35 class PrefRegistrySyncable;
36 } 36 }
37 37
38 namespace extensions { 38 namespace extensions {
39 39
40 class AppSorting; 40 class AppSorting;
41 class ContentSettingsStore;
42 class ExtensionPrefsUninstallExtension; 41 class ExtensionPrefsUninstallExtension;
43 class URLPatternSet; 42 class URLPatternSet;
44 43
45 // Class for managing global and per-extension preferences. 44 // Class for managing global and per-extension preferences.
46 // 45 //
47 // This class distinguishes the following kinds of preferences: 46 // This class distinguishes the following kinds of preferences:
48 // - global preferences: 47 // - global preferences:
49 // internal state for the extension system in general, not associated 48 // internal state for the extension system in general, not associated
50 // with an individual extension, such as lastUpdateTime. 49 // with an individual extension, such as lastUpdateTime.
51 // - per-extension preferences: 50 // - per-extension preferences:
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 typedef ScopedUpdate<base::DictionaryValue, base::Value::TYPE_DICTIONARY> 120 typedef ScopedUpdate<base::DictionaryValue, base::Value::TYPE_DICTIONARY>
122 ScopedDictionaryUpdate; 121 ScopedDictionaryUpdate;
123 typedef ScopedUpdate<base::ListValue, base::Value::TYPE_LIST> 122 typedef ScopedUpdate<base::ListValue, base::Value::TYPE_LIST>
124 ScopedListUpdate; 123 ScopedListUpdate;
125 124
126 class Observer { 125 class Observer {
127 public: 126 public:
128 // Called when the reasons for an extension being disabled have changed. 127 // Called when the reasons for an extension being disabled have changed.
129 virtual void OnExtensionDisableReasonsChanged( 128 virtual void OnExtensionDisableReasonsChanged(
130 const std::string& extension_id, 129 const std::string& extension_id,
131 int disabled_reasons) = 0; 130 int disabled_reasons) {}
131
132 // Called when an extension is registered with ExtensionPrefs.
133 virtual void OnExtensionRegistered(const std::string& extension_id,
134 const base::Time& install_time,
135 bool is_enabled) {}
136
137 // Called when an extension's prefs have been loaded.
138 virtual void OnExtensionPrefsLoaded(const std::string& extension_id) {}
139
140 // Called when an extension's prefs are deleted.
141 virtual void OnExtensionPrefsDeleted(const std::string& extension_id) {}
142
143 // Called when an extension's enabled state pref is changed.
144 virtual void OnExtensionStateChanged(const std::string& extension_id,
145 bool state) {}
132 }; 146 };
133 147
134 // Creates and initializes an ExtensionPrefs object. 148 // Creates an ExtensionPrefs object.
135 // Does not take ownership of |prefs| and |extension_pref_value_map|. 149 // Does not take ownership of |prefs| or |extension_pref_value_map|.
136 // If |extensions_disabled| is true, extension controlled preferences and 150 // If |extensions_disabled| is true, extension controlled preferences and
137 // content settings do not become effective. 151 // content settings do not become effective.
152 // The Initialize method be called before an ExtensionPrefs is ready for
153 // general use. This is to allow observers to be registered between
James Cook 2014/04/01 18:45:03 Could you instead call ExtensionsBrowserClient::Ge
Ken Rockot(use gerrit already) 2014/04/01 21:34:59 I was going to do that, but it looked like someone
154 // construction and initialization.
138 static ExtensionPrefs* Create( 155 static ExtensionPrefs* Create(
139 PrefService* prefs, 156 PrefService* prefs,
140 const base::FilePath& root_dir, 157 const base::FilePath& root_dir,
141 ExtensionPrefValueMap* extension_pref_value_map, 158 ExtensionPrefValueMap* extension_pref_value_map,
142 scoped_ptr<AppSorting> app_sorting, 159 scoped_ptr<AppSorting> app_sorting,
143 bool extensions_disabled); 160 bool extensions_disabled);
144 161
145 // A version of Create which allows injection of a custom base::Time provider. 162 // A version of Create which allows injection of a custom base::Time provider.
146 // Use this as needed for testing. 163 // Use this as needed for testing.
147 static ExtensionPrefs* Create( 164 static ExtensionPrefs* Create(
(...skipping 11 matching lines...) Expand all
159 176
160 // Returns all installed extensions from extension preferences provided by 177 // Returns all installed extensions from extension preferences provided by
161 // |pref_service|. This is exposed for ProtectedPrefsWatcher because it needs 178 // |pref_service|. This is exposed for ProtectedPrefsWatcher because it needs
162 // access to the extension ID list before the ExtensionService is initialized. 179 // access to the extension ID list before the ExtensionService is initialized.
163 static ExtensionIdList GetExtensionsFrom(const PrefService* pref_service); 180 static ExtensionIdList GetExtensionsFrom(const PrefService* pref_service);
164 181
165 // Add or remove an observer from the ExtensionPrefs. 182 // Add or remove an observer from the ExtensionPrefs.
166 void AddObserver(Observer* observer); 183 void AddObserver(Observer* observer);
167 void RemoveObserver(Observer* observer); 184 void RemoveObserver(Observer* observer);
168 185
186 // Initializes the prefs. Only AddObserver or RemoveObserver should be called
187 // on an instance of ExtensionPrefs before its Initialize method has been
188 // callbed.
James Cook 2014/04/01 18:45:03 callbed -> called
Ken Rockot(use gerrit already) 2014/04/01 21:34:59 Done.
189 void Initialize();
190
169 // Returns true if the specified external extension was uninstalled by the 191 // Returns true if the specified external extension was uninstalled by the
170 // user. 192 // user.
171 bool IsExternalExtensionUninstalled(const std::string& id) const; 193 bool IsExternalExtensionUninstalled(const std::string& id) const;
172 194
173 // Checks whether |extension_id| is disabled. If there's no state pref for 195 // Checks whether |extension_id| is disabled. If there's no state pref for
174 // the extension, this will return false. Generally you should use 196 // the extension, this will return false. Generally you should use
175 // ExtensionService::IsExtensionEnabled instead. 197 // ExtensionService::IsExtensionEnabled instead.
176 bool IsExtensionDisabled(const std::string& id) const; 198 bool IsExtensionDisabled(const std::string& id) const;
177 199
178 // Get/Set the order that the browser actions appear in the toolbar. 200 // Get/Set the order that the browser actions appear in the toolbar.
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 530
509 // Gets/sets the last launch time of an extension. 531 // Gets/sets the last launch time of an extension.
510 base::Time GetLastLaunchTime(const std::string& extension_id) const; 532 base::Time GetLastLaunchTime(const std::string& extension_id) const;
511 void SetLastLaunchTime(const std::string& extension_id, 533 void SetLastLaunchTime(const std::string& extension_id,
512 const base::Time& time); 534 const base::Time& time);
513 535
514 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 536 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
515 537
516 bool extensions_disabled() const { return extensions_disabled_; } 538 bool extensions_disabled() const { return extensions_disabled_; }
517 539
518 ContentSettingsStore* content_settings_store() {
519 return content_settings_store_.get();
520 }
521
522 // The underlying PrefService. 540 // The underlying PrefService.
523 PrefService* pref_service() const { return prefs_; } 541 PrefService* pref_service() const { return prefs_; }
524 542
525 // The underlying AppSorting. 543 // The underlying AppSorting.
526 AppSorting* app_sorting() const { return app_sorting_.get(); } 544 AppSorting* app_sorting() const { return app_sorting_.get(); }
527 545
528 // Describes the URLs that are able to install extensions. See 546 // Describes the URLs that are able to install extensions. See
529 // pref_names::kAllowedInstallSites for more information. 547 // pref_names::kAllowedInstallSites for more information.
530 URLPatternSet GetAllowedInstallSites(); 548 URLPatternSet GetAllowedInstallSites();
531 549
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 // by a newly installed extension. Work is broken up between this 680 // by a newly installed extension. Work is broken up between this
663 // function and FinishExtensionInfoPrefs() to accomodate delayed 681 // function and FinishExtensionInfoPrefs() to accomodate delayed
664 // installations. 682 // installations.
665 void PopulateExtensionInfoPrefs(const Extension* extension, 683 void PopulateExtensionInfoPrefs(const Extension* extension,
666 const base::Time install_time, 684 const base::Time install_time,
667 Extension::State initial_state, 685 Extension::State initial_state,
668 bool blacklisted_for_malware, 686 bool blacklisted_for_malware,
669 const std::string& install_parameter, 687 const std::string& install_parameter,
670 base::DictionaryValue* extension_dict); 688 base::DictionaryValue* extension_dict);
671 689
690 void InitExtensionControlledPrefs(ExtensionPrefValueMap* value_map);
691
672 // Helper function to complete initialization of the values in 692 // Helper function to complete initialization of the values in
673 // |extension_dict| for an extension install. Also see 693 // |extension_dict| for an extension install. Also see
674 // PopulateExtensionInfoPrefs(). 694 // PopulateExtensionInfoPrefs().
675 void FinishExtensionInfoPrefs( 695 void FinishExtensionInfoPrefs(
676 const std::string& extension_id, 696 const std::string& extension_id,
677 const base::Time install_time, 697 const base::Time install_time,
678 bool needs_sort_ordinal, 698 bool needs_sort_ordinal,
679 const syncer::StringOrdinal& suggested_page_ordinal, 699 const syncer::StringOrdinal& suggested_page_ordinal,
680 base::DictionaryValue* extension_dict); 700 base::DictionaryValue* extension_dict);
681 701
682 // The pref service specific to this set of extension prefs. Owned by the 702 // The pref service specific to this set of extension prefs. Owned by the
683 // BrowserContext. 703 // BrowserContext.
684 PrefService* prefs_; 704 PrefService* prefs_;
685 705
686 // Base extensions install directory. 706 // Base extensions install directory.
687 base::FilePath install_directory_; 707 base::FilePath install_directory_;
688 708
689 // Weak pointer, owned by BrowserContext. 709 // Weak pointer, owned by BrowserContext.
690 ExtensionPrefValueMap* extension_pref_value_map_; 710 ExtensionPrefValueMap* extension_pref_value_map_;
691 711
692 // Contains all the logic for handling the order for various extension 712 // Contains all the logic for handling the order for various extension
693 // properties. 713 // properties.
694 scoped_ptr<AppSorting> app_sorting_; 714 scoped_ptr<AppSorting> app_sorting_;
695 715
696 scoped_refptr<ContentSettingsStore> content_settings_store_;
697
698 scoped_ptr<TimeProvider> time_provider_; 716 scoped_ptr<TimeProvider> time_provider_;
699 717
700 bool extensions_disabled_; 718 bool extensions_disabled_;
701 719
702 ObserverList<Observer> observer_list_; 720 ObserverList<Observer> observer_list_;
703 721
704 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs); 722 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefs);
705 }; 723 };
706 724
707 } // namespace extensions 725 } // namespace extensions
708 726
709 #endif // EXTENSIONS_BROWSER_EXTENSION_PREFS_H_ 727 #endif // EXTENSIONS_BROWSER_EXTENSION_PREFS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698