Commit 72f4fe58 authored by Regan Hsu's avatar Regan Hsu Committed by Chromium LUCI CQ

[CrOS PhoneHub] Hide PhoneHub search results if phone is not supported.

Fixed: 1162309
Bug: 1106937
Change-Id: Ifa4751e146f9d363100adb6df99e66769e3ba4f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2613127
Commit-Queue: Regan Hsu <hsuregan@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841450}
parent 907cb7ed
......@@ -36,6 +36,8 @@ namespace chromeos {
namespace settings {
namespace {
using FeatureState = multidevice_setup::mojom::FeatureState;
const std::vector<SearchConcept>& GetMultiDeviceOptedInSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags(
{{IDS_OS_SETTINGS_TAG_MULTIDEVICE_FORGET,
......@@ -551,14 +553,11 @@ void MultiDeviceSection::OnHostStatusChanged(
host_status_with_device) {
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
updater.RemoveSearchTags(GetMultiDeviceOptedOutSearchConcepts());
updater.RemoveSearchTags(GetMultiDeviceOptedInPhoneHubSearchConcepts());
updater.RemoveSearchTags(GetMultiDeviceOptedInWifiSyncSearchConcepts());
updater.RemoveSearchTags(GetMultiDeviceOptedInSearchConcepts());
if (IsOptedIn(host_status_with_device.first)) {
updater.AddSearchTags(GetMultiDeviceOptedInSearchConcepts());
if (features::IsPhoneHubEnabled())
updater.AddSearchTags(GetMultiDeviceOptedInPhoneHubSearchConcepts());
if (features::IsWifiSyncAndroidEnabled())
updater.AddSearchTags(GetMultiDeviceOptedInWifiSyncSearchConcepts());
} else {
......@@ -571,11 +570,14 @@ void MultiDeviceSection::OnFeatureStatesChanged(
feature_states_map) {
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
updater.RemoveSearchTags(GetSmartLockOptionsSearchConcepts());
updater.RemoveSearchTags(GetMultiDeviceOptedInPhoneHubSearchConcepts());
if (feature_states_map.at(multidevice_setup::mojom::Feature::kSmartLock) ==
multidevice_setup::mojom::FeatureState::kEnabledByUser) {
updater.AddSearchTags(GetSmartLockOptionsSearchConcepts());
}
if (IsPhoneHubSupported())
updater.AddSearchTags(GetMultiDeviceOptedInPhoneHubSearchConcepts());
}
void MultiDeviceSection::OnNearbySharingEnabledChanged() {
......@@ -590,5 +592,12 @@ void MultiDeviceSection::OnNearbySharingEnabledChanged() {
}
}
bool MultiDeviceSection::IsPhoneHubSupported() {
const FeatureState feature_state = multidevice_setup_client_->GetFeatureState(
multidevice_setup::mojom::Feature::kPhoneHub);
return feature_state != FeatureState::kNotSupportedByPhone &&
feature_state != FeatureState::kNotSupportedByChromebook;
}
} // namespace settings
} // namespace chromeos
......@@ -68,6 +68,8 @@ class MultiDeviceSection
// Nearby Share enabled pref change observer.
void OnNearbySharingEnabledChanged();
bool IsPhoneHubSupported();
multidevice_setup::MultiDeviceSetupClient* multidevice_setup_client_;
phonehub::PhoneHubManager* phone_hub_manager_;
android_sms::AndroidSmsService* android_sms_service_;
......
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