Commit 7d4bb351 authored by Tim Song's avatar Tim Song Committed by Commit Bot

Ash Tray: Add MAC address of cellular device to network device info bubble.

BUG=1012052

Change-Id: I8cbfbf4bd5808fececc3c331c5a0cd32a9e84e52
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1846026
Commit-Queue: Tim Song <tengs@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704419}
parent 5577421a
......@@ -1291,6 +1291,9 @@ This file contains the strings for ash.
<message name="IDS_ASH_STATUS_TRAY_ETHERNET_ADDRESS" desc="The label for the mac address of the ethernet device.">
Ethernet: <ph name="ADDRESS">$1<ex>01:23:45:67:89:AB</ex></ph>
</message>
<message name="IDS_ASH_STATUS_TRAY_CELLULAR_ADDRESS" desc="The label for the mac address of the cellular device.">
Cellular: <ph name="ADDRESS">$1<ex>01:23:45:67:89:AB</ex></ph>
</message>
<message name="IDS_ASH_STATUS_TRAY_INITIALIZING_CELLULAR" desc="Message for the status area when initializing the cellular device.">
Initializing...
</message>
......
......@@ -398,7 +398,7 @@ views::View* NetworkStateListDetailedView::CreateNetworkInfoView() {
ipv6_address = device->ipv6_address->ToString();
}
std::string ethernet_address, wifi_address;
std::string ethernet_address, wifi_address, cellular_address;
if (list_type_ == LIST_TYPE_NETWORK) {
const DeviceStateProperties* ethernet =
model_->GetDevice(NetworkType::kEthernet);
......@@ -407,23 +407,29 @@ views::View* NetworkStateListDetailedView::CreateNetworkInfoView() {
const DeviceStateProperties* wifi = model_->GetDevice(NetworkType::kWiFi);
if (wifi && wifi->mac_address)
wifi_address = *wifi->mac_address;
const DeviceStateProperties* cellular =
model_->GetDevice(NetworkType::kCellular);
if (cellular && cellular->mac_address)
cellular_address = *cellular->mac_address;
}
base::string16 bubble_text;
auto add_line = [&bubble_text](const std::string& address, int ids) {
if (!address.empty()) {
auto maybe_add_mac_address = [&bubble_text](const std::string& address,
int ids) {
if (address.empty())
return;
if (!bubble_text.empty())
bubble_text += base::ASCIIToUTF16("\n");
bubble_text +=
l10n_util::GetStringFUTF16(ids, base::UTF8ToUTF16(address));
}
bubble_text += l10n_util::GetStringFUTF16(ids, base::UTF8ToUTF16(address));
};
add_line(ipv4_address, IDS_ASH_STATUS_TRAY_IP_ADDRESS);
add_line(ipv6_address, IDS_ASH_STATUS_TRAY_IPV6_ADDRESS);
add_line(ethernet_address, IDS_ASH_STATUS_TRAY_ETHERNET_ADDRESS);
add_line(wifi_address, IDS_ASH_STATUS_TRAY_WIFI_ADDRESS);
maybe_add_mac_address(ipv4_address, IDS_ASH_STATUS_TRAY_IP_ADDRESS);
maybe_add_mac_address(ipv6_address, IDS_ASH_STATUS_TRAY_IPV6_ADDRESS);
maybe_add_mac_address(ethernet_address, IDS_ASH_STATUS_TRAY_ETHERNET_ADDRESS);
maybe_add_mac_address(wifi_address, IDS_ASH_STATUS_TRAY_WIFI_ADDRESS);
maybe_add_mac_address(cellular_address, IDS_ASH_STATUS_TRAY_CELLULAR_ADDRESS);
// Avoid an empty bubble in the unlikely event that there is no network
// information at all.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment