Commit 8943110d authored by Ryan Hansberry's avatar Ryan Hansberry Committed by Commit Bot

[CrOS MultiDevice] Make the password entry page of setup flow the 2nd page.

Improve user experience by showing the "Start" page first, and the
"Password" page after, making for a less jarring experience.

Bug: 881610
Change-Id: I0a54c0d6c8b5ffc11e6bfdd2aba80adf6bab374d
Reviewed-on: https://chromium-review.googlesource.com/1214169Reviewed-by: default avatarJeremy Klein <jlklein@chromium.org>
Commit-Queue: Ryan Hansberry <hansberry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589701}
parent e68fe0ec
...@@ -33,7 +33,7 @@ cr.define('multidevice_setup', function() { ...@@ -33,7 +33,7 @@ cr.define('multidevice_setup', function() {
*/ */
visiblePageName_: { visiblePageName_: {
type: String, type: String,
value: PageName.PASSWORD, value: PageName.START,
// For testing purporses only // For testing purporses only
notify: true, notify: true,
}, },
...@@ -52,7 +52,6 @@ cr.define('multidevice_setup', function() { ...@@ -52,7 +52,6 @@ cr.define('multidevice_setup', function() {
*/ */
authToken_: { authToken_: {
type: String, type: String,
observer: 'onAuthTokenChanged_',
}, },
/** /**
...@@ -138,12 +137,6 @@ cr.define('multidevice_setup', function() { ...@@ -138,12 +137,6 @@ cr.define('multidevice_setup', function() {
return; return;
case PageName.PASSWORD: case PageName.PASSWORD:
this.$.passwordPage.clearPasswordTextInput(); this.$.passwordPage.clearPasswordTextInput();
this.visiblePageName_ = PageName.START;
return;
case PageName.SUCCESS:
this.exitSetupFlow_();
return;
case PageName.START:
let deviceId = /** @type {string} */ (this.selectedDeviceId_); let deviceId = /** @type {string} */ (this.selectedDeviceId_);
this.multideviceSetup.setHostDevice(deviceId, this.authToken_) this.multideviceSetup.setHostDevice(deviceId, this.authToken_)
.then((responseParams) => { .then((responseParams) => {
...@@ -151,11 +144,6 @@ cr.define('multidevice_setup', function() { ...@@ -151,11 +144,6 @@ cr.define('multidevice_setup', function() {
console.warn( console.warn(
'Failure setting device with device ID: ' + 'Failure setting device with device ID: ' +
this.selectedDeviceId_); this.selectedDeviceId_);
// If setting the host failed, it was likely due to an expired
// auth token, so go back to the password page to get a new
// token.
this.visiblePageName_ = PageName.PASSWORD;
return; return;
} }
...@@ -171,6 +159,13 @@ cr.define('multidevice_setup', function() { ...@@ -171,6 +159,13 @@ cr.define('multidevice_setup', function() {
.catch((error) => { .catch((error) => {
console.warn('Mojo service failure: ' + error); console.warn('Mojo service failure: ' + error);
}); });
return;
case PageName.SUCCESS:
this.exitSetupFlow_();
return;
case PageName.START:
this.visiblePageName_ = PageName.PASSWORD;
return;
} }
}, },
...@@ -188,16 +183,6 @@ cr.define('multidevice_setup', function() { ...@@ -188,16 +183,6 @@ cr.define('multidevice_setup', function() {
this.passwordPageForwardButtonDisabled_; this.passwordPageForwardButtonDisabled_;
}, },
/** @private */
onAuthTokenChanged_: function() {
// If the auth token has expired but the user is still on the "Start
// Setup" page (i.e., the user has not yet chosen a device to be the host
// device for this account), go back to the password page and require that
// the user enter their password again.
if (!this.authToken_ && this.visiblePageName_ == PageName.START)
this.visiblePageName_ = PageName.PASSWORD;
},
/** /**
* Notifies observers that the setup flow has completed. * Notifies observers that the setup flow has completed.
* *
......
...@@ -24,6 +24,7 @@ cr.define('multidevice_setup', () => { ...@@ -24,6 +24,7 @@ cr.define('multidevice_setup', () => {
*/ */
let backwardButton; let backwardButton;
const PASSWORD = 'password-page';
const SUCCESS = 'setup-succeeded-page'; const SUCCESS = 'setup-succeeded-page';
const START = 'start-setup-page'; const START = 'start-setup-page';
...@@ -70,10 +71,12 @@ cr.define('multidevice_setup', () => { ...@@ -70,10 +71,12 @@ cr.define('multidevice_setup', () => {
}); });
test( test(
'StartSetupPage forward button sets host in backround and ' + 'StartSetupPage forward button sets host in background and ' +
'continues OOBE (OOBE).', 'goes to PasswordPage (OOBE).',
done => { done => {
multiDeviceSetupElement.addEventListener('setup-exited', () => { multiDeviceSetupElement.addEventListener(
'visible-page-name_-changed', () => {
if (multiDeviceSetupElement.visiblePageName_ == PASSWORD)
done(); done();
}); });
...@@ -97,8 +100,18 @@ cr.define('multidevice_setup', () => { ...@@ -97,8 +100,18 @@ cr.define('multidevice_setup', () => {
backwardButton.click(); backwardButton.click();
}); });
test('PasswordPage backward button closes UI (post-OOBE)', done => {
multiDeviceSetupElement.addEventListener('setup-exited', () => done());
setVisiblePage(PASSWORD);
multiDeviceSetupElement.multideviceSetup.shouldSetHostSucceed = true;
multiDeviceSetupElement.uiMode = multidevice_setup.UiMode.POST_OOBE;
backwardButton.click();
});
test( test(
'StartSetupPage forward button goes to success page if mojo works ' + 'PasswordPage forward button goes to success page if mojo works ' +
'(post-OOBE)', '(post-OOBE)',
done => { done => {
multiDeviceSetupElement.addEventListener( multiDeviceSetupElement.addEventListener(
...@@ -107,7 +120,7 @@ cr.define('multidevice_setup', () => { ...@@ -107,7 +120,7 @@ cr.define('multidevice_setup', () => {
done(); done();
}); });
setVisiblePage(START); setVisiblePage(PASSWORD);
multiDeviceSetupElement.multideviceSetup.shouldSetHostSucceed = multiDeviceSetupElement.multideviceSetup.shouldSetHostSucceed =
true; true;
multiDeviceSetupElement.uiMode = multidevice_setup.UiMode.POST_OOBE; multiDeviceSetupElement.uiMode = multidevice_setup.UiMode.POST_OOBE;
......
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