| 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> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 virtual void GetLocalizedValues(DictionaryValue* localized_strings); | 22 virtual void GetLocalizedValues(DictionaryValue* localized_strings); |
| 23 | 23 |
| 24 // NotificationObserver implementation. | 24 // NotificationObserver implementation. |
| 25 virtual void Observe(NotificationType type, | 25 virtual void Observe(NotificationType type, |
| 26 const NotificationSource& source, | 26 const NotificationSource& source, |
| 27 const NotificationDetails& details); | 27 const NotificationDetails& details); |
| 28 | 28 |
| 29 // DOMMessageHandler implementation. | 29 // DOMMessageHandler implementation. |
| 30 virtual void RegisterMessages(); | 30 virtual void RegisterMessages(); |
| 31 | 31 |
| 32 protected: |
| 33 // Fetches a pref value of given |pref_name|. |
| 34 // Note that caller owns the returned Value. |
| 35 virtual Value* FetchPref(const std::wstring& pref_name); |
| 36 |
| 37 // Observes a pref of given |pref_name|. |
| 38 virtual void ObservePref(const std::wstring& pref_name); |
| 39 |
| 40 // Sets a pref value |value_string| of |pref_type| to given |pref_name|. |
| 41 virtual void SetPref(const std::wstring& pref_name, |
| 42 Value::ValueType pref_type, |
| 43 const std::string& value_string); |
| 44 |
| 32 private: | 45 private: |
| 33 typedef std::multimap<std::wstring, std::wstring> PreferenceCallbackMap; | 46 typedef std::multimap<std::wstring, std::wstring> PreferenceCallbackMap; |
| 34 // Callback for the "coreOptionsInitialize" message. This message will | 47 // Callback for the "coreOptionsInitialize" message. This message will |
| 35 // trigger the Initialize() method of all other handlers so that final | 48 // trigger the Initialize() method of all other handlers so that final |
| 36 // setup can be performed before the page is shown. | 49 // setup can be performed before the page is shown. |
| 37 void HandleInitialize(const Value* value); | 50 void HandleInitialize(const Value* value); |
| 38 | 51 |
| 39 // Callback for the "fetchPrefs" message. This message accepts the list of | 52 // Callback for the "fetchPrefs" message. This message accepts the list of |
| 40 // preference names passed as |value| parameter (ListValue). It passes results | 53 // preference names passed as |value| parameter (ListValue). It passes results |
| 41 // dictionary of preference values by calling prefsFetched() JS method on the | 54 // dictionary of preference values by calling prefsFetched() JS method on the |
| 42 // page. | 55 // page. |
| 43 void HandleFetchPrefs(const Value* value); | 56 void HandleFetchPrefs(const Value* value); |
| 44 | 57 |
| 45 // Callback for the "observePrefs" message. This message initiates | 58 // Callback for the "observePrefs" message. This message initiates |
| 46 // notification observing for given array of preference names. | 59 // notification observing for given array of preference names. |
| 47 void HandleObservePefs(const Value* value); | 60 void HandleObservePrefs(const Value* value); |
| 48 | 61 |
| 49 // Callbacks for the "set<type>Pref" message. This message saves the new | 62 // Callbacks for the "set<type>Pref" message. This message saves the new |
| 50 // preference value. The input value is an array of strings representing | 63 // preference value. The input value is an array of strings representing |
| 51 // name-value preference pair. | 64 // name-value preference pair. |
| 52 void HandleSetBooleanPref(const Value* value); | 65 void HandleSetBooleanPref(const Value* value); |
| 53 void HandleSetIntegerPref(const Value* value); | 66 void HandleSetIntegerPref(const Value* value); |
| 54 void HandleSetStringPref(const Value* value); | 67 void HandleSetStringPref(const Value* value); |
| 68 void HandleSetObjectPref(const Value* value); |
| 55 | 69 |
| 56 void HandleSetPref(const Value* value, Value::ValueType type); | 70 void HandleSetPref(const Value* value, Value::ValueType type); |
| 57 | 71 |
| 58 void NotifyPrefChanged(const std::wstring* pref_name); | 72 void NotifyPrefChanged(const std::wstring* pref_name); |
| 59 | 73 |
| 60 PreferenceCallbackMap pref_callback_map_; | 74 PreferenceCallbackMap pref_callback_map_; |
| 61 DISALLOW_COPY_AND_ASSIGN(CoreOptionsHandler); | 75 DISALLOW_COPY_AND_ASSIGN(CoreOptionsHandler); |
| 62 }; | 76 }; |
| 63 | 77 |
| 64 #endif // CHROME_BROWSER_DOM_UI_CORE_OPTIONS_HANDLER_H_ | 78 #endif // CHROME_BROWSER_DOM_UI_CORE_OPTIONS_HANDLER_H_ |
| OLD | NEW |