Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 void CancelScheduledCall() { call_scheduled_ = false; } | 130 void CancelScheduledCall() { call_scheduled_ = false; } |
| 131 void ScheduleCall() { call_scheduled_ = true; } | 131 void ScheduleCall() { call_scheduled_ = true; } |
| 132 | 132 |
| 133 private: | 133 private: |
| 134 base::Closure callback_; | 134 base::Closure callback_; |
| 135 bool call_scheduled_; | 135 bool call_scheduled_; |
| 136 | 136 |
| 137 DISALLOW_COPY_AND_ASSIGN(CallOnReturn); | 137 DISALLOW_COPY_AND_ASSIGN(CallOnReturn); |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 class BoolAutoSet { | |
| 141 public: | |
| 142 BoolAutoSet(bool* ref, bool val_at_destruct) | |
| 143 : bool_ref_(ref), | |
| 144 value_at_destruct_(val_at_destruct) { | |
| 145 } | |
| 146 | |
| 147 ~BoolAutoSet() { | |
| 148 *bool_ref_ = value_at_destruct_; | |
| 149 } | |
| 150 | |
| 151 private: | |
| 152 bool* bool_ref_; | |
| 153 bool value_at_destruct_; | |
| 154 | |
| 155 DISALLOW_COPY_AND_ASSIGN(BoolAutoSet); | |
| 156 }; | |
| 157 | |
| 140 } // namespace | 158 } // namespace |
| 141 | 159 |
| 142 namespace chromeos { | 160 namespace chromeos { |
| 143 | 161 |
| 144 namespace { | 162 namespace { |
| 145 | 163 |
| 146 bool IsOnline(NetworkStateInformer::State state, | 164 bool IsOnline(NetworkStateInformer::State state, |
| 147 NetworkError::ErrorReason reason) { | 165 NetworkError::ErrorReason reason) { |
| 148 return state == NetworkStateInformer::ONLINE && | 166 return state == NetworkStateInformer::ONLINE && |
| 149 reason != NetworkError::ERROR_REASON_PORTAL_DETECTED && | 167 reason != NetworkError::ERROR_REASON_PORTAL_DETECTED && |
| (...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 904 if (last_user_removed) | 922 if (last_user_removed) |
| 905 OnShowAddUser(); | 923 OnShowAddUser(); |
| 906 } | 924 } |
| 907 | 925 |
| 908 void SigninScreenHandler::OnUserImageChanged(const user_manager::User& user) { | 926 void SigninScreenHandler::OnUserImageChanged(const user_manager::User& user) { |
| 909 if (page_is_ready()) | 927 if (page_is_ready()) |
| 910 CallJS("login.AccountPickerScreen.updateUserImage", user.GetAccountId()); | 928 CallJS("login.AccountPickerScreen.updateUserImage", user.GetAccountId()); |
| 911 } | 929 } |
| 912 | 930 |
| 913 void SigninScreenHandler::OnPreferencesChanged() { | 931 void SigninScreenHandler::OnPreferencesChanged() { |
| 932 static bool first_preference_changed = true; | |
| 933 | |
| 914 // Make sure that one of the login UI is fully functional now, otherwise | 934 // Make sure that one of the login UI is fully functional now, otherwise |
| 915 // preferences update would be picked up next time it will be shown. | 935 // preferences update would be picked up next time it will be shown. |
| 916 if (!webui_visible_) { | 936 if (!webui_visible_) { |
| 917 LOG(WARNING) << "Login UI is not active - postponed prefs change."; | 937 LOG(WARNING) << "Login UI is not active - postponed prefs change."; |
| 918 preferences_changed_delayed_ = true; | 938 preferences_changed_delayed_ = true; |
| 919 return; | 939 return; |
| 920 } | 940 } |
| 921 | 941 |
| 942 BoolAutoSet at_return_setter(&first_preference_changed, false); | |
| 943 preferences_changed_delayed_ = false; | |
| 944 | |
| 945 if (!delegate_) | |
| 946 return; | |
| 947 | |
| 922 // Send the updated user list to the UI. | 948 // Send the updated user list to the UI. |
| 923 if (delegate_) | 949 delegate_->HandleGetUsers(); |
| 924 delegate_->HandleGetUsers(); | 950 if (GetCurrentScreen() == OobeScreen::SCREEN_ACCOUNT_PICKER && |
| 951 delegate_->ShowUsersHasChanged() && | |
| 952 !delegate_->IsShowUsers()) { | |
| 953 // We are at the account picker screen and the POD setting has changed | |
| 954 // to be disabled. We need to show the add user page. | |
| 955 HandleShowAddUser(nullptr); | |
| 956 return; | |
| 957 } | |
| 925 | 958 |
| 926 if (delegate_ && !delegate_->IsShowUsers()) { | 959 if (delegate_->AllowNewUserChanged() || |
| 927 HandleShowAddUser(nullptr); | 960 (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.
| |
| 928 } else { | 961 // We need to reload GAIA if it's the very first preference change and the |
| 962 // current screen is neither GAIA not the account picker or the allow new | |
| 963 // user setting has changed so that reloaded GAIA shows/hides the option to | |
| 964 // create a new account. | |
| 929 UpdateUIState(UI_STATE_ACCOUNT_PICKER, nullptr); | 965 UpdateUIState(UI_STATE_ACCOUNT_PICKER, nullptr); |
| 930 } | 966 } |
| 931 | |
| 932 preferences_changed_delayed_ = false; | |
| 933 } | 967 } |
| 934 | 968 |
| 935 void SigninScreenHandler::ResetSigninScreenHandlerDelegate() { | 969 void SigninScreenHandler::ResetSigninScreenHandlerDelegate() { |
| 936 SetDelegate(nullptr); | 970 SetDelegate(nullptr); |
| 937 } | 971 } |
| 938 | 972 |
| 939 void SigninScreenHandler::ShowError(int login_attempts, | 973 void SigninScreenHandler::ShowError(int login_attempts, |
| 940 const std::string& error_text, | 974 const std::string& error_text, |
| 941 const std::string& help_link_text, | 975 const std::string& help_link_text, |
| 942 HelpAppLauncher::HelpTopic help_topic_id) { | 976 HelpAppLauncher::HelpTopic help_topic_id) { |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1468 } | 1502 } |
| 1469 | 1503 |
| 1470 void SigninScreenHandler::OnFeedbackFinished() { | 1504 void SigninScreenHandler::OnFeedbackFinished() { |
| 1471 CallJS("login.UnrecoverableCryptohomeErrorScreen.resumeAfterFeedbackUI"); | 1505 CallJS("login.UnrecoverableCryptohomeErrorScreen.resumeAfterFeedbackUI"); |
| 1472 | 1506 |
| 1473 // Recreate user's cryptohome after the feedback is attempted. | 1507 // Recreate user's cryptohome after the feedback is attempted. |
| 1474 HandleResyncUserData(); | 1508 HandleResyncUserData(); |
| 1475 } | 1509 } |
| 1476 | 1510 |
| 1477 } // namespace chromeos | 1511 } // namespace chromeos |
| OLD | NEW |