diff options
author | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-21 01:38:01 +0000 |
---|---|---|
committer | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-21 01:38:01 +0000 |
commit | 669b00108d1fecc502994cb6350dc6d29465c906 (patch) | |
tree | 844b7256f913a5734de89424abe5b4a1d8d96444 /chrome | |
parent | d8961a2693062bca1a6a5c899c76ac4ceb4a59f4 (diff) | |
download | chromium_src-669b00108d1fecc502994cb6350dc6d29465c906.zip chromium_src-669b00108d1fecc502994cb6350dc6d29465c906.tar.gz chromium_src-669b00108d1fecc502994cb6350dc6d29465c906.tar.bz2 |
Add NetworkEventLog and NetworkEventLogSource to log chromeos network events
This also extracts about_network from about_ui for the chrome://network UI, updating it for NetworkState and NetworkEventLog.
Additionally network event logs (and a dbus summary) are added to feedback reports)
BUG=161369
For chrome/browser/ui/webui/:
TBR=jhawkins@chromium.org
Review URL: https://chromiumcodereview.appspot.com/11416041
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168946 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/generated_resources.grd | 29 | ||||
-rw-r--r-- | chrome/browser/chromeos/chrome_browser_main_chromeos.cc | 6 | ||||
-rw-r--r-- | chrome/browser/chromeos/system/syslogs_provider.cc | 7 | ||||
-rw-r--r-- | chrome/browser/chromeos/system_logs/network_event_log_source.cc | 29 | ||||
-rw-r--r-- | chrome/browser/chromeos/system_logs/network_event_log_source.h | 27 | ||||
-rw-r--r-- | chrome/browser/chromeos/system_logs/system_logs_fetcher.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/webui/about_ui.cc | 187 | ||||
-rw-r--r-- | chrome/browser/ui/webui/about_ui.h | 10 | ||||
-rw-r--r-- | chrome/browser/ui/webui/chromeos/about_network.cc | 296 | ||||
-rw-r--r-- | chrome/browser/ui/webui/chromeos/about_network.h | 21 | ||||
-rw-r--r-- | chrome/chrome_browser_chromeos.gypi | 2 | ||||
-rw-r--r-- | chrome/chrome_browser_ui.gypi | 2 |
12 files changed, 446 insertions, 172 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 445ced7..5af085e 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -10059,6 +10059,35 @@ Would you like to start <ph name="CONTROL_PANEL_APPLET_NAME">$1<ex>Add/Remove Pr You have switched to the <ph name="CHANNEL_NAME">$1<ex>Stable</ex></ph> channel. </message> + <!-- chrome://network --> + <message name="IDS_ABOUT_AUTO_REFRESH" desc="The message to indicate that the page is auto refreshing."> + (Auto-refreshing page every <ph name="INTERVAL_SECONDS">$1<ex>10</ex></ph> seconds.) + </message> + <message name="IDS_ABOUT_AUTO_REFRESH_INFO" desc="The message to indicate that how to auto refresh the page."> + (To auto-refresh this page use chrome://<ph name="PAGE_NAME">$1<ex>network</ex></ph>/&lt;secs&gt;) + </message> + <message name="IDS_ABOUT_NETWORK_EVENT_LOG" desc="The section title for the event log in the chrome://network page."> + Event Log (newest first): + </message> + <message name="IDS_ABOUT_NETWORK_NETWORKS" desc="The section title for all networks in the chrome://network page."> + Networks: + </message> + <message name="IDS_ABOUT_NETWORK_ETHERNET" desc="The section title for ethernet networks in the chrome://network page."> + Ethernet Networks: + </message> + <message name="IDS_ABOUT_NETWORK_WIFI" desc="The section title for wifi networks in the chrome://network page."> + Wifi Networks: + </message> + <message name="IDS_ABOUT_NETWORK_CELLULAR" desc="The section title for cellular networks in the chrome://network page."> + Cellular Networks: + </message> + <message name="IDS_ABOUT_NETWORK_VIRTUAL" desc="The section title for virtual networks in the chrome://network page."> + Virtual Networks: + </message> + <message name="IDS_ABOUT_NETWORK_REMEMBERED_WIFI" desc="The section title for remembered wifi networks in the chrome://network page."> + Remembered Wifi Networks: + </message> + <message name="IDS_OPTIONS_STARTUP_GROUP_NAME" desc="The title of the startup group"> On startup </message> diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc index 4acd1ca..0502586 100644 --- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc +++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc @@ -80,6 +80,7 @@ #include "chromeos/dbus/session_manager_client.h" #include "chromeos/disks/disk_mount_manager.h" #include "chromeos/display/output_configurator.h" +#include "chromeos/network/network_event_log.h" #include "chromeos/network/network_state_handler.h" #include "chromeos/power/power_state_override.h" #include "content/public/browser/notification_service.h" @@ -269,6 +270,7 @@ class DBusServices { if (!CommandLine::ForCurrentProcess()->HasSwitch( chromeos::switches::kEnableNewNetworkHandlers)) return; + chromeos::network_event_log::Initialize(); chromeos::NetworkStateHandler::Initialize(); network_handlers_initialized_ = true; } @@ -282,8 +284,10 @@ class DBusServices { if (cros_initialized_ && CrosLibrary::Get()) CrosLibrary::Shutdown(); - if (network_handlers_initialized_) + if (network_handlers_initialized_) { chromeos::NetworkStateHandler::Shutdown(); + chromeos::network_event_log::Shutdown(); + } cryptohome::AsyncMethodCaller::Shutdown(); disks::DiskMountManager::Shutdown(); diff --git a/chrome/browser/chromeos/system/syslogs_provider.cc b/chrome/browser/chromeos/system/syslogs_provider.cc index f3d70bc..693e44a 100644 --- a/chrome/browser/chromeos/system/syslogs_provider.cc +++ b/chrome/browser/chromeos/system/syslogs_provider.cc @@ -16,7 +16,9 @@ #include "base/string_util.h" #include "chrome/browser/memory_details.h" #include "chrome/common/chrome_switches.h" +#include "chromeos/network/network_event_log.h" #include "content/public/browser/browser_thread.h" +#include "dbus/dbus_statistics.h" using content::BrowserThread; @@ -292,6 +294,11 @@ void SyslogsProviderImpl::ReadSyslogs( file_util::Delete(zip_file, false); } + // Include recent network log events + const int kMaxNetworkEventsForFeedback = 50; + (*logs)["network_event_log"] = chromeos::network_event_log::GetAsString( + chromeos::network_event_log::OLDEST_FIRST, kMaxNetworkEventsForFeedback); + // SyslogsMemoryHandler will clean itself up. // SyslogsMemoryHandler::OnDetailsAvailable() will modify |logs| and call // request->ForwardResult(logs, zip_content). diff --git a/chrome/browser/chromeos/system_logs/network_event_log_source.cc b/chrome/browser/chromeos/system_logs/network_event_log_source.cc new file mode 100644 index 0000000..5fdcc68 --- /dev/null +++ b/chrome/browser/chromeos/system_logs/network_event_log_source.cc @@ -0,0 +1,29 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/chromeos/system_logs/network_event_log_source.h" + +#include "base/message_loop.h" +#include "chrome/browser/chromeos/system_logs/system_logs_fetcher.h" +#include "chromeos/network/network_event_log.h" +#include "content/public/browser/browser_thread.h" + +namespace chromeos { + +namespace { +const char kNetworkEventLogEntry[] = "network_event_log"; +} + +void NetworkEventLogSource::Fetch(const SysLogsSourceCallback& callback) { + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + DCHECK(!callback.is_null()); + + scoped_ptr<SystemLogsResponse> response(new SystemLogsResponse); + const int kMaxNetworkEventsForAboutSystem = 200; + (*response)[kNetworkEventLogEntry] = network_event_log::GetAsString( + network_event_log::OLDEST_FIRST, kMaxNetworkEventsForAboutSystem); + callback.Run(response.get()); +} + +} // namespace chromeos diff --git a/chrome/browser/chromeos/system_logs/network_event_log_source.h b/chrome/browser/chromeos/system_logs/network_event_log_source.h new file mode 100644 index 0000000..0c4e5e7 --- /dev/null +++ b/chrome/browser/chromeos/system_logs/network_event_log_source.h @@ -0,0 +1,27 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROMEOS_SYSTEM_LOGS_NETWORK_EVENT_LOG_SOURCE_H_ +#define CHROME_BROWSER_CHROMEOS_SYSTEM_LOGS_NETWORK_EVENT_LOG_SOURCE_H_ + +#include "chrome/browser/chromeos/system_logs/system_logs_fetcher.h" + +namespace chromeos { + +// Fetches memory usage details. +class NetworkEventLogSource : public SystemLogsSource { + public: + NetworkEventLogSource() {} + virtual ~NetworkEventLogSource() {} + + // SystemLogsSource override. + virtual void Fetch(const SysLogsSourceCallback& request) OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(NetworkEventLogSource); +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_SYSTEM_LOGS_NETWORK_EVENT_LOG_SOURCE_H_ diff --git a/chrome/browser/chromeos/system_logs/system_logs_fetcher.cc b/chrome/browser/chromeos/system_logs/system_logs_fetcher.cc index 446278e..a25e0c7 100644 --- a/chrome/browser/chromeos/system_logs/system_logs_fetcher.cc +++ b/chrome/browser/chromeos/system_logs/system_logs_fetcher.cc @@ -11,6 +11,7 @@ #include "chrome/browser/chromeos/system_logs/debug_daemon_log_source.h" #include "chrome/browser/chromeos/system_logs/lsb_release_log_source.h" #include "chrome/browser/chromeos/system_logs/memory_details_log_source.h" +#include "chrome/browser/chromeos/system_logs/network_event_log_source.h" #include "content/public/browser/browser_thread.h" using content::BrowserThread; @@ -29,6 +30,7 @@ SystemLogsFetcher::SystemLogsFetcher() data_sources_.push_back(new DBusLogSource()); data_sources_.push_back(new LsbReleaseLogSource()); data_sources_.push_back(new MemoryDetailsLogSource()); + data_sources_.push_back(new NetworkEventLogSource()); num_pending_requests_ = data_sources_.size(); } diff --git a/chrome/browser/ui/webui/about_ui.cc b/chrome/browser/ui/webui/about_ui.cc index a415cc1..bd7b8ff 100644 --- a/chrome/browser/ui/webui/about_ui.cc +++ b/chrome/browser/ui/webui/about_ui.cc @@ -74,10 +74,9 @@ #endif #if defined(OS_CHROMEOS) -#include "chrome/browser/chromeos/cros/cros_library.h" -#include "chrome/browser/chromeos/cros/network_library.h" #include "chrome/browser/chromeos/customization_document.h" #include "chrome/browser/chromeos/memory/oom_priority_manager.h" +#include "chrome/browser/ui/webui/chromeos/about_network.h" #endif #if defined(USE_ASH) @@ -232,8 +231,12 @@ class ChromeOSTermsHandler #endif +} // namespace + // Individual about handlers --------------------------------------------------- +namespace about_ui { + void AppendHeader(std::string* output, int refresh, const std::string& unescaped_title) { output->append("<!DOCTYPE HTML>\n<html>\n<head>\n"); @@ -258,6 +261,14 @@ void AppendFooter(std::string *output) { output->append("</body>\n</html>\n"); } +} // namespace about_ui + +using about_ui::AppendHeader; +using about_ui::AppendBody; +using about_ui::AppendFooter; + +namespace { + std::string ChromeURLs() { std::string html; AppendHeader(&html, 0, "Chrome URLs"); @@ -281,18 +292,12 @@ std::string ChromeURLs() { #if defined(OS_CHROMEOS) // Html output helper functions -// TODO(stevenjb): L10N this. // Helper function to wrap HTML with a tag. std::string WrapWithTag(const std::string& tag, const std::string& text) { return "<" + tag + ">" + text + "</" + tag + ">"; } -// Helper function to wrap Html with <th> tag. -std::string WrapWithTH(const std::string& text) { - return "<th>" + text + "</th>"; -} - // Helper function to wrap Html with <td> tag. std::string WrapWithTD(const std::string& text) { return "<td>" + text + "</td>"; @@ -303,168 +308,6 @@ std::string WrapWithTR(const std::string& text) { return "<tr>" + text + "</tr>"; } -void AppendRefresh(std::string *output, int refresh, const std::string& name) { - if (refresh > 0) { - output->append("(Auto-refreshing page every "); - output->append(base::IntToString(refresh)); - output->append("s)"); - } else { - output->append("(To auto-refresh this page: about:"); - output->append(name); - output->append("/<secs>)"); - } -} - -// Helper function to create an Html table header for a Network. -std::string ToHtmlTableHeader(const chromeos::Network* network) { - std::string str = - WrapWithTH("Name") + - WrapWithTH("Active") + - WrapWithTH("State"); - if (network->type() == chromeos::TYPE_WIFI || - network->type() == chromeos::TYPE_CELLULAR) { - str += WrapWithTH("Auto-Connect"); - str += WrapWithTH("Strength"); - } - if (network->type() == chromeos::TYPE_WIFI) { - str += WrapWithTH("Encryption"); - str += WrapWithTH("Passphrase"); - str += WrapWithTH("Identity"); - str += WrapWithTH("Frequency"); - } - if (network->type() == chromeos::TYPE_CELLULAR) { - str += WrapWithTH("Technology"); - str += WrapWithTH("Connectivity"); - str += WrapWithTH("Activation"); - str += WrapWithTH("Roaming"); - } - if (network->type() == chromeos::TYPE_VPN) { - str += WrapWithTH("Host"); - str += WrapWithTH("Provider Type"); - str += WrapWithTH("PSK Passphrase"); - str += WrapWithTH("Username"); - str += WrapWithTH("User Passphrase"); - } - str += WrapWithTH("Error"); - str += WrapWithTH("IP Address"); - return WrapWithTR(str); -} - -// Helper function to create an Html table row for a Network. -std::string ToHtmlTableRow(const chromeos::Network* network) { - std::string str = - WrapWithTD(network->name()) + - WrapWithTD(base::IntToString(network->is_active())) + - WrapWithTD(network->GetStateString()); - if (network->type() == chromeos::TYPE_WIFI || - network->type() == chromeos::TYPE_CELLULAR) { - const chromeos::WirelessNetwork* wireless = - static_cast<const chromeos::WirelessNetwork*>(network); - str += WrapWithTD(base::IntToString(wireless->auto_connect())); - str += WrapWithTD(base::IntToString(wireless->strength())); - } - if (network->type() == chromeos::TYPE_WIFI) { - const chromeos::WifiNetwork* wifi = - static_cast<const chromeos::WifiNetwork*>(network); - str += WrapWithTD(wifi->GetEncryptionString()); - str += WrapWithTD(std::string(wifi->passphrase().length(), '*')); - str += WrapWithTD(wifi->identity()); - str += WrapWithTD(base::IntToString(wifi->frequency())); - } - if (network->type() == chromeos::TYPE_CELLULAR) { - const chromeos::CellularNetwork* cell = - static_cast<const chromeos::CellularNetwork*>(network); - str += WrapWithTH(cell->GetNetworkTechnologyString()); - str += WrapWithTH(cell->GetActivationStateString()); - str += WrapWithTH(cell->GetRoamingStateString()); - } - if (network->type() == chromeos::TYPE_VPN) { - const chromeos::VirtualNetwork* vpn = - static_cast<const chromeos::VirtualNetwork*>(network); - str += WrapWithTH(vpn->server_hostname()); - str += WrapWithTH(vpn->GetProviderTypeString()); - str += WrapWithTD(std::string(vpn->psk_passphrase().length(), '*')); - str += WrapWithTH(vpn->username()); - str += WrapWithTD(std::string(vpn->user_passphrase().length(), '*')); - } - str += WrapWithTD(network->failed() ? network->GetErrorString() : ""); - str += WrapWithTD(network->ip_address()); - return WrapWithTR(str); -} - -std::string GetNetworkHtmlInfo(int refresh) { - chromeos::NetworkLibrary* cros = - chromeos::CrosLibrary::Get()->GetNetworkLibrary(); - std::string output; - AppendHeader(&output, refresh, "About Network"); - AppendBody(&output); - AppendRefresh(&output, refresh, "network"); - - if (cros->ethernet_enabled()) { - output.append("<h3>Ethernet:</h3><table border=1>"); - const chromeos::EthernetNetwork* ethernet = cros->ethernet_network(); - if (ethernet) { - output.append(ToHtmlTableHeader(ethernet)); - output.append(ToHtmlTableRow(ethernet)); - } - } - - if (cros->wifi_enabled()) { - output.append("</table><h3>Wifi Networks:</h3><table border=1>"); - const chromeos::WifiNetworkVector& wifi_networks = cros->wifi_networks(); - for (size_t i = 0; i < wifi_networks.size(); ++i) { - if (i == 0) - output.append(ToHtmlTableHeader(wifi_networks[i])); - output.append(ToHtmlTableRow(wifi_networks[i])); - } - } - - if (cros->cellular_enabled()) { - output.append("</table><h3>Cellular Networks:</h3><table border=1>"); - const chromeos::CellularNetworkVector& cellular_networks = - cros->cellular_networks(); - for (size_t i = 0; i < cellular_networks.size(); ++i) { - if (i == 0) - output.append(ToHtmlTableHeader(cellular_networks[i])); - output.append(ToHtmlTableRow(cellular_networks[i])); - } - } - - { - output.append("</table><h3>Virtual Networks:</h3><table border=1>"); - const chromeos::VirtualNetworkVector& virtual_networks = - cros->virtual_networks(); - for (size_t i = 0; i < virtual_networks.size(); ++i) { - if (i == 0) - output.append(ToHtmlTableHeader(virtual_networks[i])); - output.append(ToHtmlTableRow(virtual_networks[i])); - } - } - - { - output.append( - "</table><h3>Remembered Wi-Fi Networks:</h3><table border=1>"); - const chromeos::WifiNetworkVector& remembered_wifi_networks = - cros->remembered_wifi_networks(); - for (size_t i = 0; i < remembered_wifi_networks.size(); ++i) { - if (i == 0) - output.append( - ToHtmlTableHeader(remembered_wifi_networks[i])); - output.append(ToHtmlTableRow(remembered_wifi_networks[i])); - } - } - - output.append("</table>"); - AppendFooter(&output); - return output; -} - -std::string AboutNetwork(const std::string& query) { - int refresh; - base::StringToInt(query, &refresh); - return GetNetworkHtmlInfo(refresh); -} - std::string AddStringRow(const std::string& name, const std::string& value) { std::string row; row.append(WrapWithTD(name)); @@ -472,6 +315,8 @@ std::string AddStringRow(const std::string& name, const std::string& value) { return WrapWithTR(row); } +// TODO(stevenjb): L10N AboutDiscards. + std::string AboutDiscardsRun() { std::string output; AppendHeader(&output, 0, "About discards"); @@ -1136,7 +981,7 @@ void AboutUIHTMLSource::StartDataRequest(const std::string& path, return; #if defined(OS_CHROMEOS) } else if (host == chrome::kChromeUINetworkHost) { - response = AboutNetwork(path); + response = chromeos::about_ui::AboutNetwork(path); } else if (host == chrome::kChromeUIOSCreditsHost) { response = ResourceBundle::GetSharedInstance().GetRawDataResource( IDR_OS_CREDITS_HTML).as_string(); diff --git a/chrome/browser/ui/webui/about_ui.h b/chrome/browser/ui/webui/about_ui.h index 78d9778..3f73e09 100644 --- a/chrome/browser/ui/webui/about_ui.h +++ b/chrome/browser/ui/webui/about_ui.h @@ -50,4 +50,14 @@ class AboutUI : public content::WebUIController { DISALLOW_COPY_AND_ASSIGN(AboutUI); }; +namespace about_ui { + +// Helper functions +void AppendHeader(std::string* output, int refresh, + const std::string& unescaped_title); +void AppendBody(std::string *output); +void AppendFooter(std::string *output); + +} // namespace about_ui + #endif // CHROME_BROWSER_UI_WEBUI_ABOUT_UI_H_ diff --git a/chrome/browser/ui/webui/chromeos/about_network.cc b/chrome/browser/ui/webui/chromeos/about_network.cc new file mode 100644 index 0000000..4336e1d --- /dev/null +++ b/chrome/browser/ui/webui/chromeos/about_network.cc @@ -0,0 +1,296 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/webui/chromeos/about_network.h" + +#include "base/command_line.h" +#include "base/string_number_conversions.h" +#include "base/utf_string_conversions.h" +#include "chrome/browser/chromeos/cros/cros_library.h" +#include "chrome/browser/chromeos/cros/network_library.h" +#include "chrome/browser/ui/webui/about_ui.h" +#include "chromeos/chromeos_switches.h" +#include "chromeos/network/network_event_log.h" +#include "chromeos/network/network_state.h" +#include "chromeos/network/network_state_handler.h" +#include "grit/generated_resources.h" +#include "ui/base/l10n/l10n_util.h" + +namespace chromeos { + +namespace { + +// Html output helper functions + +std::string WrapWithH3(const std::string& text) { + return "<h3>" + text + "</h3>"; +} + +std::string WrapWithTH(const std::string& text) { + return "<th>" + text + "</th>"; +} + +std::string WrapWithTD(const std::string& text) { + return "<td>" + text + "</td>"; +} + +std::string WrapWithTR(const std::string& text) { + return "<tr>" + text + "</tr>"; +} + +void AppendRefresh(std::string *output, int refresh, const std::string& name) { + if (refresh > 0) { + output->append(l10n_util::GetStringFUTF8( + IDS_ABOUT_AUTO_REFRESH, base::IntToString16(refresh))); + } else { + output->append(l10n_util::GetStringFUTF8( + IDS_ABOUT_AUTO_REFRESH_INFO, UTF8ToUTF16(name))); + } +} + +std::string GetHeaderHtmlInfo(int refresh) { + std::string output; + ::about_ui::AppendHeader(&output, refresh, "About Network"); + ::about_ui::AppendBody(&output); + AppendRefresh(&output, refresh, "network"); + return output; +} + +std::string GetHeaderEventLogInfo() { + std::string output; + output.append(WrapWithH3( + l10n_util::GetStringUTF8(IDS_ABOUT_NETWORK_EVENT_LOG))); + output.append("<pre style=\"" + "border-style:solid; border-width:1px; " + "overflow: auto; " + "height:200px;\">"); + output.append( + network_event_log::GetAsString(network_event_log::NEWEST_FIRST, 0)); + output.append("</pre>"); + return output; +} + +// NetworkLibrary tables + +std::string NetworkToHtmlTableHeader(const Network* network) { + std::string str = + WrapWithTH("Name") + + WrapWithTH("Active") + + WrapWithTH("State"); + if (network->type() == TYPE_WIFI || + network->type() == TYPE_CELLULAR) { + str += WrapWithTH("Auto-Connect"); + str += WrapWithTH("Strength"); + } + if (network->type() == TYPE_WIFI) { + str += WrapWithTH("Encryption"); + str += WrapWithTH("Passphrase"); + str += WrapWithTH("Identity"); + str += WrapWithTH("Frequency"); + } + if (network->type() == TYPE_CELLULAR) { + str += WrapWithTH("Technology"); + str += WrapWithTH("Connectivity"); + str += WrapWithTH("Activation"); + str += WrapWithTH("Roaming"); + } + if (network->type() == TYPE_VPN) { + str += WrapWithTH("Host"); + str += WrapWithTH("Provider Type"); + str += WrapWithTH("PSK Passphrase"); + str += WrapWithTH("Username"); + str += WrapWithTH("User Passphrase"); + } + str += WrapWithTH("Error"); + str += WrapWithTH("IP Address"); + return WrapWithTR(str); +} + +// Helper function to create an Html table row for a Network. +std::string NetworkToHtmlTableRow(const Network* network) { + std::string str = + WrapWithTD(network->name()) + + WrapWithTD(base::IntToString(network->is_active())) + + WrapWithTD(network->GetStateString()); + if (network->type() == TYPE_WIFI || + network->type() == TYPE_CELLULAR) { + const WirelessNetwork* wireless = + static_cast<const WirelessNetwork*>(network); + str += WrapWithTD(base::IntToString(wireless->auto_connect())); + str += WrapWithTD(base::IntToString(wireless->strength())); + } + if (network->type() == TYPE_WIFI) { + const WifiNetwork* wifi = + static_cast<const WifiNetwork*>(network); + str += WrapWithTD(wifi->GetEncryptionString()); + str += WrapWithTD(std::string(wifi->passphrase().length(), '*')); + str += WrapWithTD(wifi->identity()); + str += WrapWithTD(base::IntToString(wifi->frequency())); + } + if (network->type() == TYPE_CELLULAR) { + const CellularNetwork* cell = + static_cast<const CellularNetwork*>(network); + str += WrapWithTH(cell->GetNetworkTechnologyString()); + str += WrapWithTH(cell->GetActivationStateString()); + str += WrapWithTH(cell->GetRoamingStateString()); + } + if (network->type() == TYPE_VPN) { + const VirtualNetwork* vpn = + static_cast<const VirtualNetwork*>(network); + str += WrapWithTH(vpn->server_hostname()); + str += WrapWithTH(vpn->GetProviderTypeString()); + str += WrapWithTD(std::string(vpn->psk_passphrase().length(), '*')); + str += WrapWithTH(vpn->username()); + str += WrapWithTD(std::string(vpn->user_passphrase().length(), '*')); + } + str += WrapWithTD(network->failed() ? network->GetErrorString() : ""); + str += WrapWithTD(network->ip_address()); + return WrapWithTR(str); +} + +std::string GetCrosNetworkHtmlInfo() { + std::string output; + + NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); + + const EthernetNetwork* ethernet = cros->ethernet_network(); + if (cros->ethernet_enabled() && ethernet) { + output.append(WrapWithH3( + l10n_util::GetStringUTF8(IDS_ABOUT_NETWORK_ETHERNET))); + output.append("<table border=1>"); + output.append(NetworkToHtmlTableHeader(ethernet)); + output.append(NetworkToHtmlTableRow(ethernet)); + output.append("</table>"); + } + + const WifiNetworkVector& wifi_networks = cros->wifi_networks(); + if (cros->wifi_enabled() && wifi_networks.size() > 0) { + output.append(WrapWithH3( + l10n_util::GetStringUTF8(IDS_ABOUT_NETWORK_WIFI))); + output.append("<table border=1>"); + for (size_t i = 0; i < wifi_networks.size(); ++i) { + if (i == 0) + output.append(NetworkToHtmlTableHeader(wifi_networks[i])); + output.append(NetworkToHtmlTableRow(wifi_networks[i])); + } + output.append("</table>"); + } + + const CellularNetworkVector& cellular_networks = cros->cellular_networks(); + if (cros->cellular_enabled() && cellular_networks.size() > 0) { + output.append(WrapWithH3( + l10n_util::GetStringUTF8(IDS_ABOUT_NETWORK_CELLULAR))); + output.append("<table border=1>"); + for (size_t i = 0; i < cellular_networks.size(); ++i) { + if (i == 0) + output.append(NetworkToHtmlTableHeader(cellular_networks[i])); + output.append(NetworkToHtmlTableRow(cellular_networks[i])); + } + output.append("</table>"); + } + + const VirtualNetworkVector& virtual_networks = cros->virtual_networks(); + if (virtual_networks.size() > 0) { + output.append(WrapWithH3( + l10n_util::GetStringUTF8(IDS_ABOUT_NETWORK_VIRTUAL))); + output.append("<table border=1>"); + for (size_t i = 0; i < virtual_networks.size(); ++i) { + if (i == 0) + output.append(NetworkToHtmlTableHeader(virtual_networks[i])); + output.append(NetworkToHtmlTableRow(virtual_networks[i])); + } + output.append("</table>"); + } + + const WifiNetworkVector& remembered_wifi_networks = + cros->remembered_wifi_networks(); + if (remembered_wifi_networks.size() > 0) { + output.append(WrapWithH3( + l10n_util::GetStringUTF8(IDS_ABOUT_NETWORK_REMEMBERED_WIFI))); + output.append("<table border=1>"); + for (size_t i = 0; i < remembered_wifi_networks.size(); ++i) { + if (i == 0) + output.append(NetworkToHtmlTableHeader(remembered_wifi_networks[i])); + output.append(NetworkToHtmlTableRow(remembered_wifi_networks[i])); + } + output.append("</table>"); + } + + ::about_ui::AppendFooter(&output); + return output; +} + +// NetworkStateHandler tables + +std::string NetworkStateToHtmlTableHeader() { + std::string str = + WrapWithTH("Name") + + WrapWithTH("Type") + + WrapWithTH("State") + + WrapWithTH("Path") + + WrapWithTH("IP Addr") + + WrapWithTH("Security") + + WrapWithTH("Technology") + + WrapWithTH("Activation") + + WrapWithTH("Romaing") + + WrapWithTH("Strength"); + return WrapWithTR(str); +} + +std::string NetworkStateToHtmlTableRow(const NetworkState* network) { + std::string str = + WrapWithTD(network->name()) + + WrapWithTD(network->type()) + + WrapWithTD(network->state()) + + WrapWithTD(network->path()) + + WrapWithTD(network->ip_address()) + + WrapWithTD(network->security()) + + WrapWithTD(network->technology()) + + WrapWithTD(network->activation_state()) + + WrapWithTD(network->roaming()) + + WrapWithTD(base::IntToString(network->signal_strength())); + return WrapWithTR(str); +} + +std::string GetNetworkStateHtmlInfo() { + NetworkStateHandler* handler = NetworkStateHandler::Get(); + NetworkStateHandler::NetworkStateList network_list; + handler->GetNetworkList(&network_list); + + std::string output; + output.append(WrapWithH3( + l10n_util::GetStringUTF8(IDS_ABOUT_NETWORK_NETWORKS))); + output.append("<table border=1>"); + output.append(NetworkStateToHtmlTableHeader()); + for (NetworkStateHandler::NetworkStateList::iterator iter = + network_list.begin(); iter != network_list.end(); ++iter) { + const NetworkState* network = *iter; + output.append(NetworkStateToHtmlTableRow(network)); + } + output.append("</table>"); + return output; +} + +} // namespace + +namespace about_ui { + +std::string AboutNetwork(const std::string& query) { + int refresh; + base::StringToInt(query, &refresh); + std::string output = GetHeaderHtmlInfo(refresh); + if (network_event_log::IsInitialized()) + output += GetHeaderEventLogInfo(); + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableNewNetworkHandlers)) { + output += GetNetworkStateHtmlInfo(); + } else { + output += GetCrosNetworkHtmlInfo(); + } + return output; +} + +} // namespace about_ui + +} // namespace chromeos diff --git a/chrome/browser/ui/webui/chromeos/about_network.h b/chrome/browser/ui/webui/chromeos/about_network.h new file mode 100644 index 0000000..42f17d4 --- /dev/null +++ b/chrome/browser/ui/webui/chromeos/about_network.h @@ -0,0 +1,21 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_ABOUT_NETWORK_H_ +#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ABOUT_NETWORK_H_ + +#include <string> + +namespace chromeos { +namespace about_ui { + +// Returns the HTML for chrome://network for the chromeos networks. +// |query| contains any text after 'chrome://network/', used to indicate the +// refresh interval. +std::string AboutNetwork(const std::string& query); + +} // namespace about_ui +} // namespace chromeos + +#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ABOUT_NETWORK_H_ diff --git a/chrome/chrome_browser_chromeos.gypi b/chrome/chrome_browser_chromeos.gypi index 593127b..8b4dd0e 100644 --- a/chrome/chrome_browser_chromeos.gypi +++ b/chrome/chrome_browser_chromeos.gypi @@ -625,6 +625,8 @@ 'browser/chromeos/system_logs/lsb_release_log_source.h', 'browser/chromeos/system_logs/memory_details_log_source.cc', 'browser/chromeos/system_logs/memory_details_log_source.h', + 'browser/chromeos/system_logs/network_event_log_source.cc', + 'browser/chromeos/system_logs/network_event_log_source.h', 'browser/chromeos/system_logs/system_logs_fetcher.cc', 'browser/chromeos/system_logs/system_logs_fetcher.h', 'browser/chromeos/ui/idle_logout_dialog_view.cc', diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index bea50ead..93f00d2 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi @@ -1739,6 +1739,8 @@ 'browser/ui/webui/chrome_web_ui_controller_factory.h', 'browser/ui/webui/chrome_web_ui_data_source.cc', 'browser/ui/webui/chrome_web_ui_data_source.h', + 'browser/ui/webui/chromeos/about_network.cc', + 'browser/ui/webui/chromeos/about_network.h', 'browser/ui/webui/chromeos/choose_mobile_network_ui.cc', 'browser/ui/webui/chromeos/choose_mobile_network_ui.h', 'browser/ui/webui/chromeos/cryptohome_ui.cc', |