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 #include "content/public/browser/notification_observer.h" 16 #include "content/public/browser/notification_registrar.h" 17 18 namespace chromeos { 19 namespace options { 20 21 // CoreChromeOSOptionsHandler handles ChromeOS settings. 22 class CoreChromeOSOptionsHandler : public ::options::CoreOptionsHandler, 23 public content::NotificationObserver { 24 public: 25 CoreChromeOSOptionsHandler(); 26 virtual ~CoreChromeOSOptionsHandler(); 27 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; 40 41 // OptionsPageUIHandler implementation. 42 virtual void GetLocalizedValues( 43 base::DictionaryValue* localized_strings) OVERRIDE; 44 45 // content::NotificationObserver implementation. 46 virtual void Observe(int type, 47 const content::NotificationSource& source, 48 const content::NotificationDetails& details) OVERRIDE; 49 50 private: 51 virtual void OnPreferenceChanged(PrefService* service, 52 const std::string& pref_name) OVERRIDE; 53 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); 57 58 // Notifies registered JS callbacks on ChromeOS setting change. 59 void NotifySettingsChanged(const std::string& setting_name); 60 void NotifyProxyPrefsChanged(); 61 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(); 65 66 typedef std::map<std::string, linked_ptr<CrosSettings::ObserverSubscription> > 67 SubscriptionMap; 68 SubscriptionMap pref_subscription_map_; 69 70 content::NotificationRegistrar notification_registrar_; 71 72 UIProxyConfigService proxy_config_service_; 73 }; 74 75 } // namespace options 76 } // namespace chromeos 77 78 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_CORE_CHROMEOS_OPTIONS_HANDLER_H_ 79