OLD | NEW |
| (Empty) |
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_OPTIONS2_CHROMEOS_INTERNET_OPTIONS_HANDLER_H_ | |
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_INTERNET_OPTIONS_HANDLER_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/compiler_specific.h" | |
11 #include "chrome/browser/chromeos/cros/network_library.h" | |
12 #include "chrome/browser/chromeos/cros/network_ui_data.h" | |
13 #include "chrome/browser/ui/webui/options2/options_ui.h" | |
14 #include "content/public/browser/notification_registrar.h" | |
15 #include "ui/gfx/native_widget_types.h" | |
16 | |
17 class Browser; | |
18 | |
19 namespace gfx { | |
20 class ImageSkia; | |
21 } | |
22 | |
23 namespace views { | |
24 class WidgetDelegate; | |
25 } | |
26 | |
27 namespace options { | |
28 | |
29 // ChromeOS internet options page UI handler. | |
30 class InternetOptionsHandler | |
31 : public OptionsPageUIHandler, | |
32 public chromeos::NetworkLibrary::NetworkManagerObserver, | |
33 public chromeos::NetworkLibrary::NetworkObserver, | |
34 public chromeos::NetworkLibrary::CellularDataPlanObserver { | |
35 public: | |
36 InternetOptionsHandler(); | |
37 virtual ~InternetOptionsHandler(); | |
38 | |
39 // OptionsPageUIHandler implementation. | |
40 virtual void GetLocalizedValues( | |
41 base::DictionaryValue* localized_strings) OVERRIDE; | |
42 virtual void InitializePage() OVERRIDE; | |
43 | |
44 // WebUIMessageHandler implementation. | |
45 virtual void RegisterMessages() OVERRIDE; | |
46 | |
47 // NetworkLibrary::NetworkManagerObserver implementation. | |
48 virtual void OnNetworkManagerChanged( | |
49 chromeos::NetworkLibrary* network_lib) OVERRIDE; | |
50 // NetworkLibrary::NetworkObserver implementation. | |
51 virtual void OnNetworkChanged(chromeos::NetworkLibrary* network_lib, | |
52 const chromeos::Network* network) OVERRIDE; | |
53 // NetworkLibrary::CellularDataPlanObserver implementation. | |
54 virtual void OnCellularDataPlanChanged( | |
55 chromeos::NetworkLibrary* network_lib) OVERRIDE; | |
56 | |
57 // content::NotificationObserver implementation. | |
58 virtual void Observe(int type, | |
59 const content::NotificationSource& source, | |
60 const content::NotificationDetails& details) OVERRIDE; | |
61 | |
62 private: | |
63 // Opens a modal popup dialog. | |
64 void CreateModalPopup(views::WidgetDelegate* view); | |
65 gfx::NativeWindow GetNativeWindow() const; | |
66 | |
67 // Returns the last active browser. If there is no such browser, creates a new | |
68 // browser window with an empty tab and returns it. | |
69 Browser* GetAppropriateBrowser(); | |
70 | |
71 // Passes data needed to show the details overlay for a network. | |
72 // |args| will be [ network_type, service_path, command ] | |
73 // And command is one of 'options', 'connect', disconnect', 'activate' or | |
74 // 'forget' | |
75 void NetworkCommandCallback(const base::ListValue* args); | |
76 | |
77 // Handle{Wifi,Wimax,Cellular,VPN}ButtonClick handles button click on a | |
78 // wireless, wimax, cellular or VPN network item, respectively. | |
79 void HandleWifiButtonClick(const std::string& service_path, | |
80 const std::string& command); | |
81 void HandleWimaxButtonClick(const std::string& service_path, | |
82 const std::string& command); | |
83 void HandleCellularButtonClick(const std::string& service_path, | |
84 const std::string& command); | |
85 void HandleVPNButtonClick(const std::string& service_path, | |
86 const std::string& command); | |
87 | |
88 // Used to finish up async connection to the |network|. |network| cannot | |
89 // be NULL. | |
90 void DoConnect(chromeos::Network* network); | |
91 | |
92 // Initiates cellular plan data refresh. The results from libcros will be | |
93 // passed through CellularDataPlanChanged() callback method. | |
94 // |args| will be [ service_path ] | |
95 void RefreshCellularPlanCallback(const base::ListValue* args); | |
96 void SetActivationButtonVisibility( | |
97 const chromeos::CellularNetwork* cellular, | |
98 base::DictionaryValue* dictionary, | |
99 const std::string& carrier_id); | |
100 | |
101 void SetPreferNetworkCallback(const base::ListValue* args); | |
102 void SetAutoConnectCallback(const base::ListValue* args); | |
103 void SetSharedCallback(const base::ListValue* args); | |
104 void SetIPConfigCallback(const base::ListValue* args); | |
105 void EnableWifiCallback(const base::ListValue* args); | |
106 void DisableWifiCallback(const base::ListValue* args); | |
107 void EnableCellularCallback(const base::ListValue* args); | |
108 void DisableCellularCallback(const base::ListValue* args); | |
109 void EnableWimaxCallback(const base::ListValue* args); | |
110 void DisableWimaxCallback(const base::ListValue* args); | |
111 void BuyDataPlanCallback(const base::ListValue* args); | |
112 void SetApnCallback(const base::ListValue* args); | |
113 void SetSimCardLockCallback(const base::ListValue* args); | |
114 void ChangePinCallback(const base::ListValue* args); | |
115 void ShareNetworkCallback(const base::ListValue* args); | |
116 void ShowMorePlanInfoCallback(const base::ListValue* args); | |
117 void RefreshNetworksCallback(const base::ListValue* args); | |
118 | |
119 /** | |
120 * Toggle airplane mode. Disables all wireless networks when activated. | |
121 * Celluar and Bluetooth connections remain disabled while active, but | |
122 * Wi-Fi can be reactivated. |args| is unused. | |
123 */ | |
124 void ToggleAirplaneModeCallback(const ListValue* args); | |
125 | |
126 // Populates the ui with the details of the given device path. This forces | |
127 // an overlay to be displayed in the UI. | |
128 void PopulateDictionaryDetails(const chromeos::Network* network); | |
129 // This is the second half of PopulateDictionaryDetails after the asynchronous | |
130 // request for Shill's service properties. | |
131 void PopulateDictionaryDetailsCallback( | |
132 const chromeos::Network* network, | |
133 const std::string& service_path, | |
134 const base::DictionaryValue* shill_properties); | |
135 void PopulateWifiDetails(const chromeos::WifiNetwork* wifi, | |
136 base::DictionaryValue* dictionary); | |
137 void PopulateWimaxDetails(const chromeos::WimaxNetwork* wimax, | |
138 base::DictionaryValue* dictionary); | |
139 void PopulateCellularDetails(const chromeos::CellularNetwork* cellular, | |
140 base::DictionaryValue* dictionary); | |
141 void PopulateVPNDetails(const chromeos::VirtualNetwork* vpn, | |
142 base::DictionaryValue* dictionary); | |
143 | |
144 // Converts CellularDataPlan structure into dictionary for JS. Formats plan | |
145 // settings into human readable texts. | |
146 base::DictionaryValue* CellularDataPlanToDictionary( | |
147 const chromeos::CellularDataPlan* plan); | |
148 | |
149 // Converts CellularApn stuct into dictionary for JS. | |
150 base::DictionaryValue* CreateDictionaryFromCellularApn( | |
151 const chromeos::CellularApn& apn); | |
152 | |
153 // Creates the map of wired networks. | |
154 base::ListValue* GetWiredList(); | |
155 // Creates the map of wireless networks. | |
156 base::ListValue* GetWirelessList(); | |
157 // Creates the map of virtual networks. | |
158 base::ListValue* GetVPNList(); | |
159 // Creates the map of remembered networks. | |
160 base::ListValue* GetRememberedList(); | |
161 // Fills network information into JS dictionary for displaying network lists. | |
162 void FillNetworkInfo(base::DictionaryValue* dictionary); | |
163 // Refreshes the display of network information. | |
164 void RefreshNetworkData(); | |
165 // Adds observers for wireless networks, if any, so that we can dynamically | |
166 // display the correct icon for that network's signal strength and, in the | |
167 // case of cellular networks, network technology and roaming status. | |
168 void MonitorNetworks(); | |
169 | |
170 // Stores a dictionary under |key| in |settings| that is suitable to be sent | |
171 // to the webui that contains the actual value of a setting and whether it's | |
172 // controlled by policy. Takes ownership of |value|. | |
173 void SetValueDictionary(DictionaryValue* settings, | |
174 const char* key, | |
175 base::Value* value, | |
176 const chromeos::NetworkPropertyUIData& ui_data); | |
177 | |
178 // Convenience pointer to netwrok library (will not change). | |
179 chromeos::NetworkLibrary* cros_; | |
180 | |
181 content::NotificationRegistrar registrar_; | |
182 | |
183 // Weak pointer factory so we can start connections at a later time | |
184 // without worrying that they will actually try to happen after the lifetime | |
185 // of this object. | |
186 base::WeakPtrFactory<InternetOptionsHandler> weak_factory_; | |
187 | |
188 DISALLOW_COPY_AND_ASSIGN(InternetOptionsHandler); | |
189 }; | |
190 | |
191 } // namespace options | |
192 | |
193 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_INTERNET_OPTIONS_HANDLER_H_ | |
OLD | NEW |