OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_DOM_UI_OPTIONS_CORE_OPTIONS_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_DOM_UI_OPTIONS_CORE_OPTIONS_HANDLER_H_ |
6 #define CHROME_BROWSER_DOM_UI_OPTIONS_CORE_OPTIONS_HANDLER_H_ | 6 #define CHROME_BROWSER_DOM_UI_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> |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 // Observes a pref of given |pref_name|. | 40 // Observes a pref of given |pref_name|. |
41 virtual void ObservePref(const std::string& pref_name); | 41 virtual void ObservePref(const std::string& pref_name); |
42 | 42 |
43 // Sets a pref value |value_string| of |pref_type| to given |pref_name|. | 43 // Sets a pref value |value_string| of |pref_type| to given |pref_name|. |
44 virtual void SetPref(const std::string& pref_name, | 44 virtual void SetPref(const std::string& pref_name, |
45 Value::ValueType pref_type, | 45 Value::ValueType pref_type, |
46 const std::string& value_string, | 46 const std::string& value_string, |
47 const std::string& metric); | 47 const std::string& metric); |
48 | 48 |
| 49 // Clears pref value for given |pref_name|. |
| 50 void ClearPref(const std::string& pref_name, const std::string& metric); |
| 51 |
49 // Stops observing given preference identified by |path|. | 52 // Stops observing given preference identified by |path|. |
50 virtual void StopObservingPref(const std::string& path); | 53 virtual void StopObservingPref(const std::string& path); |
51 | 54 |
52 // Records a user metric action for the given value. | 55 // Records a user metric action for the given value. |
53 void ProcessUserMetric(Value::ValueType pref_type, | 56 void ProcessUserMetric(Value::ValueType pref_type, |
54 const std::string& value_string, | 57 const std::string& value_string, |
55 const std::string& metric); | 58 const std::string& metric); |
56 | 59 |
57 typedef std::multimap<std::string, std::wstring> PreferenceCallbackMap; | 60 typedef std::multimap<std::string, std::wstring> PreferenceCallbackMap; |
58 PreferenceCallbackMap pref_callback_map_; | 61 PreferenceCallbackMap pref_callback_map_; |
59 private: | 62 private: |
60 // Callback for the "coreOptionsInitialize" message. This message will | 63 // Callback for the "coreOptionsInitialize" message. This message will |
61 // trigger the Initialize() method of all other handlers so that final | 64 // trigger the Initialize() method of all other handlers so that final |
62 // setup can be performed before the page is shown. | 65 // setup can be performed before the page is shown. |
63 void HandleInitialize(const ListValue* args); | 66 void HandleInitialize(const ListValue* args); |
64 | 67 |
65 // Callback for the "fetchPrefs" message. This message accepts the list of | 68 // Callback for the "fetchPrefs" message. This message accepts the list of |
66 // preference names passed as |value| parameter (ListValue). It passes results | 69 // preference names passed as the |args| parameter (ListValue). It passes |
67 // dictionary of preference values by calling prefsFetched() JS method on the | 70 // results dictionary of preference values by calling prefsFetched() JS method |
68 // page. | 71 // on the page. |
69 void HandleFetchPrefs(const ListValue* args); | 72 void HandleFetchPrefs(const ListValue* args); |
70 | 73 |
71 // Callback for the "observePrefs" message. This message initiates | 74 // Callback for the "observePrefs" message. This message initiates |
72 // notification observing for given array of preference names. | 75 // notification observing for given array of preference names. |
73 void HandleObservePrefs(const ListValue* args); | 76 void HandleObservePrefs(const ListValue* args); |
74 | 77 |
75 // Callbacks for the "set<type>Pref" message. This message saves the new | 78 // Callbacks for the "set<type>Pref" message. This message saves the new |
76 // preference value. The input value is an array of strings representing | 79 // preference value. |args| is an array of parameters as follows: |
77 // name-value preference pair. | 80 // item 0 - name of the preference. |
| 81 // item 1 - the value of the preference in string form. |
| 82 // item 2 - name of the metric identifier (optional). |
78 void HandleSetBooleanPref(const ListValue* args); | 83 void HandleSetBooleanPref(const ListValue* args); |
79 void HandleSetIntegerPref(const ListValue* args); | 84 void HandleSetIntegerPref(const ListValue* args); |
80 void HandleSetStringPref(const ListValue* args); | 85 void HandleSetStringPref(const ListValue* args); |
81 void HandleSetObjectPref(const ListValue* args); | 86 void HandleSetObjectPref(const ListValue* args); |
82 | 87 |
83 void HandleSetPref(const ListValue* args, Value::ValueType type); | 88 void HandleSetPref(const ListValue* args, Value::ValueType type); |
84 | 89 |
| 90 // Callback for the "clearPref" message. This message clears a preference |
| 91 // value. |args| is an array of parameters as follows: |
| 92 // item 0 - name of the preference. |
| 93 // item 1 - name of the metric identifier (optional). |
| 94 void HandleClearPref(const ListValue* args); |
| 95 |
85 // Callback for the "coreOptionsUserMetricsAction" message. This records | 96 // Callback for the "coreOptionsUserMetricsAction" message. This records |
86 // an action that should be tracked if metrics recording is enabled. | 97 // an action that should be tracked if metrics recording is enabled. |args| |
| 98 // is an array that contains a single item, the name of the metric identifier. |
87 void HandleUserMetricsAction(const ListValue* args); | 99 void HandleUserMetricsAction(const ListValue* args); |
88 | 100 |
89 void NotifyPrefChanged(const std::string* pref_name); | 101 void NotifyPrefChanged(const std::string* pref_name); |
90 | 102 |
91 PrefChangeRegistrar registrar_; | 103 PrefChangeRegistrar registrar_; |
92 | 104 |
93 DISALLOW_COPY_AND_ASSIGN(CoreOptionsHandler); | 105 DISALLOW_COPY_AND_ASSIGN(CoreOptionsHandler); |
94 }; | 106 }; |
95 | 107 |
96 #endif // CHROME_BROWSER_DOM_UI_OPTIONS_CORE_OPTIONS_HANDLER_H_ | 108 #endif // CHROME_BROWSER_DOM_UI_OPTIONS_CORE_OPTIONS_HANDLER_H_ |
OLD | NEW |