Commit 4e5a9782 authored by Daniel Classon's avatar Daniel Classon Committed by Commit Bot

[InternetPage] Show search result for Ethernet no network

For some edgecases, i.e. Chromeboxes, there is an ethernet section shown
with "No network". Show a search result for Ethernet that links to
the Network Section.

Fixed: 1096768
Test: Remove the lines as seen in Patchset 2 (test setup) and run on Linux CrOS emulator..
Change-Id: I0dd06b1fd77129499ad11b732dffedb5c28d2f00
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2429258
Commit-Queue: Daniel Classon <dclasson@google.com>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811287}
parent 483ecf8e
......@@ -88,6 +88,18 @@ const std::vector<SearchConcept>& GetEthernetConnectedSearchConcepts() {
return *tags;
}
const std::vector<SearchConcept>& GetEthernetNotConnectedSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
{IDS_OS_SETTINGS_TAG_ETHERNET,
mojom::kNetworkSectionPath,
mojom::SearchResultIcon::kEthernet,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSection,
{.section = mojom::Section::kNetwork}},
});
return *tags;
}
const std::vector<SearchConcept>& GetWifiSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({
{IDS_OS_SETTINGS_TAG_WIFI,
......@@ -871,6 +883,10 @@ void InternetSection::OnDeviceList(
updater.RemoveSearchTags(GetInstantTetheringOnSearchConcepts());
updater.RemoveSearchTags(GetInstantTetheringOffSearchConcepts());
// Keep track of ethernet devices to handle an edge case where Ethernet device
// is present but no network is connected.
does_ethernet_device_exist_ = false;
for (const auto& device : devices) {
switch (device->type) {
case NetworkType::kWiFi:
......@@ -899,6 +915,10 @@ void InternetSection::OnDeviceList(
updater.AddSearchTags(GetInstantTetheringOffSearchConcepts());
break;
case NetworkType::kEthernet:
does_ethernet_device_exist_ = true;
break;
default:
// Note: Ethernet and VPN only show search tags when connected, and
// categories such as Mobile/Wireless do not have search tags.
......@@ -923,6 +943,7 @@ void InternetSection::OnNetworkList(
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
updater.RemoveSearchTags(GetEthernetConnectedSearchConcepts());
updater.RemoveSearchTags(GetEthernetNotConnectedSearchConcepts());
updater.RemoveSearchTags(GetWifiConnectedSearchConcepts());
updater.RemoveSearchTags(GetWifiMeteredSearchConcepts());
updater.RemoveSearchTags(GetCellularSearchConcepts());
......@@ -990,6 +1011,12 @@ void InternetSection::OnNetworkList(
break;
}
}
// Edge case where Ethernet device is present but no network is connected,
// i.e. on Chromeboxes. http://crbug.com/1096768
if (does_ethernet_device_exist_ && !connected_ethernet_guid_.has_value()) {
updater.AddSearchTags(GetEthernetNotConnectedSearchConcepts());
}
}
} // namespace settings
......
......@@ -75,6 +75,8 @@ class InternetSection
base::Optional<std::string> connected_tether_guid_;
base::Optional<std::string> connected_vpn_guid_;
bool does_ethernet_device_exist_ = false;
mojo::Receiver<network_config::mojom::CrosNetworkConfigObserver> receiver_{
this};
mojo::Remote<network_config::mojom::CrosNetworkConfig> cros_network_config_;
......
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