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_INTERNET_OPTIONS_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_INTERNET_OPTIONS_HANDLER_H_
10 #include "base/compiler_specific.h"
11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/ui/webui/options/options_ui.h"
13 #include "chromeos/network/network_state_handler_observer.h"
14 #include "ui/gfx/native_widget_types.h"
22 class NetworkStateHandlerObserver;
36 // ChromeOS internet options page UI handler.
37 class InternetOptionsHandler
38 : public ::options::OptionsPageUIHandler,
39 public chromeos::NetworkStateHandlerObserver {
41 InternetOptionsHandler();
42 virtual ~InternetOptionsHandler();
45 // OptionsPageUIHandler
46 virtual void GetLocalizedValues(
47 base::DictionaryValue* localized_strings) override;
48 virtual void InitializePage() override;
50 // WebUIMessageHandler (from OptionsPageUIHandler)
51 virtual void RegisterMessages() override;
53 // Callbacks to set network state properties.
54 void ShowMorePlanInfoCallback(const base::ListValue* args);
55 void SetApnCallback(const base::ListValue* args);
56 void SetApnProperties(const base::ListValue* args,
57 const std::string& service_path,
58 const base::DictionaryValue& shill_properties);
59 void CarrierStatusCallback();
60 void SetCarrierCallback(const base::ListValue* args);
61 void SimOperationCallback(const base::ListValue* args);
63 // networkingPrvate callbacks
64 void DisableNetworkTypeCallback(const base::ListValue* args);
65 void EnableNetworkTypeCallback(const base::ListValue* args);
66 void GetManagedPropertiesCallback(const base::ListValue* args);
67 void RequestNetworkScanCallback(const base::ListValue* args);
68 void StartConnectCallback(const base::ListValue* args);
69 void StartDisconnectCallback(const base::ListValue* args);
71 // Retrieves a data url for a resource.
72 std::string GetIconDataUrl(int resource_id) const;
74 // Refreshes the display of network information.
75 void RefreshNetworkData();
77 // Updates the display of network connection information for the details page
79 void UpdateConnectionData(const std::string& service_path);
81 // Callback for ManagedNetworkConnectionHandler::GetManagedProperties.
82 // Calls the JS callback |js_callback_function| with the result.
83 void GetManagedPropertiesResult(const std::string& js_callback_function,
84 const std::string& service_path,
85 const base::DictionaryValue& onc_properties);
87 // Called when carrier data has been updated to informs the JS.
90 // NetworkStateHandlerObserver
91 virtual void DeviceListChanged() override;
92 virtual void NetworkListChanged() override;
93 virtual void NetworkConnectionStateChanged(
94 const chromeos::NetworkState* network) override;
95 virtual void NetworkPropertiesUpdated(
96 const chromeos::NetworkState* network) override;
97 virtual void DevicePropertiesUpdated(
98 const chromeos::DeviceState* device) override;
100 // Updates the logged in user type.
101 void UpdateLoggedInUserType();
103 // Additional callbacks to set network state properties.
104 void SetServerHostnameCallback(const base::ListValue* args);
105 void SetPreferNetworkCallback(const base::ListValue* args);
106 void SetAutoConnectCallback(const base::ListValue* args);
107 void SetIPConfigCallback(const base::ListValue* args);
108 void SetIPConfigProperties(const base::ListValue* args,
109 const std::string& service_path,
110 const base::DictionaryValue& shill_properties);
112 // Gets the native window for hosting dialogs, etc.
113 gfx::NativeWindow GetNativeWindow() const;
115 // Gets the UI scale factor.
116 float GetScaleFactor() const;
118 // Gets the user PrefService associated with the WebUI.
119 const PrefService* GetPrefs() const;
121 // Additional callbacks for managing networks.
122 void AddConnection(const base::ListValue* args);
123 void ConfigureNetwork(const base::ListValue* args);
124 void ActivateNetwork(const base::ListValue* args);
125 void RemoveNetwork(const base::ListValue* args);
127 // Creates the map of wired networks.
128 base::ListValue* GetWiredList();
130 // Creates the map of wireless networks.
131 base::ListValue* GetWirelessList();
133 // Creates the map of virtual networks.
134 base::ListValue* GetVPNList();
136 // Creates the map of remembered networks.
137 base::ListValue* GetRememberedList();
139 // Fills network information into JS dictionary for displaying network lists.
140 void FillNetworkInfo(base::DictionaryValue* dictionary);
142 // Keep track of the service path for the network shown in the Details view.
143 std::string details_path_;
145 // Weak pointer factory so we can start connections at a later time
146 // without worrying that they will actually try to happen after the lifetime
148 base::WeakPtrFactory<InternetOptionsHandler> weak_factory_;
150 DISALLOW_COPY_AND_ASSIGN(InternetOptionsHandler);
153 } // namespace options
154 } // namespace chromeos
156 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_INTERNET_OPTIONS_HANDLER_H_