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 GetEventLogSection(bool debug) { |
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"; |
| 74 // network_event_log::GetAsString does HTML escaping. |
69 output.append( | 75 output.append( |
70 network_event_log::GetAsString(network_event_log::NEWEST_FIRST, 0)); | 76 network_event_log::GetAsString(network_event_log::NEWEST_FIRST, |
| 77 format, log_level, 0)); |
71 output.append("</pre>"); | 78 output.append("</pre>"); |
72 return output; | 79 return output; |
73 } | 80 } |
74 | 81 |
75 // NetworkLibrary tables | 82 // NetworkLibrary tables |
76 | 83 |
77 std::string NetworkToHtmlTableHeader(const Network* network) { | 84 std::string NetworkToHtmlTableHeader(const Network* network) { |
78 std::string str = | 85 std::string str = |
79 WrapWithTH("Name") + | 86 WrapWithTH("Name") + |
80 WrapWithTH("Active") + | 87 WrapWithTH("Active") + |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 } | 290 } |
284 output.append("</table>"); | 291 output.append("</table>"); |
285 return output; | 292 return output; |
286 } | 293 } |
287 | 294 |
288 } // namespace | 295 } // namespace |
289 | 296 |
290 namespace about_ui { | 297 namespace about_ui { |
291 | 298 |
292 std::string AboutNetwork(const std::string& query) { | 299 std::string AboutNetwork(const std::string& query) { |
293 int refresh; | 300 base::StringTokenizer tok(query, "/"); |
294 base::StringToInt(query, &refresh); | 301 int refresh = 0; |
| 302 bool debug = false; |
| 303 while (tok.GetNext()) { |
| 304 std::string token = tok.token(); |
| 305 if (token == "debug") |
| 306 debug = true; |
| 307 else |
| 308 base::StringToInt(token, &refresh); |
| 309 } |
295 std::string output = GetHeaderHtmlInfo(refresh); | 310 std::string output = GetHeaderHtmlInfo(refresh); |
296 if (network_event_log::IsInitialized()) | 311 if (network_event_log::IsInitialized()) |
297 output += GetHeaderEventLogInfo(); | 312 output += GetEventLogSection(debug); |
298 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 313 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
299 ash::switches::kAshDisableNewNetworkStatusArea)) { | 314 ash::switches::kAshDisableNewNetworkStatusArea)) { |
300 output += GetNetworkStateHtmlInfo(); | 315 output += GetNetworkStateHtmlInfo(); |
301 } else { | 316 } else { |
302 output += GetCrosNetworkHtmlInfo(); | 317 output += GetCrosNetworkHtmlInfo(); |
303 } | 318 } |
304 return output; | 319 return output; |
305 } | 320 } |
306 | 321 |
307 } // namespace about_ui | 322 } // namespace about_ui |
308 | 323 |
309 } // namespace chromeos | 324 } // namespace chromeos |
OLD | NEW |