Commit dbacb416 authored by Daniel Classon's avatar Daniel Classon Committed by Commit Bot

[MultidevicePage] Fix "Smart lock screen lock options" when smart lock disabled

Fix the "Smart lock screen lock options" search tag behavior to only
appear when the smart lock feature is enabled by the user and the
corresponding options buttons are visible.

Bug: 1116553
Change-Id: Ib5a7194b8a97a639ba4df6b96952a92e4fb47270
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2429935
Commit-Queue: Daniel Classon <dclasson@google.com>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810914}
parent dc0960d4
...@@ -37,13 +37,7 @@ namespace { ...@@ -37,13 +37,7 @@ namespace {
const std::vector<SearchConcept>& GetMultiDeviceOptedInSearchConcepts() { const std::vector<SearchConcept>& GetMultiDeviceOptedInSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags( static const base::NoDestructor<std::vector<SearchConcept>> tags(
{{IDS_OS_SETTINGS_TAG_MULTIDEVICE_SMART_LOCK_OPTIONS, {{IDS_OS_SETTINGS_TAG_MULTIDEVICE_FORGET,
mojom::kSmartLockSubpagePath,
mojom::SearchResultIcon::kLock,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
{.setting = mojom::Setting::kSmartLockUnlockOrSignIn}},
{IDS_OS_SETTINGS_TAG_MULTIDEVICE_FORGET,
mojom::kMultiDeviceFeaturesSubpagePath, mojom::kMultiDeviceFeaturesSubpagePath,
mojom::SearchResultIcon::kPhone, mojom::SearchResultIcon::kPhone,
mojom::SearchResultDefaultRank::kMedium, mojom::SearchResultDefaultRank::kMedium,
...@@ -75,6 +69,17 @@ const std::vector<SearchConcept>& GetMultiDeviceOptedInSearchConcepts() { ...@@ -75,6 +69,17 @@ const std::vector<SearchConcept>& GetMultiDeviceOptedInSearchConcepts() {
return *tags; return *tags;
} }
const std::vector<SearchConcept>& GetSmartLockOptionsSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags(
{{IDS_OS_SETTINGS_TAG_MULTIDEVICE_SMART_LOCK_OPTIONS,
mojom::kSmartLockSubpagePath,
mojom::SearchResultIcon::kLock,
mojom::SearchResultDefaultRank::kMedium,
mojom::SearchResultType::kSetting,
{.setting = mojom::Setting::kSmartLockUnlockOrSignIn}}});
return *tags;
}
const std::vector<SearchConcept>& const std::vector<SearchConcept>&
GetMultiDeviceOptedInPhoneHubSearchConcepts() { GetMultiDeviceOptedInPhoneHubSearchConcepts() {
static const base::NoDestructor<std::vector<SearchConcept>> tags( static const base::NoDestructor<std::vector<SearchConcept>> tags(
...@@ -247,6 +252,7 @@ MultiDeviceSection::MultiDeviceSection( ...@@ -247,6 +252,7 @@ MultiDeviceSection::MultiDeviceSection(
multidevice_setup_client_->AddObserver(this); multidevice_setup_client_->AddObserver(this);
OnHostStatusChanged(multidevice_setup_client_->GetHostStatus()); OnHostStatusChanged(multidevice_setup_client_->GetHostStatus());
OnFeatureStatesChanged(multidevice_setup_client_->GetFeatureStates());
} }
MultiDeviceSection::~MultiDeviceSection() { MultiDeviceSection::~MultiDeviceSection() {
...@@ -488,6 +494,18 @@ void MultiDeviceSection::OnHostStatusChanged( ...@@ -488,6 +494,18 @@ void MultiDeviceSection::OnHostStatusChanged(
} }
} }
void MultiDeviceSection::OnFeatureStatesChanged(
const multidevice_setup::MultiDeviceSetupClient::FeatureStatesMap&
feature_states_map) {
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
updater.RemoveSearchTags(GetSmartLockOptionsSearchConcepts());
if (feature_states_map.at(multidevice_setup::mojom::Feature::kSmartLock) ==
multidevice_setup::mojom::FeatureState::kEnabledByUser) {
updater.AddSearchTags(GetSmartLockOptionsSearchConcepts());
}
}
void MultiDeviceSection::OnNearbySharingEnabledChanged() { void MultiDeviceSection::OnNearbySharingEnabledChanged() {
SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate(); SearchTagRegistry::ScopedTagUpdater updater = registry()->StartUpdate();
......
...@@ -59,6 +59,9 @@ class MultiDeviceSection ...@@ -59,6 +59,9 @@ class MultiDeviceSection
void OnHostStatusChanged( void OnHostStatusChanged(
const multidevice_setup::MultiDeviceSetupClient::HostStatusWithDevice& const multidevice_setup::MultiDeviceSetupClient::HostStatusWithDevice&
host_status_with_device) override; host_status_with_device) override;
void OnFeatureStatesChanged(
const multidevice_setup::MultiDeviceSetupClient::FeatureStatesMap&
feature_states_map) override;
// Nearby Share enabled pref change observer. // Nearby Share enabled pref change observer.
void OnNearbySharingEnabledChanged(); void OnNearbySharingEnabledChanged();
......
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