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_OPTIONS_CHROMEOS_INTERNET_OPTIONS_HANDLER_H_ | |
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_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/options/options_ui.h" | |
14 #include "content/public/browser/notification_registrar.h" | |
15 #include "ui/gfx/native_widget_types.h" | |
16 | |
17 class SkBitmap; | |
18 namespace views { | |
19 class WidgetDelegate; | |
20 } | |
21 | |
22 // ChromeOS internet options page UI handler. | |
23 class InternetOptionsHandler | |
24 : public OptionsPageUIHandler, | |
25 public chromeos::NetworkLibrary::NetworkManagerObserver, | |
26 public chromeos::NetworkLibrary::NetworkObserver, | |
27 public chromeos::NetworkLibrary::CellularDataPlanObserver { | |
28 public: | |
29 InternetOptionsHandler(); | |
30 virtual ~InternetOptionsHandler(); | |
31 | |
32 // OptionsPageUIHandler implementation. | |
33 virtual void GetLocalizedValues( | |
34 base::DictionaryValue* localized_strings) OVERRIDE; | |
35 virtual void InitializeHandler() OVERRIDE; | |
36 | |
37 // WebUIMessageHandler implementation. | |
38 virtual void RegisterMessages() OVERRIDE; | |
39 | |
40 // NetworkLibrary::NetworkManagerObserver implementation. | |
41 virtual void OnNetworkManagerChanged( | |
42 chromeos::NetworkLibrary* network_lib) OVERRIDE; | |
43 // NetworkLibrary::NetworkObserver implementation. | |
44 virtual void OnNetworkChanged(chromeos::NetworkLibrary* network_lib, | |
45 const chromeos::Network* network) OVERRIDE; | |
46 // NetworkLibrary::CellularDataPlanObserver implementation. | |
47 virtual void OnCellularDataPlanChanged( | |
48 chromeos::NetworkLibrary* network_lib) OVERRIDE; | |
49 | |
50 // content::NotificationObserver implementation. | |
51 virtual void Observe(int type, | |
52 const content::NotificationSource& source, | |
53 const content::NotificationDetails& details) OVERRIDE; | |
54 | |
55 private: | |
56 // Opens a modal popup dialog. | |
57 void CreateModalPopup(views::WidgetDelegate* view); | |
58 gfx::NativeWindow GetNativeWindow() const; | |
59 | |
60 // Passes data needed to show details overlay for network. | |
61 // |args| will be [ network_type, service_path, command ] | |
62 // And command is one of 'options', 'connect', disconnect', 'activate' or | |
63 // 'forget' | |
64 // Handle{Wifi,Cellular}ButtonClick handles button click on a wireless | |
65 // network item and a cellular network item respectively. | |
66 void ButtonClickCallback(const base::ListValue* args); | |
67 void HandleWifiButtonClick(const std::string& service_path, | |
68 const std::string& command); | |
69 void HandleCellularButtonClick(const std::string& service_path, | |
70 const std::string& command); | |
71 void HandleVPNButtonClick(const std::string& service_path, | |
72 const std::string& command); | |
73 | |
74 // Initiates cellular plan data refresh. The results from libcros will be | |
75 // passed through CellularDataPlanChanged() callback method. | |
76 // |args| will be [ service_path ] | |
77 void RefreshCellularPlanCallback(const base::ListValue* args); | |
78 void SetActivationButtonVisibility( | |
79 const chromeos::CellularNetwork* cellular, | |
80 base::DictionaryValue* dictionary, | |
81 const std::string& carrier_id); | |
82 | |
83 void SetPreferNetworkCallback(const base::ListValue* args); | |
84 void SetAutoConnectCallback(const base::ListValue* args); | |
85 void SetSharedCallback(const base::ListValue* args); | |
86 void SetIPConfigCallback(const base::ListValue* args); | |
87 void EnableWifiCallback(const base::ListValue* args); | |
88 void DisableWifiCallback(const base::ListValue* args); | |
89 void EnableCellularCallback(const base::ListValue* args); | |
90 void DisableCellularCallback(const base::ListValue* args); | |
91 void BuyDataPlanCallback(const base::ListValue* args); | |
92 void SetApnCallback(const base::ListValue* args); | |
93 void SetSimCardLockCallback(const base::ListValue* args); | |
94 void ChangePinCallback(const base::ListValue* args); | |
95 void ShareNetworkCallback(const base::ListValue* args); | |
96 void ShowMorePlanInfoCallback(const ListValue* args); | |
97 | |
98 // Populates the ui with the details of the given device path. This forces | |
99 // an overlay to be displayed in the UI. | |
100 void PopulateDictionaryDetails(const chromeos::Network* network); | |
101 void PopulateWifiDetails(const chromeos::WifiNetwork* wifi, | |
102 base::DictionaryValue* dictionary); | |
103 void PopulateCellularDetails(const chromeos::CellularNetwork* cellular, | |
104 base::DictionaryValue* dictionary); | |
105 void PopulateVPNDetails(const chromeos::VirtualNetwork* vpn, | |
106 base::DictionaryValue* dictionary); | |
107 | |
108 // Converts CellularDataPlan structure into dictionary for JS. Formats plan | |
109 // settings into human readable texts. | |
110 base::DictionaryValue* CellularDataPlanToDictionary( | |
111 const chromeos::CellularDataPlan* plan); | |
112 | |
113 // Converts CellularApn stuct into dictionary for JS. | |
114 base::DictionaryValue* CreateDictionaryFromCellularApn( | |
115 const chromeos::CellularApn& apn); | |
116 | |
117 // Creates the map of wired networks. | |
118 base::ListValue* GetWiredList(); | |
119 // Creates the map of wireless networks. | |
120 base::ListValue* GetWirelessList(); | |
121 // Creates the map of virtual networks. | |
122 base::ListValue* GetVPNList(); | |
123 // Creates the map of remembered networks. | |
124 base::ListValue* GetRememberedList(); | |
125 // Fills network information into JS dictionary for displaying network lists. | |
126 void FillNetworkInfo(base::DictionaryValue* dictionary); | |
127 // Refreshes the display of network information. | |
128 void RefreshNetworkData(); | |
129 // Adds observers for wireless networks, if any, so that we can dynamically | |
130 // display the correct icon for that network's signal strength and, in the | |
131 // case of cellular networks, network technology and roaming status. | |
132 void MonitorNetworks(); | |
133 | |
134 // Stores a dictionary under |key| in |settings| that is suitable to be sent | |
135 // to the webui that contains the actual value of a setting and whether it's | |
136 // controlled by policy. Takes ownership of |value|. | |
137 void SetValueDictionary(DictionaryValue* settings, | |
138 const char* key, | |
139 base::Value* value, | |
140 const chromeos::NetworkPropertyUIData& ui_data); | |
141 | |
142 // Convenience pointer to netwrok library (will not change). | |
143 chromeos::NetworkLibrary* cros_; | |
144 | |
145 content::NotificationRegistrar registrar_; | |
146 | |
147 DISALLOW_COPY_AND_ASSIGN(InternetOptionsHandler); | |
148 }; | |
149 | |
150 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_INTERNET_OPTIONS_HANDLER_H_ | |
OLD | NEW |