Commit 6f99f8fd authored by Wenzhao Zang's avatar Wenzhao Zang Committed by Commit Bot

cros: Skip web-ui public session expanded view in demo mode

Because views login hasn't implemented the code path to transition
between web-ui OOBE to views-login directly, the web-ui public session
pod is shown one-time only right after the enrollment completes. So for
this bug, we should implement the web-ui and views versions separately.

Bug: 882692
Change-Id: Ia3945b2dbfdb3a2e38db4d59c74248a29004bf37
Reviewed-on: https://chromium-review.googlesource.com/1226256Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Reviewed-by: default avatarAga Wronska <agawronska@chromium.org>
Commit-Queue: Wenzhao (Colin) Zang <wzang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#591500}
parent 307d8f43
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
#include "chrome/browser/chromeos/language_preferences.h" #include "chrome/browser/chromeos/language_preferences.h"
#include "chrome/browser/chromeos/lock_screen_apps/state_controller.h" #include "chrome/browser/chromeos/lock_screen_apps/state_controller.h"
#include "chrome/browser/chromeos/login/demo_mode/demo_session.h"
#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_service.h" #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_service.h"
#include "chrome/browser/chromeos/login/error_screens_histogram_helper.h" #include "chrome/browser/chromeos/login/error_screens_histogram_helper.h"
#include "chrome/browser/chromeos/login/help_app_launcher.h" #include "chrome/browser/chromeos/login/help_app_launcher.h"
...@@ -543,6 +544,7 @@ void SigninScreenHandler::RegisterMessages() { ...@@ -543,6 +544,7 @@ void SigninScreenHandler::RegisterMessages() {
&SigninScreenHandler::HandleGetPublicSessionKeyboardLayouts); &SigninScreenHandler::HandleGetPublicSessionKeyboardLayouts);
AddCallback("getTabletModeState", AddCallback("getTabletModeState",
&SigninScreenHandler::HandleGetTabletModeState); &SigninScreenHandler::HandleGetTabletModeState);
AddCallback("getDemoModeState", &SigninScreenHandler::HandleGetDemoModeState);
AddCallback("logRemoveUserWarningShown", AddCallback("logRemoveUserWarningShown",
&SigninScreenHandler::HandleLogRemoveUserWarningShown); &SigninScreenHandler::HandleLogRemoveUserWarningShown);
AddCallback("firstIncorrectPasswordAttempt", AddCallback("firstIncorrectPasswordAttempt",
...@@ -1602,6 +1604,11 @@ void SigninScreenHandler::HandleGetTabletModeState() { ...@@ -1602,6 +1604,11 @@ void SigninScreenHandler::HandleGetTabletModeState() {
TabletModeClient::Get()->tablet_mode_enabled()); TabletModeClient::Get()->tablet_mode_enabled());
} }
void SigninScreenHandler::HandleGetDemoModeState() {
CallJS("login.AccountPickerScreen.setDemoModeState",
DemoSession::IsDeviceInDemoMode());
}
void SigninScreenHandler::HandleLogRemoveUserWarningShown() { void SigninScreenHandler::HandleLogRemoveUserWarningShown() {
ProfileMetrics::LogProfileDeleteUser( ProfileMetrics::LogProfileDeleteUser(
ProfileMetrics::DELETE_PROFILE_USER_MANAGER_SHOW_WARNING); ProfileMetrics::DELETE_PROFILE_USER_MANAGER_SHOW_WARNING);
......
...@@ -401,6 +401,7 @@ class SigninScreenHandler ...@@ -401,6 +401,7 @@ class SigninScreenHandler
void HandleGetPublicSessionKeyboardLayouts(const AccountId& account_id, void HandleGetPublicSessionKeyboardLayouts(const AccountId& account_id,
const std::string& locale); const std::string& locale);
void HandleGetTabletModeState(); void HandleGetTabletModeState();
void HandleGetDemoModeState();
void HandleLogRemoveUserWarningShown(); void HandleLogRemoveUserWarningShown();
void HandleFirstIncorrectPasswordAttempt(const AccountId& account_id); void HandleFirstIncorrectPasswordAttempt(const AccountId& account_id);
void HandleMaxIncorrectPasswordAttempts(const AccountId& account_id); void HandleMaxIncorrectPasswordAttempts(const AccountId& account_id);
......
...@@ -42,6 +42,7 @@ login.createScreen('AccountPickerScreen', 'account-picker', function() { ...@@ -42,6 +42,7 @@ login.createScreen('AccountPickerScreen', 'account-picker', function() {
'setPinEnabledForUser', 'setPinEnabledForUser',
'setAuthType', 'setAuthType',
'setTabletModeState', 'setTabletModeState',
'setDemoModeState',
'setPublicSessionDisplayName', 'setPublicSessionDisplayName',
'setPublicSessionLocales', 'setPublicSessionLocales',
'setPublicSessionKeyboardLayouts', 'setPublicSessionKeyboardLayouts',
...@@ -166,6 +167,7 @@ login.createScreen('AccountPickerScreen', 'account-picker', function() { ...@@ -166,6 +167,7 @@ login.createScreen('AccountPickerScreen', 'account-picker', function() {
return; return;
} }
chrome.send('getTabletModeState'); chrome.send('getTabletModeState');
chrome.send('getDemoModeState');
if (!this.firstShown_) if (!this.firstShown_)
return; return;
this.firstShown_ = false; this.firstShown_ = false;
...@@ -432,6 +434,14 @@ login.createScreen('AccountPickerScreen', 'account-picker', function() { ...@@ -432,6 +434,14 @@ login.createScreen('AccountPickerScreen', 'account-picker', function() {
$('pod-row').setTabletModeState(isTabletModeEnabled); $('pod-row').setTabletModeState(isTabletModeEnabled);
}, },
/**
* Sets whether the device is in demo mode.
* @param {boolean} isDeviceInDemoMode true if the device is in demo mode.
*/
setDemoModeState: function(isDeviceInDemoMode) {
$('pod-row').setDemoModeState(isDeviceInDemoMode);
},
/** /**
* Enables or disables the pin keyboard for the given user. This may change * Enables or disables the pin keyboard for the given user. This may change
* pin keyboard visibility. * pin keyboard visibility.
......
...@@ -2409,6 +2409,19 @@ cr.define('login', function() { ...@@ -2409,6 +2409,19 @@ cr.define('login', function() {
*/ */
lastPosition: {left: 'unset', top: 'unset'}, lastPosition: {left: 'unset', top: 'unset'},
/**
* If true, the public session should be launched directly without showing
* the expanded view when the pod is activated.
* @type {boolean}
*/
skipExpandedView: false,
/**
* If true, further attempts of entering public session should bail out.
* @type {boolean}
*/
isEnteringPublicSession_: false,
/** /**
* The Learn more dialog. * The Learn more dialog.
* @type {HTMLDivElement} * @type {HTMLDivElement}
...@@ -2523,17 +2536,7 @@ cr.define('login', function() { ...@@ -2523,17 +2536,7 @@ cr.define('login', function() {
this.enterButtonElement.tabIndex = UserPodTabOrder.POD_INPUT; this.enterButtonElement.tabIndex = UserPodTabOrder.POD_INPUT;
this.enterButtonElement.addEventListener('click', (function(e) { this.enterButtonElement.addEventListener('click', (function(e) {
this.enterButtonElement.disabled = true; this.enterButtonElement.disabled = true;
var locale = this.querySelector('.language-select').value; this.enterPublicSession_();
var keyboardSelect = this.querySelector('.keyboard-select');
// The contents of |keyboardSelect| is updated asynchronously. If its
// locale does not match |locale|, it has not updated yet and the
// currently selected keyboard layout may not be applicable to |locale|.
// Do not return any keyboard layout in this case and let the backend
// choose a suitable layout.
var keyboardLayout =
keyboardSelect.loadedLocale == locale ? keyboardSelect.value : '';
chrome.send('launchPublicSession',
[this.user.username, locale, keyboardLayout]);
}).bind(this)); }).bind(this));
}, },
...@@ -2583,8 +2586,12 @@ cr.define('login', function() { ...@@ -2583,8 +2586,12 @@ cr.define('login', function() {
/** @override */ /** @override */
activate: function(e) { activate: function(e) {
if (!this.expanded) { if (!this.expanded) {
this.expanded = true; if (this.skipExpandedView) {
this.focusInput(); this.enterPublicSession_();
} else {
this.expanded = true;
this.focusInput();
}
} }
return true; return true;
}, },
...@@ -2768,6 +2775,28 @@ cr.define('login', function() { ...@@ -2768,6 +2775,28 @@ cr.define('login', function() {
// Retrieve a list of keyboard layouts applicable to the locale that is // Retrieve a list of keyboard layouts applicable to the locale that is
// now selected. // now selected.
this.getPublicSessionKeyboardLayouts_(); this.getPublicSessionKeyboardLayouts_();
},
/**
* Launches the public session with the user-selected locale and keyboard
* layout (if available).
* @private
*/
enterPublicSession_: function() {
if (this.isEnteringPublicSession_)
return;
this.isEnteringPublicSession_ = true;
var locale = this.querySelector('.language-select').value;
var keyboardSelect = this.querySelector('.keyboard-select');
// The contents of |keyboardSelect| is updated asynchronously. If its
// locale does not match |locale|, it has not updated yet and the
// currently selected keyboard layout may not be applicable to |locale|.
// Do not return any keyboard layout in this case and let the backend
// choose a suitable layout.
var keyboardLayout =
keyboardSelect.loadedLocale == locale ? keyboardSelect.value : '';
chrome.send(
'launchPublicSession', [this.user.username, locale, keyboardLayout]);
} }
}; };
...@@ -3616,7 +3645,7 @@ cr.define('login', function() { ...@@ -3616,7 +3645,7 @@ cr.define('login', function() {
/** /**
* Sets the state of tablet mode. * Sets the state of tablet mode.
* @param {boolean} isTabletModeEnabled true if the mode is on. * @param {boolean} isTabletModeEnabled
*/ */
setTabletModeState: function(isTabletModeEnabled) { setTabletModeState: function(isTabletModeEnabled) {
this.tabletModeEnabled_ = isTabletModeEnabled; this.tabletModeEnabled_ = isTabletModeEnabled;
...@@ -3630,6 +3659,17 @@ cr.define('login', function() { ...@@ -3630,6 +3659,17 @@ cr.define('login', function() {
}); });
}, },
/**
* Sets whether the device is in demo mode.
* @param {boolean} isDeviceInDemoMode
*/
setDemoModeState: function(isDeviceInDemoMode) {
for (let pod of this.pods) {
if (pod.isPublicSessionPod)
pod.skipExpandedView = isDeviceInDemoMode;
}
},
/** /**
* Updates the display name shown on a public session pod. * Updates the display name shown on a public session pod.
* @param {string} userID The user ID of the public session * @param {string} userID The user ID of the public session
......
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