Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Side by Side Diff: chrome/browser/ui/webui/chromeos/about_network.cc

Issue 15350002: Deprecate kAshDisableNewNetworkStatusArea (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/chromeos/about_network.h" 5 #include "chrome/browser/ui/webui/chromeos/about_network.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_tokenizer.h" 10 #include "base/strings/string_tokenizer.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/chromeos/cros/cros_library.h"
13 #include "chrome/browser/chromeos/cros/network_library.h"
14 #include "chrome/browser/ui/webui/about_ui.h" 12 #include "chrome/browser/ui/webui/about_ui.h"
15 #include "chromeos/network/network_event_log.h" 13 #include "chromeos/network/network_event_log.h"
16 #include "chromeos/network/network_state.h" 14 #include "chromeos/network/network_state.h"
17 #include "chromeos/network/network_state_handler.h" 15 #include "chromeos/network/network_state_handler.h"
18 #include "grit/generated_resources.h" 16 #include "grit/generated_resources.h"
19 #include "net/base/escape.h" 17 #include "net/base/escape.h"
20 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
21 19
22 namespace chromeos { 20 namespace chromeos {
23 21
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 : network_event_log::LOG_LEVEL_EVENT; 70 : network_event_log::LOG_LEVEL_EVENT;
73 std::string format = debug ? "file,time,desc,html" : "time,desc,html"; 71 std::string format = debug ? "file,time,desc,html" : "time,desc,html";
74 // network_event_log::GetAsString does HTML escaping. 72 // network_event_log::GetAsString does HTML escaping.
75 output.append( 73 output.append(
76 network_event_log::GetAsString(network_event_log::NEWEST_FIRST, 74 network_event_log::GetAsString(network_event_log::NEWEST_FIRST,
77 format, log_level, 0)); 75 format, log_level, 0));
78 output.append("</pre>"); 76 output.append("</pre>");
79 return output; 77 return output;
80 } 78 }
81 79
82 // NetworkLibrary tables
83
84 std::string NetworkToHtmlTableHeader(const Network* network) {
85 std::string str =
86 WrapWithTH("Name") +
87 WrapWithTH("Active") +
88 WrapWithTH("State");
89 if (network->type() != TYPE_ETHERNET)
90 str += WrapWithTH("Auto-Connect");
91 if (network->type() == TYPE_WIFI ||
92 network->type() == TYPE_CELLULAR) {
93 str += WrapWithTH("Strength");
94 }
95 if (network->type() == TYPE_WIFI) {
96 str += WrapWithTH("Encryption");
97 str += WrapWithTH("Passphrase");
98 str += WrapWithTH("Identity");
99 str += WrapWithTH("Frequency");
100 }
101 if (network->type() == TYPE_CELLULAR) {
102 str += WrapWithTH("Technology");
103 str += WrapWithTH("Connectivity");
104 str += WrapWithTH("Activation");
105 str += WrapWithTH("Roaming");
106 }
107 if (network->type() == TYPE_VPN) {
108 str += WrapWithTH("Host");
109 str += WrapWithTH("Provider Type");
110 str += WrapWithTH("PSK Passphrase");
111 str += WrapWithTH("Username");
112 str += WrapWithTH("User Passphrase");
113 }
114 str += WrapWithTH("Error");
115 str += WrapWithTH("IP Address");
116 return WrapWithTR(str);
117 }
118
119 // Helper function to create an Html table row for a Network.
120 std::string NetworkToHtmlTableRow(const Network* network) {
121 std::string str =
122 WrapWithTD(network->name()) +
123 WrapWithTD(base::IntToString(network->is_active())) +
124 WrapWithTD(network->GetStateString());
125 if (network->type() != TYPE_ETHERNET)
126 str += WrapWithTD(base::IntToString(network->auto_connect()));
127 if (network->type() == TYPE_WIFI ||
128 network->type() == TYPE_CELLULAR) {
129 const WirelessNetwork* wireless =
130 static_cast<const WirelessNetwork*>(network);
131 str += WrapWithTD(base::IntToString(wireless->strength()));
132 }
133 if (network->type() == TYPE_WIFI) {
134 const WifiNetwork* wifi =
135 static_cast<const WifiNetwork*>(network);
136 str += WrapWithTD(wifi->GetEncryptionString());
137 str += WrapWithTD(std::string(wifi->passphrase().length(), '*'));
138 str += WrapWithTD(wifi->identity());
139 str += WrapWithTD(base::IntToString(wifi->frequency()));
140 }
141 if (network->type() == TYPE_CELLULAR) {
142 const CellularNetwork* cell =
143 static_cast<const CellularNetwork*>(network);
144 str += WrapWithTH(cell->GetNetworkTechnologyString());
145 str += WrapWithTH(cell->GetActivationStateString());
146 str += WrapWithTH(cell->GetRoamingStateString());
147 }
148 if (network->type() == TYPE_VPN) {
149 const VirtualNetwork* vpn =
150 static_cast<const VirtualNetwork*>(network);
151 str += WrapWithTH(vpn->server_hostname());
152 str += WrapWithTH(vpn->GetProviderTypeString());
153 str += WrapWithTD(std::string(vpn->psk_passphrase().length(), '*'));
154 str += WrapWithTH(vpn->username());
155 str += WrapWithTD(std::string(vpn->user_passphrase().length(), '*'));
156 }
157 str += WrapWithTD(network->failed() ? network->GetErrorString() : "");
158 str += WrapWithTD(network->ip_address());
159 return WrapWithTR(str);
160 }
161
162 std::string GetCrosNetworkHtmlInfo() {
163 std::string output;
164
165 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary();
166
167 const EthernetNetwork* ethernet = cros->ethernet_network();
168 if (cros->ethernet_enabled() && ethernet) {
169 output.append(WrapWithH3(
170 l10n_util::GetStringUTF8(IDS_ABOUT_NETWORK_ETHERNET)));
171 output.append("<table border=1>");
172 output.append(NetworkToHtmlTableHeader(ethernet));
173 output.append(NetworkToHtmlTableRow(ethernet));
174 output.append("</table>");
175 }
176
177 const WifiNetworkVector& wifi_networks = cros->wifi_networks();
178 if (cros->wifi_enabled() && wifi_networks.size() > 0) {
179 output.append(WrapWithH3(
180 l10n_util::GetStringUTF8(IDS_ABOUT_NETWORK_WIFI)));
181 output.append("<table border=1>");
182 for (size_t i = 0; i < wifi_networks.size(); ++i) {
183 if (i == 0)
184 output.append(NetworkToHtmlTableHeader(wifi_networks[i]));
185 output.append(NetworkToHtmlTableRow(wifi_networks[i]));
186 }
187 output.append("</table>");
188 }
189
190 const CellularNetworkVector& cellular_networks = cros->cellular_networks();
191 if (cros->cellular_enabled() && cellular_networks.size() > 0) {
192 output.append(WrapWithH3(
193 l10n_util::GetStringUTF8(IDS_ABOUT_NETWORK_CELLULAR)));
194 output.append("<table border=1>");
195 for (size_t i = 0; i < cellular_networks.size(); ++i) {
196 if (i == 0)
197 output.append(NetworkToHtmlTableHeader(cellular_networks[i]));
198 output.append(NetworkToHtmlTableRow(cellular_networks[i]));
199 }
200 output.append("</table>");
201 }
202
203 const VirtualNetworkVector& virtual_networks = cros->virtual_networks();
204 if (virtual_networks.size() > 0) {
205 output.append(WrapWithH3(
206 l10n_util::GetStringUTF8(IDS_ABOUT_NETWORK_VIRTUAL)));
207 output.append("<table border=1>");
208 for (size_t i = 0; i < virtual_networks.size(); ++i) {
209 if (i == 0)
210 output.append(NetworkToHtmlTableHeader(virtual_networks[i]));
211 output.append(NetworkToHtmlTableRow(virtual_networks[i]));
212 }
213 output.append("</table>");
214 }
215
216 const WifiNetworkVector& remembered_wifi_networks =
217 cros->remembered_wifi_networks();
218 if (remembered_wifi_networks.size() > 0) {
219 output.append(WrapWithH3(
220 l10n_util::GetStringUTF8(IDS_ABOUT_NETWORK_REMEMBERED_WIFI)));
221 output.append("<table border=1>");
222 for (size_t i = 0; i < remembered_wifi_networks.size(); ++i) {
223 if (i == 0)
224 output.append(NetworkToHtmlTableHeader(remembered_wifi_networks[i]));
225 output.append(NetworkToHtmlTableRow(remembered_wifi_networks[i]));
226 }
227 output.append("</table>");
228 }
229
230 ::about_ui::AppendFooter(&output);
231 return output;
232 }
233
234 // NetworkStateHandler tables
235
236 std::string NetworkStateToHtmlTableHeader() { 80 std::string NetworkStateToHtmlTableHeader() {
237 std::string str = 81 std::string str =
238 WrapWithTH("Name") + 82 WrapWithTH("Name") +
239 WrapWithTH("Type") + 83 WrapWithTH("Type") +
240 WrapWithTH("State") + 84 WrapWithTH("State") +
241 WrapWithTH("Path") + 85 WrapWithTH("Path") +
242 WrapWithTH("Error") + 86 WrapWithTH("Error") +
243 WrapWithTH("IP Addr") + 87 WrapWithTH("IP Addr") +
244 WrapWithTH("Security") + 88 WrapWithTH("Security") +
245 WrapWithTH("Technology") + 89 WrapWithTH("Technology") +
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 while (tok.GetNext()) { 147 while (tok.GetNext()) {
304 std::string token = tok.token(); 148 std::string token = tok.token();
305 if (token == "debug") 149 if (token == "debug")
306 debug = true; 150 debug = true;
307 else 151 else
308 base::StringToInt(token, &refresh); 152 base::StringToInt(token, &refresh);
309 } 153 }
310 std::string output = GetHeaderHtmlInfo(refresh); 154 std::string output = GetHeaderHtmlInfo(refresh);
311 if (network_event_log::IsInitialized()) 155 if (network_event_log::IsInitialized())
312 output += GetEventLogSection(debug); 156 output += GetEventLogSection(debug);
313 if (!CommandLine::ForCurrentProcess()->HasSwitch( 157 output += GetNetworkStateHtmlInfo();
314 ash::switches::kAshDisableNewNetworkStatusArea)) {
315 output += GetNetworkStateHtmlInfo();
316 } else {
317 output += GetCrosNetworkHtmlInfo();
318 }
319 return output; 158 return output;
320 } 159 }
321 160
322 } // namespace about_ui 161 } // namespace about_ui
323 162
324 } // namespace chromeos 163 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698