Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5705)

Unified Diff: chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc

Issue 2107353002: Fix the flaky test KioskTest.LaunchAppUserCancel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplify Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
index 88971eaa06931cc1a1245d12e71b10a0fe8e1226..05092661187b0369729f0a7db5d103911d0206fa 100644
--- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
@@ -137,6 +137,24 @@ class CallOnReturn {
DISALLOW_COPY_AND_ASSIGN(CallOnReturn);
};
+class BoolAutoSet {
+ public:
+ BoolAutoSet(bool* ref, bool val_at_destruct)
+ : bool_ref_(ref),
+ value_at_destruct_(val_at_destruct) {
+ }
+
+ ~BoolAutoSet() {
+ *bool_ref_ = value_at_destruct_;
+ }
+
+ private:
+ bool* bool_ref_;
+ bool value_at_destruct_;
+
+ DISALLOW_COPY_AND_ASSIGN(BoolAutoSet);
+};
+
} // namespace
namespace chromeos {
@@ -911,6 +929,8 @@ void SigninScreenHandler::OnUserImageChanged(const user_manager::User& user) {
}
void SigninScreenHandler::OnPreferencesChanged() {
+ static bool first_preference_changed = true;
+
// Make sure that one of the login UI is fully functional now, otherwise
// preferences update would be picked up next time it will be shown.
if (!webui_visible_) {
@@ -919,17 +939,31 @@ void SigninScreenHandler::OnPreferencesChanged() {
return;
}
- // Send the updated user list to the UI.
- if (delegate_)
- delegate_->HandleGetUsers();
+ BoolAutoSet at_return_setter(&first_preference_changed, false);
+ preferences_changed_delayed_ = false;
+
+ if (!delegate_)
+ return;
- if (delegate_ && !delegate_->IsShowUsers()) {
+ // Send the updated user list to the UI.
+ delegate_->HandleGetUsers();
+ if (GetCurrentScreen() == OobeScreen::SCREEN_ACCOUNT_PICKER &&
+ delegate_->ShowUsersHasChanged() &&
+ !delegate_->IsShowUsers()) {
+ // We are at the account picker screen and the POD setting has changed
+ // to be disabled. We need to show the add user page.
HandleShowAddUser(nullptr);
- } else {
- UpdateUIState(UI_STATE_ACCOUNT_PICKER, nullptr);
+ return;
}
- preferences_changed_delayed_ = false;
+ if (delegate_->AllowNewUserChanged() ||
+ (first_preference_changed && !IsSigninScreen(GetCurrentScreen()))) {
xiyuan 2016/06/30 20:21:40 Can we get rid of |first_preference_changed| and u
afakhry 2016/07/01 13:14:33 Done.
+ // We need to reload GAIA if it's the very first preference change and the
+ // current screen is neither GAIA not the account picker or the allow new
+ // user setting has changed so that reloaded GAIA shows/hides the option to
+ // create a new account.
+ UpdateUIState(UI_STATE_ACCOUNT_PICKER, nullptr);
+ }
}
void SigninScreenHandler::ResetSigninScreenHandlerDelegate() {

Powered by Google App Engine
This is Rietveld 408576698