Commit 5a5d874c authored by Gordon Seto's avatar Gordon Seto Committed by Chromium LUCI CQ

[Nearby] Update high visibility toggle to show dialog.

Show high visibility dialog when the high visibility button is toggled
from the Nearby share subpage. This keeps the behavior consistent
with when high visibility is toggled from the tray.

Bug: 1154830
Change-Id: I17f6015706bca6f6b7ae85904c768e91923211e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2590652
Commit-Queue: Gordon Seto <gordonseto@google.com>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837443}
parent 73b9815f
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
/**
* @type {!number}
* @private
*/
const DEFAULT_HIGH_VISIBILITY_TIMEOUT_S = 300;
/** /**
* @fileoverview * @fileoverview
* 'settings-nearby-share-subpage' is the settings subpage for managing the * 'settings-nearby-share-subpage' is the settings subpage for managing the
...@@ -83,9 +89,6 @@ Polymer({ ...@@ -83,9 +89,6 @@ Polymer({
}, },
}, },
/** @private {?nearbyShare.mojom.ReceiveManagerInterface} */
receiveManager_: null,
/** @private {?nearbyShare.mojom.ReceiveObserverReceiver} */ /** @private {?nearbyShare.mojom.ReceiveObserverReceiver} */
receiveObserver_: null, receiveObserver_: null,
...@@ -103,7 +106,6 @@ Polymer({ ...@@ -103,7 +106,6 @@ Polymer({
this.profileName_ = accounts[0].fullName; this.profileName_ = accounts[0].fullName;
this.profileLabel_ = accounts[0].email; this.profileLabel_ = accounts[0].email;
}); });
this.receiveManager_ = nearby_share.getReceiveManager();
this.receiveObserver_ = nearby_share.observeReceiveManager( this.receiveObserver_ = nearby_share.observeReceiveManager(
/** @type {!nearbyShare.mojom.ReceiveObserverInterface} */ (this)); /** @type {!nearbyShare.mojom.ReceiveObserverInterface} */ (this));
}, },
...@@ -206,9 +208,7 @@ Polymer({ ...@@ -206,9 +208,7 @@ Polymer({
/** @private */ /** @private */
onInHighVisibilityToggledByUser_() { onInHighVisibilityToggledByUser_() {
if (this.inHighVisibility_) { if (this.inHighVisibility_) {
this.receiveManager_.registerForegroundReceiveSurface(); this.showHighVisibilityPage_();
} else {
this.receiveManager_.unregisterForegroundReceiveSurface();
} }
}, },
...@@ -350,11 +350,7 @@ Polymer({ ...@@ -350,11 +350,7 @@ Polymer({
} }
if (queryParams.has('receive')) { if (queryParams.has('receive')) {
// Get shutoffTimeoutInSeconds with a default of 5 minutes (300 seconds) this.showHighVisibilityPage_(Number(queryParams.get('timeout')));
const shutoffTimeoutInSeconds = Number(queryParams.get('timeout')) || 300;
this.showReceiveDialog_ = true;
Polymer.dom.flush();
this.$$('#receiveDialog').showHighVisibilityPage(shutoffTimeoutInSeconds);
} }
if (queryParams.has('confirm')) { if (queryParams.has('confirm')) {
...@@ -372,6 +368,18 @@ Polymer({ ...@@ -372,6 +368,18 @@ Polymer({
this.attemptDeepLink(); this.attemptDeepLink();
}, },
/**
* @param {number=} timeoutInSeconds
* @private
*/
showHighVisibilityPage_(timeoutInSeconds) {
const shutoffTimeoutInSeconds =
timeoutInSeconds || DEFAULT_HIGH_VISIBILITY_TIMEOUT_S;
this.showReceiveDialog_ = true;
Polymer.dom.flush();
this.$$('#receiveDialog').showHighVisibilityPage(shutoffTimeoutInSeconds);
},
/** /**
* @param {string} profileName The user's full name. * @param {string} profileName The user's full name.
* @param {string} profileLabel The user's email. * @param {string} profileLabel The user's email.
......
...@@ -219,8 +219,13 @@ suite('NearbyShare', function() { ...@@ -219,8 +219,13 @@ suite('NearbyShare', function() {
Polymer.dom.flush(); Polymer.dom.flush();
assertTrue(fakeReceiveManager.getInHighVisibilityForTest()); assertTrue(fakeReceiveManager.getInHighVisibilityForTest());
subpage.$$('#highVisibilityToggle').click(); const dialog = subpage.$$('nearby-share-receive-dialog');
Polymer.dom.flush(); assertTrue(!!dialog);
const highVisibilityDialog = dialog.$$('nearby-share-high-visibility-page');
assertTrue(test_util.isVisible(highVisibilityDialog));
dialog.close_();
assertFalse(fakeReceiveManager.getInHighVisibilityForTest()); assertFalse(fakeReceiveManager.getInHighVisibilityForTest());
}); });
......
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