76c3fffedbfe31a9e3113a26cdc44407a4b6f39c
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / options / chromeos / core_chromeos_options_handler.h
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CORE_CHROMEOS_OPTIONS_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CORE_CHROMEOS_OPTIONS_HANDLER_H_
7
8 #include <map>
9
10 #include "base/compiler_specific.h"
11 #include "base/memory/linked_ptr.h"
12 #include "chrome/browser/chromeos/settings/cros_settings.h"
13 #include "chrome/browser/chromeos/ui_proxy_config_service.h"
14 #include "chrome/browser/ui/webui/options/core_options_handler.h"
15
16 namespace chromeos {
17 namespace options {
18
19 // CoreChromeOSOptionsHandler handles ChromeOS settings.
20 class CoreChromeOSOptionsHandler : public ::options::CoreOptionsHandler {
21  public:
22   CoreChromeOSOptionsHandler();
23   virtual ~CoreChromeOSOptionsHandler();
24
25   // ::CoreOptionsHandler overrides
26   virtual void RegisterMessages() OVERRIDE;
27   virtual base::Value* FetchPref(const std::string& pref_name) OVERRIDE;
28   virtual void InitializeHandler() OVERRIDE;
29   virtual void ObservePref(const std::string& pref_name) OVERRIDE;
30   virtual void SetPref(const std::string& pref_name,
31                        const base::Value* value,
32                        const std::string& metric) OVERRIDE;
33   virtual void StopObservingPref(const std::string& path) OVERRIDE;
34   virtual base::Value* CreateValueForPref(
35       const std::string& pref_name,
36       const std::string& controlling_pref_name) OVERRIDE;
37
38   // OptionsPageUIHandler implementation.
39   virtual void GetLocalizedValues(
40       base::DictionaryValue* localized_strings) OVERRIDE;
41
42  private:
43   virtual void OnPreferenceChanged(PrefService* service,
44                                    const std::string& pref_name) OVERRIDE;
45
46   // Called from Javascript to select the network to show proxy settings
47   // for. Triggers pref notifications about the updated proxy settings.
48   void SelectNetworkCallback(const base::ListValue* args);
49
50   // Notifies registered JS callbacks on ChromeOS setting change.
51   void NotifySettingsChanged(const std::string& setting_name);
52   void NotifyProxyPrefsChanged();
53
54   typedef std::map<std::string, linked_ptr<CrosSettings::ObserverSubscription> >
55       SubscriptionMap;
56   SubscriptionMap pref_subscription_map_;
57
58   UIProxyConfigService proxy_config_service_;
59 };
60
61 }  // namespace options
62 }  // namespace chromeos
63
64 #endif  // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CORE_CHROMEOS_OPTIONS_HANDLER_H_