OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/plugin_data_remover_helper.h" | 13 #include "chrome/browser/plugin_data_remover_helper.h" |
14 #include "chrome/browser/prefs/pref_change_registrar.h" | 14 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 15 #include "chrome/browser/prefs/pref_service.h" |
15 #include "chrome/browser/ui/webui/options/options_ui.h" | 16 #include "chrome/browser/ui/webui/options/options_ui.h" |
16 | 17 |
17 // Core options UI handler. | 18 // Core options UI handler. |
18 // Handles resource and JS calls common to all options sub-pages. | 19 // Handles resource and JS calls common to all options sub-pages. |
19 class CoreOptionsHandler : public OptionsPageUIHandler { | 20 class CoreOptionsHandler : public OptionsPageUIHandler { |
20 public: | 21 public: |
21 CoreOptionsHandler(); | 22 CoreOptionsHandler(); |
22 virtual ~CoreOptionsHandler(); | 23 virtual ~CoreOptionsHandler(); |
23 | 24 |
24 // OptionsPageUIHandler implementation. | 25 // OptionsPageUIHandler implementation. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // Clears pref value for given |pref_name|. | 60 // Clears pref value for given |pref_name|. |
60 void ClearPref(const std::string& pref_name, const std::string& metric); | 61 void ClearPref(const std::string& pref_name, const std::string& metric); |
61 | 62 |
62 // Stops observing given preference identified by |path|. | 63 // Stops observing given preference identified by |path|. |
63 virtual void StopObservingPref(const std::string& path); | 64 virtual void StopObservingPref(const std::string& path); |
64 | 65 |
65 // Records a user metric action for the given value. | 66 // Records a user metric action for the given value. |
66 void ProcessUserMetric(const Value* value, | 67 void ProcessUserMetric(const Value* value, |
67 const std::string& metric); | 68 const std::string& metric); |
68 | 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 |
69 typedef std::multimap<std::string, std::wstring> PreferenceCallbackMap; | 84 typedef std::multimap<std::string, std::wstring> PreferenceCallbackMap; |
70 PreferenceCallbackMap pref_callback_map_; | 85 PreferenceCallbackMap pref_callback_map_; |
| 86 |
71 private: | 87 private: |
72 // Type of preference value received from the page. This doesn't map 1:1 to | 88 // Type of preference value received from the page. This doesn't map 1:1 to |
73 // Value::Type, since a TYPE_STRING can require custom processing. | 89 // Value::Type, since a TYPE_STRING can require custom processing. |
74 enum PrefType { | 90 enum PrefType { |
75 TYPE_BOOLEAN = 0, | 91 TYPE_BOOLEAN = 0, |
76 TYPE_INTEGER, | 92 TYPE_INTEGER, |
77 TYPE_DOUBLE, | 93 TYPE_DOUBLE, |
78 TYPE_STRING, | 94 TYPE_STRING, |
79 TYPE_URL, | 95 TYPE_URL, |
80 TYPE_LIST, | 96 TYPE_LIST, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // item 1 - name of the metric identifier (optional). | 131 // item 1 - name of the metric identifier (optional). |
116 void HandleClearPref(const ListValue* args); | 132 void HandleClearPref(const ListValue* args); |
117 | 133 |
118 // Callback for the "coreOptionsUserMetricsAction" message. This records | 134 // Callback for the "coreOptionsUserMetricsAction" message. This records |
119 // an action that should be tracked if metrics recording is enabled. |args| | 135 // an action that should be tracked if metrics recording is enabled. |args| |
120 // is an array that contains a single item, the name of the metric identifier. | 136 // is an array that contains a single item, the name of the metric identifier. |
121 void HandleUserMetricsAction(const ListValue* args); | 137 void HandleUserMetricsAction(const ListValue* args); |
122 | 138 |
123 void UpdateClearPluginLSOData(); | 139 void UpdateClearPluginLSOData(); |
124 | 140 |
125 void NotifyPrefChanged(const std::string* pref_name); | |
126 | |
127 OptionsPageUIHandlerHost* handlers_host_; | 141 OptionsPageUIHandlerHost* handlers_host_; |
128 PrefChangeRegistrar registrar_; | 142 PrefChangeRegistrar registrar_; |
129 | 143 |
130 // Used for asynchronously updating the preference stating whether clearing | 144 // Used for asynchronously updating the preference stating whether clearing |
131 // LSO data is supported. | 145 // LSO data is supported. |
132 PluginDataRemoverHelper clear_plugin_lso_data_enabled_; | 146 PluginDataRemoverHelper clear_plugin_lso_data_enabled_; |
133 | 147 |
134 DISALLOW_COPY_AND_ASSIGN(CoreOptionsHandler); | 148 DISALLOW_COPY_AND_ASSIGN(CoreOptionsHandler); |
135 }; | 149 }; |
136 | 150 |
137 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CORE_OPTIONS_HANDLER_H_ | 151 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CORE_OPTIONS_HANDLER_H_ |
OLD | NEW |