OLD | NEW |
---|---|
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/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
11 #include "chrome/browser/chromeos/cros/cros_library.h" | 12 #include "chrome/browser/chromeos/cros/cros_library.h" |
12 #include "chrome/browser/chromeos/cros/network_library.h" | 13 #include "chrome/browser/chromeos/cros/network_library.h" |
13 #include "chrome/browser/ui/webui/about_ui.h" | 14 #include "chrome/browser/ui/webui/about_ui.h" |
14 #include "chromeos/network/network_event_log.h" | 15 #include "chromeos/network/network_event_log.h" |
15 #include "chromeos/network/network_state.h" | 16 #include "chromeos/network/network_state.h" |
16 #include "chromeos/network/network_state_handler.h" | 17 #include "chromeos/network/network_state_handler.h" |
17 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
18 #include "net/base/escape.h" | 19 #include "net/base/escape.h" |
19 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 } | 52 } |
52 | 53 |
53 std::string GetHeaderHtmlInfo(int refresh) { | 54 std::string GetHeaderHtmlInfo(int refresh) { |
54 std::string output; | 55 std::string output; |
55 ::about_ui::AppendHeader(&output, refresh, "About Network"); | 56 ::about_ui::AppendHeader(&output, refresh, "About Network"); |
56 ::about_ui::AppendBody(&output); | 57 ::about_ui::AppendBody(&output); |
57 AppendRefresh(&output, refresh, "network"); | 58 AppendRefresh(&output, refresh, "network"); |
58 return output; | 59 return output; |
59 } | 60 } |
60 | 61 |
61 std::string GetHeaderEventLogInfo() { | 62 std::string GetHeaderEventLogInfo(bool debug) { |
pneubeck (no reviews)
2013/05/13 13:16:25
This function's name is cryptic to me.
stevenjb
2013/05/13 19:36:39
A suggestion would help since it's obviously less
| |
62 std::string output; | 63 std::string output; |
63 output.append(WrapWithH3( | 64 output.append(WrapWithH3( |
64 l10n_util::GetStringUTF8(IDS_ABOUT_NETWORK_EVENT_LOG))); | 65 l10n_util::GetStringUTF8(IDS_ABOUT_NETWORK_EVENT_LOG))); |
65 output.append("<pre style=\"" | 66 output.append("<pre style=\"" |
66 "border-style:solid; border-width:1px; " | 67 "border-style:solid; border-width:1px; " |
67 "overflow: auto; " | 68 "overflow: auto; " |
68 "height:200px;\">"); | 69 "height:200px;\">"); |
70 network_event_log::LogLevel log_level = debug | |
71 ? network_event_log::LOG_LEVEL_DEBUG | |
72 : network_event_log::LOG_LEVEL_EVENT; | |
73 std::string format = debug ? "file,time,desc,html" : "time,desc,html"; | |
69 output.append( | 74 output.append( |
70 network_event_log::GetAsString(network_event_log::NEWEST_FIRST, 0)); | 75 network_event_log::GetAsString(network_event_log::NEWEST_FIRST, |
pneubeck (no reviews)
2013/05/13 13:16:25
creating html content from insecure sources (like
stevenjb
2013/05/13 19:36:39
Yeah, this is long overdue to be replaced with Web
| |
76 format, log_level, 0)); | |
71 output.append("</pre>"); | 77 output.append("</pre>"); |
72 return output; | 78 return output; |
73 } | 79 } |
74 | 80 |
75 // NetworkLibrary tables | 81 // NetworkLibrary tables |
76 | 82 |
77 std::string NetworkToHtmlTableHeader(const Network* network) { | 83 std::string NetworkToHtmlTableHeader(const Network* network) { |
78 std::string str = | 84 std::string str = |
79 WrapWithTH("Name") + | 85 WrapWithTH("Name") + |
80 WrapWithTH("Active") + | 86 WrapWithTH("Active") + |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 } | 289 } |
284 output.append("</table>"); | 290 output.append("</table>"); |
285 return output; | 291 return output; |
286 } | 292 } |
287 | 293 |
288 } // namespace | 294 } // namespace |
289 | 295 |
290 namespace about_ui { | 296 namespace about_ui { |
291 | 297 |
292 std::string AboutNetwork(const std::string& query) { | 298 std::string AboutNetwork(const std::string& query) { |
293 int refresh; | 299 base::StringTokenizer tok(query, "/"); |
gauravsh
2013/05/13 00:34:51
Update the comment for AboutNetwork in about_netwo
pneubeck (no reviews)
2013/05/13 13:16:25
shouldn't this be separated by '&' ?
stevenjb
2013/05/13 19:36:39
We should really have a proper UI here. This is a
| |
294 base::StringToInt(query, &refresh); | 300 int refresh = 0; |
301 bool debug = false; | |
302 while (tok.GetNext()) { | |
303 std::string token = tok.token(); | |
304 if (token == "debug") | |
305 debug = true; | |
306 else | |
307 base::StringToInt(token, &refresh); | |
308 } | |
295 std::string output = GetHeaderHtmlInfo(refresh); | 309 std::string output = GetHeaderHtmlInfo(refresh); |
296 if (network_event_log::IsInitialized()) | 310 if (network_event_log::IsInitialized()) |
297 output += GetHeaderEventLogInfo(); | 311 output += GetHeaderEventLogInfo(debug); |
298 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 312 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
299 ash::switches::kAshDisableNewNetworkStatusArea)) { | 313 ash::switches::kAshDisableNewNetworkStatusArea)) { |
300 output += GetNetworkStateHtmlInfo(); | 314 output += GetNetworkStateHtmlInfo(); |
301 } else { | 315 } else { |
302 output += GetCrosNetworkHtmlInfo(); | 316 output += GetCrosNetworkHtmlInfo(); |
303 } | 317 } |
304 return output; | 318 return output; |
305 } | 319 } |
306 | 320 |
307 } // namespace about_ui | 321 } // namespace about_ui |
308 | 322 |
309 } // namespace chromeos | 323 } // namespace chromeos |
OLD | NEW |