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() { ...@@ -88,6 +88,18 @@ const std::vector<SearchConcept>& GetEthernetConnectedSearchConcepts() {
return *tags; 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() { const std::vector<SearchConcept>& GetWifiSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags({ static const base::NoDestructor<std::vector<SearchConcept>> tags({
{IDS_OS_SETTINGS_TAG_WIFI, {IDS_OS_SETTINGS_TAG_WIFI,
...@@ -871,6 +883,10 @@ void InternetSection::OnDeviceList( ...@@ -871,6 +883,10 @@ void InternetSection::OnDeviceList(
updater.RemoveSearchTags(GetInstantTetheringOnSearchConcepts()); updater.RemoveSearchTags(GetInstantTetheringOnSearchConcepts());
updater.RemoveSearchTags(GetInstantTetheringOffSearchConcepts()); 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) { for (const auto& device : devices) {
switch (device->type) { switch (device->type) {
case NetworkType::kWiFi: case NetworkType::kWiFi:
...@@ -899,6 +915,10 @@ void InternetSection::OnDeviceList( ...@@ -899,6 +915,10 @@ void InternetSection::OnDeviceList(
updater.AddSearchTags(GetInstantTetheringOffSearchConcepts()); updater.AddSearchTags(GetInstantTetheringOffSearchConcepts());
break; break;
case NetworkType::kEthernet:
does_ethernet_device_exist_ = true;
break;
default: default:
// Note: Ethernet and VPN only show search tags when connected, and // Note: Ethernet and VPN only show search tags when connected, and
// categories such as Mobile/Wireless do not have search tags. // categories such as Mobile/Wireless do not have search tags.
...@@ -923,6 +943,7 @@ void InternetSection::OnNetworkList( ...@@ -923,6 +943,7 @@ void InternetSection::OnNetworkList(
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate(); SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
updater.RemoveSearchTags(GetEthernetConnectedSearchConcepts()); updater.RemoveSearchTags(GetEthernetConnectedSearchConcepts());
updater.RemoveSearchTags(GetEthernetNotConnectedSearchConcepts());
updater.RemoveSearchTags(GetWifiConnectedSearchConcepts()); updater.RemoveSearchTags(GetWifiConnectedSearchConcepts());
updater.RemoveSearchTags(GetWifiMeteredSearchConcepts()); updater.RemoveSearchTags(GetWifiMeteredSearchConcepts());
updater.RemoveSearchTags(GetCellularSearchConcepts()); updater.RemoveSearchTags(GetCellularSearchConcepts());
...@@ -990,6 +1011,12 @@ void InternetSection::OnNetworkList( ...@@ -990,6 +1011,12 @@ void InternetSection::OnNetworkList(
break; 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 } // namespace settings
......
...@@ -75,6 +75,8 @@ class InternetSection ...@@ -75,6 +75,8 @@ class InternetSection
base::Optional<std::string> connected_tether_guid_; base::Optional<std::string> connected_tether_guid_;
base::Optional<std::string> connected_vpn_guid_; base::Optional<std::string> connected_vpn_guid_;
bool does_ethernet_device_exist_ = false;
mojo::Receiver<network_config::mojom::CrosNetworkConfigObserver> receiver_{ mojo::Receiver<network_config::mojom::CrosNetworkConfigObserver> receiver_{
this}; this};
mojo::Remote<network_config::mojom::CrosNetworkConfig> cros_network_config_; 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