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_CORE_OPTIONS_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_DOM_UI_CORE_OPTIONS_HANDLER_H_ |
6 #define CHROME_BROWSER_DOM_UI_CORE_OPTIONS_HANDLER_H_ | 6 #define CHROME_BROWSER_DOM_UI_CORE_OPTIONS_HANDLER_H_ |
7 | 7 |
| 8 #include <map> |
| 9 #include <string> |
| 10 |
8 #include "base/values.h" | 11 #include "base/values.h" |
9 #include "chrome/browser/dom_ui/options_ui.h" | 12 #include "chrome/browser/dom_ui/options_ui.h" |
10 | 13 |
11 // Core options UI handler. | 14 // Core options UI handler. |
12 // Handles resource and JS calls common to all options sub-pages. | 15 // Handles resource and JS calls common to all options sub-pages. |
13 class CoreOptionsHandler : public OptionsPageUIHandler { | 16 class CoreOptionsHandler : public OptionsPageUIHandler { |
14 public: | 17 public: |
15 CoreOptionsHandler(); | 18 CoreOptionsHandler(); |
| 19 virtual ~CoreOptionsHandler(); |
16 | 20 |
17 // OptionsUIHandler implementation. | 21 // OptionsUIHandler implementation. |
18 virtual void GetLocalizedValues(DictionaryValue* localized_strings); | 22 virtual void GetLocalizedValues(DictionaryValue* localized_strings); |
19 | 23 |
20 // NotificationObserver implementation. | 24 // NotificationObserver implementation. |
21 virtual void Observe(NotificationType type, | 25 virtual void Observe(NotificationType type, |
22 const NotificationSource& source, | 26 const NotificationSource& source, |
23 const NotificationDetails& details); | 27 const NotificationDetails& details); |
24 | 28 |
25 // DOMMessageHandler implementation. | 29 // DOMMessageHandler implementation. |
26 virtual void RegisterMessages(); | 30 virtual void RegisterMessages(); |
27 | 31 |
28 private: | 32 private: |
| 33 typedef std::multimap<std::wstring, std::wstring> PreferenceCallbackMap; |
29 // Callback for the "fetchPrefs" message. This message accepts the list of | 34 // Callback for the "fetchPrefs" message. This message accepts the list of |
30 // preference names passed as |value| parameter (ListValue). It passes results | 35 // preference names passed as |value| parameter (ListValue). It passes results |
31 // dictionary of preference values by calling prefsFetched() JS method on the | 36 // dictionary of preference values by calling prefsFetched() JS method on the |
32 // page. | 37 // page. |
33 void HandleFetchPrefs(const Value* value); | 38 void HandleFetchPrefs(const Value* value); |
34 | 39 |
35 // Callback for the "observePrefs" message. This message initiates | 40 // Callback for the "observePrefs" message. This message initiates |
36 // notification observing for given array of preference names. | 41 // notification observing for given array of preference names. |
37 void HandleObservePefs(const Value* value); | 42 void HandleObservePefs(const Value* value); |
38 | 43 |
39 // Callbacks for the "set<type>Pref" message. This message saves the new | 44 // Callbacks for the "set<type>Pref" message. This message saves the new |
40 // preference value. The input value is an array of strings representing | 45 // preference value. The input value is an array of strings representing |
41 // name-value preference pair. | 46 // name-value preference pair. |
42 void HandleSetBooleanPref(const Value* value); | 47 void HandleSetBooleanPref(const Value* value); |
43 void HandleSetIntegerPref(const Value* value); | 48 void HandleSetIntegerPref(const Value* value); |
44 void HandleSetStringPref(const Value* value); | 49 void HandleSetStringPref(const Value* value); |
45 | 50 |
46 void HandleSetPref(const Value* value, Value::ValueType type); | 51 void HandleSetPref(const Value* value, Value::ValueType type); |
47 | 52 |
48 void NotifyPrefChanged(const std::wstring* pref_name); | 53 void NotifyPrefChanged(const std::wstring* pref_name); |
49 | 54 |
| 55 PreferenceCallbackMap pref_callback_map_; |
50 DISALLOW_COPY_AND_ASSIGN(CoreOptionsHandler); | 56 DISALLOW_COPY_AND_ASSIGN(CoreOptionsHandler); |
51 }; | 57 }; |
52 | 58 |
53 #endif // CHROME_BROWSER_DOM_UI_CORE_OPTIONS_HANDLER_H_ | 59 #endif // CHROME_BROWSER_DOM_UI_CORE_OPTIONS_HANDLER_H_ |
OLD | NEW |