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.
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_
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 #include "content/public/browser/notification_observer.h"
16 #include "content/public/browser/notification_registrar.h"
21 // CoreChromeOSOptionsHandler handles ChromeOS settings.
22 class CoreChromeOSOptionsHandler : public ::options::CoreOptionsHandler,
23 public content::NotificationObserver {
25 CoreChromeOSOptionsHandler();
26 virtual ~CoreChromeOSOptionsHandler();
28 // ::CoreOptionsHandler overrides
29 virtual void RegisterMessages() override;
30 virtual base::Value* FetchPref(const std::string& pref_name) override;
31 virtual void InitializeHandler() override;
32 virtual void ObservePref(const std::string& pref_name) override;
33 virtual void SetPref(const std::string& pref_name,
34 const base::Value* value,
35 const std::string& metric) override;
36 virtual void StopObservingPref(const std::string& path) override;
37 virtual base::Value* CreateValueForPref(
38 const std::string& pref_name,
39 const std::string& controlling_pref_name) override;
41 // OptionsPageUIHandler implementation.
42 virtual void GetLocalizedValues(
43 base::DictionaryValue* localized_strings) override;
45 // content::NotificationObserver implementation.
46 virtual void Observe(int type,
47 const content::NotificationSource& source,
48 const content::NotificationDetails& details) override;
51 virtual void OnPreferenceChanged(PrefService* service,
52 const std::string& pref_name) override;
54 // Called from Javascript to select the network to show proxy settings
55 // for. Triggers pref notifications about the updated proxy settings.
56 void SelectNetworkCallback(const base::ListValue* args);
58 // Notifies registered JS callbacks on ChromeOS setting change.
59 void NotifySettingsChanged(const std::string& setting_name);
60 void NotifyProxyPrefsChanged();
62 // Called on changes to the ownership status. Needed to update the interface
63 // in case it has been shown before ownership has been fully established.
64 void NotifyOwnershipChanged();
66 typedef std::map<std::string, linked_ptr<CrosSettings::ObserverSubscription> >
68 SubscriptionMap pref_subscription_map_;
70 content::NotificationRegistrar notification_registrar_;
72 UIProxyConfigService proxy_config_service_;
75 } // namespace options
76 } // namespace chromeos
78 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CORE_CHROMEOS_OPTIONS_HANDLER_H_