Commit 61525561 authored by Tim Schumann's avatar Tim Schumann Committed by Commit Bot

Revert "[Nearby] Trigger onboarding when first enabling Nearby"

This reverts commit a5d3ad0f.

Reason for revert: Suspected to break NearbyOnboardingPageTest.All on linux-chromeos-dbg

Original change's description:
> [Nearby] Trigger onboarding when first enabling Nearby
> 
> This CL adds a pref to track if onboarding was run by this user before.
> If it has not, when enabling for the first time, onboarding is run first
> by navigating to the subpage and showing in a dialog. Once onboarding
> has been done once, the user can freely toggle on/off without
> triggering onboarding. However, onboarding will still run if the user
> triggers the pod button and the feature is disabled. This matches the
> Android behavior.
> 
> Additionally, this CL fixes a bug with the premature closing of the
> shared receiveManager which needs to stay alive and connected after the
> dialog closes otherwise getReceiveManager returns a remote with a closed
> pipe.
> 
> Bug: b/154866951
> Change-Id: I1e3cbd15f4995f019b3476c2f7a69f67d6eb1888
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2424763
> Reviewed-by: Kyle Horimoto <khorimoto@chromium.org>
> Commit-Queue: James Vecore <vecore@google.com>
> Cr-Commit-Position: refs/heads/master@{#809623}

TBR=khorimoto@chromium.org,vecore@google.com

Change-Id: I4bd779c4a17b7ef0560078cefd00287810dab796
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: b/154866951, 1131390
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2424160Reviewed-by: default avatarTim Schumann <tschumann@chromium.org>
Commit-Queue: Tim Schumann <tschumann@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809720}
parent 96f8779f
......@@ -309,8 +309,6 @@ const PrefsUtil::TypedPrefMap& PrefsUtil::GetAllowlistedKeys() {
// Nearby Share.
(*s_allowlist)[::prefs::kNearbySharingEnabledPrefName] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_allowlist)[::prefs::kNearbySharingOnboardingCompletePrefName] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_allowlist)[::prefs::kNearbySharingActiveProfilePrefName] =
settings_api::PrefType::PREF_TYPE_BOOLEAN;
(*s_allowlist)[::prefs::kNearbySharingDeviceNamePrefName] =
......
......@@ -26,8 +26,6 @@ const char kNearbySharingDataUsageName[] = "nearby_sharing.data_usage";
const char kNearbySharingDeviceIdPrefName[] = "nearby_sharing.device_id";
const char kNearbySharingDeviceNamePrefName[] = "nearby_sharing.device_name";
const char kNearbySharingEnabledPrefName[] = "nearby_sharing.enabled";
const char kNearbySharingOnboardingCompletePrefName[] =
"nearby_sharing.onboarding_complete";
const char kNearbySharingFullNamePrefName[] = "nearby_sharing.full_name";
const char kNearbySharingIconUrlPrefName[] = "nearby_sharing.icon_url";
const char kNearbySharingOnboardingDismissedTimePrefName[] =
......@@ -60,8 +58,6 @@ void RegisterNearbySharingPrefs(PrefRegistrySimple* registry) {
// available.
registry->RegisterBooleanPref(prefs::kNearbySharingEnabledPrefName,
/*default_value=*/true);
registry->RegisterBooleanPref(prefs::kNearbySharingOnboardingCompletePrefName,
/*default_value=*/false);
registry->RegisterIntegerPref(
prefs::kNearbySharingBackgroundVisibilityName,
/*default_value=*/static_cast<int>(Visibility::kUnknown));
......
......@@ -17,7 +17,6 @@ extern const char kNearbySharingDataUsageName[];
extern const char kNearbySharingDeviceIdPrefName[];
extern const char kNearbySharingDeviceNamePrefName[];
extern const char kNearbySharingEnabledPrefName[];
extern const char kNearbySharingOnboardingCompletePrefName[];
extern const char kNearbySharingFullNamePrefName[];
extern const char kNearbySharingIconUrlPrefName[];
extern const char kNearbySharingOnboardingDismissedTimePrefName[];
......
......@@ -83,12 +83,6 @@ void NearbyShareSettings::GetEnabled(base::OnceCallback<void(bool)> callback) {
void NearbyShareSettings::SetEnabled(bool enabled) {
pref_service_->SetBoolean(prefs::kNearbySharingEnabledPrefName, enabled);
if (enabled) {
// We rely on the the UI to enforce that if the feature was enabled for the
// first time, that onboarding was run.
pref_service_->SetBoolean(prefs::kNearbySharingOnboardingCompletePrefName,
true);
}
}
void NearbyShareSettings::GetDeviceName(
......
......@@ -467,25 +467,12 @@ Polymer({
* @private
*/
nearbyShareClick_(event) {
const nearbyEnabled = this.getPref('nearby_sharing.enabled').value;
const onboardingComplete =
this.getPref('nearby_sharing.onboarding_complete').value;
let params = undefined;
if (!nearbyEnabled) {
if (onboardingComplete) {
// If we have already run onboarding at least once, we don't need to do
// it again, just enabled the feature in place.
this.setPrefValue('nearby_sharing.enabled', true);
return;
}
// Otherwise we need to go into the subpage and trigger the onboarding
// dialog.
params = new URLSearchParams();
params.set('onboarding', '');
if (!this.getPref('nearby_sharing.enabled').value) {
this.setPrefValue('nearby_sharing.enabled', true);
} else {
// Navigate to Nearby Share subpage.
settings.Router.getInstance().navigateTo(settings.routes.NEARBY_SHARE);
}
settings.Router.getInstance().navigateTo(
settings.routes.NEARBY_SHARE, params);
},
/** @private */
......
......@@ -103,6 +103,11 @@ Polymer({
if (this.observerReceiver_) {
this.observerReceiver_.$.close();
}
if (this.receiveManager_) {
/** @type {nearbyShare.mojom.ReceiveManagerRemote} */
(this.receiveManager_).$.close();
}
},
/**
......
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