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

Side by Side Diff: chrome/browser/ui/webui/options/core_options_handler.h

Issue 11316163: Remove the last usages of PrefObserver outside of Prefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Win and CrOS build. Created 8 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CHROME_BROWSER_UI_WEBUI_OPTIONS_CORE_OPTIONS_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_CORE_OPTIONS_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CORE_OPTIONS_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CORE_OPTIONS_HANDLER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/prefs/public/pref_change_registrar.h" 12 #include "base/prefs/public/pref_change_registrar.h"
13 #include "base/prefs/public/pref_observer.h"
14 #include "base/values.h" 13 #include "base/values.h"
15 #include "chrome/browser/plugins/plugin_status_pref_setter.h" 14 #include "chrome/browser/plugins/plugin_status_pref_setter.h"
16 #include "chrome/browser/prefs/pref_service.h" 15 #include "chrome/browser/prefs/pref_service.h"
17 #include "chrome/browser/ui/webui/options/options_ui.h" 16 #include "chrome/browser/ui/webui/options/options_ui.h"
18 17
19 namespace options { 18 namespace options {
20 19
21 // Core options UI handler. 20 // Core options UI handler.
22 // Handles resource and JS calls common to all options sub-pages. 21 // Handles resource and JS calls common to all options sub-pages.
23 class CoreOptionsHandler : public OptionsPageUIHandler, 22 class CoreOptionsHandler : public OptionsPageUIHandler {
24 public PrefObserver {
25 public: 23 public:
26 CoreOptionsHandler(); 24 CoreOptionsHandler();
27 virtual ~CoreOptionsHandler(); 25 virtual ~CoreOptionsHandler();
28 26
29 // OptionsPageUIHandler implementation. 27 // OptionsPageUIHandler implementation.
30 virtual void GetLocalizedValues(DictionaryValue* localized_strings) OVERRIDE; 28 virtual void GetLocalizedValues(DictionaryValue* localized_strings) OVERRIDE;
31 virtual void InitializeHandler() OVERRIDE; 29 virtual void InitializeHandler() OVERRIDE;
32 virtual void InitializePage() OVERRIDE; 30 virtual void InitializePage() OVERRIDE;
33 virtual void Uninitialize() OVERRIDE; 31 virtual void Uninitialize() OVERRIDE;
34 32
35 // PrefObserver implementation.
36 virtual void OnPreferenceChanged(PrefServiceBase* service,
37 const std::string& pref_name) OVERRIDE;
38
39 // WebUIMessageHandler implementation. 33 // WebUIMessageHandler implementation.
40 virtual void RegisterMessages() OVERRIDE; 34 virtual void RegisterMessages() OVERRIDE;
41 35
42 void set_handlers_host(OptionsPageUIHandlerHost* handlers_host) { 36 void set_handlers_host(OptionsPageUIHandlerHost* handlers_host) {
43 handlers_host_ = handlers_host; 37 handlers_host_ = handlers_host;
44 } 38 }
45 39
46 // Adds localized strings to |localized_strings|. 40 // Adds localized strings to |localized_strings|.
47 static void GetStaticLocalizedValues( 41 static void GetStaticLocalizedValues(
48 base::DictionaryValue* localized_strings); 42 base::DictionaryValue* localized_strings);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // value. |args| is an array of parameters as follows: 135 // value. |args| is an array of parameters as follows:
142 // item 0 - name of the preference. 136 // item 0 - name of the preference.
143 // item 1 - name of the metric identifier (optional). 137 // item 1 - name of the metric identifier (optional).
144 void HandleClearPref(const ListValue* args); 138 void HandleClearPref(const ListValue* args);
145 139
146 // Callback for the "coreOptionsUserMetricsAction" message. This records 140 // Callback for the "coreOptionsUserMetricsAction" message. This records
147 // an action that should be tracked if metrics recording is enabled. |args| 141 // an action that should be tracked if metrics recording is enabled. |args|
148 // is an array that contains a single item, the name of the metric identifier. 142 // is an array that contains a single item, the name of the metric identifier.
149 void HandleUserMetricsAction(const ListValue* args); 143 void HandleUserMetricsAction(const ListValue* args);
150 144
145 // We need to use virtual dispatch as handling of some prefs may be
146 // finessed in subclasses. We need to include the PrefServiceBase
147 // pointer so that subclasses can know whether we are observing the
148 // pref from the local state or not.
149 virtual void OnPreferenceChanged(PrefServiceBase* service,
150 const std::string& pref_name);
151
151 void UpdateClearPluginLSOData(); 152 void UpdateClearPluginLSOData();
152 void UpdatePepperFlashSettingsEnabled(); 153 void UpdatePepperFlashSettingsEnabled();
153 154
154 OptionsPageUIHandlerHost* handlers_host_; 155 OptionsPageUIHandlerHost* handlers_host_;
155 // This registrar keeps track of user prefs. 156 // This registrar keeps track of user prefs.
156 PrefChangeRegistrar registrar_; 157 PrefChangeRegistrar registrar_;
157 // This registrar keeps track of local state. 158 // This registrar keeps track of local state.
158 PrefChangeRegistrar local_state_registrar_; 159 PrefChangeRegistrar local_state_registrar_;
159 160
160 PluginStatusPrefSetter plugin_status_pref_setter_; 161 PluginStatusPrefSetter plugin_status_pref_setter_;
161 162
162 // This maps pref names to filter functions. The callbacks should take the 163 // This maps pref names to filter functions. The callbacks should take the
163 // value that the user has attempted to set for the pref, and should return 164 // value that the user has attempted to set for the pref, and should return
164 // true if that value may be applied. If the return value is false, the 165 // true if that value may be applied. If the return value is false, the
165 // change will be ignored. 166 // change will be ignored.
166 typedef std::map<std::string, base::Callback<bool(const base::Value*)> > 167 typedef std::map<std::string, base::Callback<bool(const base::Value*)> >
167 PrefChangeFilterMap; 168 PrefChangeFilterMap;
168 PrefChangeFilterMap pref_change_filters_; 169 PrefChangeFilterMap pref_change_filters_;
169 170
170 DISALLOW_COPY_AND_ASSIGN(CoreOptionsHandler); 171 DISALLOW_COPY_AND_ASSIGN(CoreOptionsHandler);
171 }; 172 };
172 173
173 } // namespace options 174 } // namespace options
174 175
175 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CORE_OPTIONS_HANDLER_H_ 176 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CORE_OPTIONS_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698