Commit fd002ecb authored by Andre Le's avatar Andre Le Committed by Chromium LUCI CQ

[NearbyShare] Don't repeat onboarding when user clicks tray icon

When an user has already gone through the onboarding process, we should
not make them do it again even when the feature is turned off. In that
case, when user enable the feature through the tray icon, we will
silently enable the feature in settings.

Test: manually, unit_tests
Fixed: 1157145
Change-Id: I8941c629bec260adc4e851ef17bd8870f2dd2214
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2592132
Commit-Queue: Andre Le <leandre@chromium.org>
Reviewed-by: default avatarJosh Nohle <nohle@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837333}
parent ee15b04e
...@@ -72,6 +72,10 @@ void NearbyShareDelegateImpl::EnableHighVisibility() { ...@@ -72,6 +72,10 @@ void NearbyShareDelegateImpl::EnableHighVisibility() {
if (!nearby_share_service_) if (!nearby_share_service_)
return; return;
// Automatically enable the feature if onboarding is already completed.
if (nearby_share_service_->GetSettings()->IsOnboardingComplete())
nearby_share_service_->GetSettings()->SetEnabled(true);
settings_opener_->ShowSettingsPage(kStartReceivingQueryParam); settings_opener_->ShowSettingsPage(kStartReceivingQueryParam);
if (!nearby_share_service_->GetSettings()->GetEnabled()) { if (!nearby_share_service_->GetSettings()->GetEnabled()) {
......
...@@ -210,6 +210,24 @@ TEST_F(NearbyShareDelegateImplTest, StopHighVisibilityOnScreenLock) { ...@@ -210,6 +210,24 @@ TEST_F(NearbyShareDelegateImplTest, StopHighVisibilityOnScreenLock) {
SetHighVisibilityOn(false); SetHighVisibilityOn(false);
} }
TEST_F(NearbyShareDelegateImplTest, AutomaticallyEnableFeature) {
settings()->SetEnabled(false);
// If onboarding is not completed, settings should not be enabled and the user
// should go through onboarding process.
test_pref_service_.SetBoolean(prefs::kNearbySharingOnboardingCompletePrefName,
false);
delegate_.EnableHighVisibility();
EXPECT_FALSE(settings()->GetEnabled());
// If onboarding is completed, the feature should automatically be enabled
// when open high visibility
test_pref_service_.SetBoolean(prefs::kNearbySharingOnboardingCompletePrefName,
true);
delegate_.EnableHighVisibility();
EXPECT_TRUE(settings()->GetEnabled());
}
TEST_F(NearbyShareDelegateImplTest, ShowNearbyShareSettings) { TEST_F(NearbyShareDelegateImplTest, ShowNearbyShareSettings) {
EXPECT_CALL(*settings_opener_, ShowSettingsPage(_)); EXPECT_CALL(*settings_opener_, ShowSettingsPage(_));
......
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