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

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

Issue 8930012: Revert 114236 - Options2: Pull the trigger. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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
(Empty)
1 // Copyright (c) 2011 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.
4
5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_CORE_OPTIONS_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_CORE_OPTIONS_HANDLER_H_
7 #pragma once
8
9 #include <map>
10 #include <string>
11
12 #include "base/values.h"
13 #include "chrome/browser/plugin_data_remover_helper.h"
14 #include "chrome/browser/prefs/pref_change_registrar.h"
15 #include "chrome/browser/prefs/pref_service.h"
16 #include "chrome/browser/ui/webui/options2/options_ui.h"
17
18 // Core options UI handler.
19 // Handles resource and JS calls common to all options sub-pages.
20 class CoreOptionsHandler : public OptionsPage2UIHandler {
21 public:
22 CoreOptionsHandler();
23 virtual ~CoreOptionsHandler();
24
25 // OptionsPage2UIHandler implementation.
26 virtual void Initialize() OVERRIDE;
27 virtual void GetLocalizedValues(DictionaryValue* localized_strings) OVERRIDE;
28 virtual void Uninitialize() OVERRIDE;
29
30 // content::NotificationObserver implementation.
31 virtual void Observe(int type,
32 const content::NotificationSource& source,
33 const content::NotificationDetails& details) OVERRIDE;
34
35 // WebUIMessageHandler implementation.
36 virtual void RegisterMessages() OVERRIDE;
37 virtual WebUIMessageHandler* Attach(WebUI* web_ui) OVERRIDE;
38
39 void set_handlers_host(OptionsPage2UIHandlerHost* handlers_host) {
40 handlers_host_ = handlers_host;
41 }
42
43 // Adds localized strings to |localized_strings|.
44 static void GetStaticLocalizedValues(
45 base::DictionaryValue* localized_strings);
46
47 protected:
48 // Fetches a pref value of given |pref_name|.
49 // Note that caller owns the returned Value.
50 virtual base::Value* FetchPref(const std::string& pref_name);
51
52 // Observes a pref of given |pref_name|.
53 virtual void ObservePref(const std::string& pref_name);
54
55 // Sets a pref |value| to given |pref_name|.
56 virtual void SetPref(const std::string& pref_name,
57 const base::Value* value,
58 const std::string& metric);
59
60 // Clears pref value for given |pref_name|.
61 void ClearPref(const std::string& pref_name, const std::string& metric);
62
63 // Stops observing given preference identified by |path|.
64 virtual void StopObservingPref(const std::string& path);
65
66 // Records a user metric action for the given value.
67 void ProcessUserMetric(const base::Value* value,
68 const std::string& metric);
69
70 // Notifies registered JS callbacks on change in |pref_name| preference.
71 // |controlling_pref_name| controls if |pref_name| is managed by
72 // policy/extension; empty |controlling_pref_name| indicates no other pref is
73 // controlling |pref_name|.
74 void NotifyPrefChanged(const std::string& pref_name,
75 const std::string& controlling_pref_name);
76
77 // Creates dictionary value for |pref|, |controlling_pref| controls if |pref|
78 // is managed by policy/extension; NULL indicates no other pref is controlling
79 // |pref|.
80 DictionaryValue* CreateValueForPref(
81 const PrefService::Preference* pref,
82 const PrefService::Preference* controlling_pref);
83
84 typedef std::multimap<std::string, std::wstring> PreferenceCallbackMap;
85 PreferenceCallbackMap pref_callback_map_;
86
87 private:
88 // Type of preference value received from the page. This doesn't map 1:1 to
89 // Value::Type, since a TYPE_STRING can require custom processing.
90 enum PrefType {
91 TYPE_BOOLEAN = 0,
92 TYPE_INTEGER,
93 TYPE_DOUBLE,
94 TYPE_STRING,
95 TYPE_URL,
96 TYPE_LIST,
97 };
98
99 // Callback for the "coreOptionsInitialize" message. This message will
100 // trigger the Initialize() method of all other handlers so that final
101 // setup can be performed before the page is shown.
102 void HandleInitialize(const ListValue* args);
103
104 // Callback for the "fetchPrefs" message. This message accepts the list of
105 // preference names passed as the |args| parameter (ListValue). It passes
106 // results dictionary of preference values by calling prefsFetched() JS method
107 // on the page.
108 void HandleFetchPrefs(const ListValue* args);
109
110 // Callback for the "observePrefs" message. This message initiates
111 // notification observing for given array of preference names.
112 void HandleObservePrefs(const ListValue* args);
113
114 // Callbacks for the "set<type>Pref" message. This message saves the new
115 // preference value. |args| is an array of parameters as follows:
116 // item 0 - name of the preference.
117 // item 1 - the value of the preference in string form.
118 // item 2 - name of the metric identifier (optional).
119 void HandleSetBooleanPref(const ListValue* args);
120 void HandleSetIntegerPref(const ListValue* args);
121 void HandleSetDoublePref(const ListValue* args);
122 void HandleSetStringPref(const ListValue* args);
123 void HandleSetURLPref(const ListValue* args);
124 void HandleSetListPref(const ListValue* args);
125
126 void HandleSetPref(const ListValue* args, PrefType type);
127
128 // Callback for the "clearPref" message. This message clears a preference
129 // value. |args| is an array of parameters as follows:
130 // item 0 - name of the preference.
131 // item 1 - name of the metric identifier (optional).
132 void HandleClearPref(const ListValue* args);
133
134 // Callback for the "coreOptionsUserMetricsAction" message. This records
135 // an action that should be tracked if metrics recording is enabled. |args|
136 // is an array that contains a single item, the name of the metric identifier.
137 void HandleUserMetricsAction(const ListValue* args);
138
139 void UpdateClearPluginLSOData();
140
141 OptionsPage2UIHandlerHost* handlers_host_;
142 PrefChangeRegistrar registrar_;
143
144 // Used for asynchronously updating the preference stating whether clearing
145 // LSO data is supported.
146 PluginDataRemoverHelper clear_plugin_lso_data_enabled_;
147
148 DISALLOW_COPY_AND_ASSIGN(CoreOptionsHandler);
149 };
150
151 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_CORE_OPTIONS_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options2/cookies_view_handler.cc ('k') | chrome/browser/ui/webui/options2/core_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698