| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> |
| 9 #include <string> | 10 #include <string> |
| 10 | 11 |
| 11 #include "base/callback.h" | 12 #include "base/callback.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/values.h" | 14 #include "base/values.h" |
| 14 #include "chrome/browser/plugins/plugin_status_pref_setter.h" | 15 #include "chrome/browser/plugins/plugin_status_pref_setter.h" |
| 15 #include "chrome/browser/ui/webui/options/options_ui.h" | 16 #include "chrome/browser/ui/webui/options/options_ui.h" |
| 16 #include "components/prefs/pref_change_registrar.h" | 17 #include "components/prefs/pref_change_registrar.h" |
| 17 #include "components/prefs/pref_service.h" | 18 #include "components/prefs/pref_service.h" |
| 18 | 19 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 38 handlers_host_ = handlers_host; | 39 handlers_host_ = handlers_host; |
| 39 } | 40 } |
| 40 | 41 |
| 41 // Adds localized strings to |localized_strings|. | 42 // Adds localized strings to |localized_strings|. |
| 42 static void GetStaticLocalizedValues( | 43 static void GetStaticLocalizedValues( |
| 43 base::DictionaryValue* localized_strings); | 44 base::DictionaryValue* localized_strings); |
| 44 | 45 |
| 45 protected: | 46 protected: |
| 46 // Fetches a pref value of given |pref_name|. | 47 // Fetches a pref value of given |pref_name|. |
| 47 // Note that caller owns the returned Value. | 48 // Note that caller owns the returned Value. |
| 48 virtual base::Value* FetchPref(const std::string& pref_name); | 49 virtual std::unique_ptr<base::Value> FetchPref(const std::string& pref_name); |
| 49 | 50 |
| 50 // Observes a pref of given |pref_name|. | 51 // Observes a pref of given |pref_name|. |
| 51 virtual void ObservePref(const std::string& pref_name); | 52 virtual void ObservePref(const std::string& pref_name); |
| 52 | 53 |
| 53 // Stops observing given preference identified by |pref_name|. | 54 // Stops observing given preference identified by |pref_name|. |
| 54 virtual void StopObservingPref(const std::string& pref_name); | 55 virtual void StopObservingPref(const std::string& pref_name); |
| 55 | 56 |
| 56 // Sets a pref |value| to given |pref_name|. | 57 // Sets a pref |value| to given |pref_name|. |
| 57 virtual void SetPref(const std::string& pref_name, | 58 virtual void SetPref(const std::string& pref_name, |
| 58 const base::Value* value, | 59 const base::Value* value, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 81 | 82 |
| 82 // Calls JS callbacks to report a change in the value of the |name| | 83 // Calls JS callbacks to report a change in the value of the |name| |
| 83 // preference. |value| is the new value for |name|. Called from | 84 // preference. |value| is the new value for |name|. Called from |
| 84 // Notify*Changed methods to fire off the notifications. | 85 // Notify*Changed methods to fire off the notifications. |
| 85 void DispatchPrefChangeNotification(const std::string& name, | 86 void DispatchPrefChangeNotification(const std::string& name, |
| 86 std::unique_ptr<base::Value> value); | 87 std::unique_ptr<base::Value> value); |
| 87 | 88 |
| 88 // Creates dictionary value for the pref described by |pref_name|. | 89 // Creates dictionary value for the pref described by |pref_name|. |
| 89 // If |controlling_pref| is not empty, it describes the pref that manages | 90 // If |controlling_pref| is not empty, it describes the pref that manages |
| 90 // |pref| via policy or extension. | 91 // |pref| via policy or extension. |
| 91 virtual base::Value* CreateValueForPref( | 92 virtual std::unique_ptr<base::Value> CreateValueForPref( |
| 92 const std::string& pref_name, | 93 const std::string& pref_name, |
| 93 const std::string& controlling_pref_name); | 94 const std::string& controlling_pref_name); |
| 94 | 95 |
| 95 typedef std::multimap<std::string, std::string> PreferenceCallbackMap; | 96 typedef std::multimap<std::string, std::string> PreferenceCallbackMap; |
| 96 PreferenceCallbackMap pref_callback_map_; | 97 PreferenceCallbackMap pref_callback_map_; |
| 97 | 98 |
| 98 private: | 99 private: |
| 99 // Type of preference value received from the page. This doesn't map 1:1 to | 100 // Type of preference value received from the page. This doesn't map 1:1 to |
| 100 // Value::Type, since a TYPE_STRING can require custom processing. | 101 // Value::Type, since a TYPE_STRING can require custom processing. |
| 101 enum PrefType { | 102 enum PrefType { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 typedef std::map<std::string, base::Callback<bool(const base::Value*)> > | 182 typedef std::map<std::string, base::Callback<bool(const base::Value*)> > |
| 182 PrefChangeFilterMap; | 183 PrefChangeFilterMap; |
| 183 PrefChangeFilterMap pref_change_filters_; | 184 PrefChangeFilterMap pref_change_filters_; |
| 184 | 185 |
| 185 DISALLOW_COPY_AND_ASSIGN(CoreOptionsHandler); | 186 DISALLOW_COPY_AND_ASSIGN(CoreOptionsHandler); |
| 186 }; | 187 }; |
| 187 | 188 |
| 188 } // namespace options | 189 } // namespace options |
| 189 | 190 |
| 190 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CORE_OPTIONS_HANDLER_H_ | 191 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CORE_OPTIONS_HANDLER_H_ |
| OLD | NEW |