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

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

Issue 14063018: Implemented argument wrapping for CallJS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Get rid of macro. Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 &SigninScreenHandler::HandleShowLoadingTimeoutError); 773 &SigninScreenHandler::HandleShowLoadingTimeoutError);
774 AddCallback("updateOfflineLogin", 774 AddCallback("updateOfflineLogin",
775 &SigninScreenHandler::HandleUpdateOfflineLogin); 775 &SigninScreenHandler::HandleUpdateOfflineLogin);
776 } 776 }
777 777
778 void SigninScreenHandler::HandleGetUsers() { 778 void SigninScreenHandler::HandleGetUsers() {
779 SendUserList(false); 779 SendUserList(false);
780 } 780 }
781 781
782 void SigninScreenHandler::ClearAndEnablePassword() { 782 void SigninScreenHandler::ClearAndEnablePassword() {
783 base::FundamentalValue force_online(false); 783 CallJS("cr.ui.Oobe.resetSigninUI", false);
784 CallJS("cr.ui.Oobe.resetSigninUI", force_online);
785 } 784 }
786 785
787 void SigninScreenHandler::ClearUserPodPassword() { 786 void SigninScreenHandler::ClearUserPodPassword() {
788 CallJS("cr.ui.Oobe.clearUserPodPassword"); 787 CallJS("cr.ui.Oobe.clearUserPodPassword");
789 } 788 }
790 789
791 void SigninScreenHandler::OnLoginSuccess(const std::string& username) { 790 void SigninScreenHandler::OnLoginSuccess(const std::string& username) {
792 base::StringValue username_value(username); 791 CallJS("cr.ui.Oobe.onLoginSuccess", username);
793 CallJS("cr.ui.Oobe.onLoginSuccess", username_value);
794 } 792 }
795 793
796 void SigninScreenHandler::OnUserRemoved(const std::string& username) { 794 void SigninScreenHandler::OnUserRemoved(const std::string& username) {
797 SendUserList(false); 795 SendUserList(false);
798 } 796 }
799 797
800 void SigninScreenHandler::OnUserImageChanged(const User& user) { 798 void SigninScreenHandler::OnUserImageChanged(const User& user) {
801 if (!page_is_ready()) 799 if (page_is_ready())
802 return; 800 CallJS("login.AccountPickerScreen.updateUserImage", user.email());
803
804 base::StringValue user_email(user.email());
805 CallJS("login.AccountPickerScreen.updateUserImage", user_email);
806 } 801 }
807 802
808 void SigninScreenHandler::OnPreferencesChanged() { 803 void SigninScreenHandler::OnPreferencesChanged() {
809 // Make sure that one of the login UI is active now, otherwise 804 // Make sure that one of the login UI is active now, otherwise
810 // preferences update would be picked up next time it will be shown. 805 // preferences update would be picked up next time it will be shown.
811 if (!login_ui_active_) { 806 if (!login_ui_active_) {
812 LOG(WARNING) << "Login UI is not active - ignoring prefs change."; 807 LOG(WARNING) << "Login UI is not active - ignoring prefs change.";
813 return; 808 return;
814 } 809 }
815 810
816 if (delegate_ && !delegate_->IsShowUsers()) { 811 if (delegate_ && !delegate_->IsShowUsers()) {
817 HandleShowAddUser(NULL); 812 HandleShowAddUser(NULL);
818 } else { 813 } else {
819 SendUserList(false); 814 SendUserList(false);
820 UpdateUIState(UI_STATE_ACCOUNT_PICKER, NULL); 815 UpdateUIState(UI_STATE_ACCOUNT_PICKER, NULL);
821 } 816 }
822 } 817 }
823 818
824 void SigninScreenHandler::ResetSigninScreenHandlerDelegate() { 819 void SigninScreenHandler::ResetSigninScreenHandlerDelegate() {
825 SetDelegate(NULL); 820 SetDelegate(NULL);
826 } 821 }
827 822
828 void SigninScreenHandler::ShowError(int login_attempts, 823 void SigninScreenHandler::ShowError(int login_attempts,
829 const std::string& error_text, 824 const std::string& error_text,
830 const std::string& help_link_text, 825 const std::string& help_link_text,
831 HelpAppLauncher::HelpTopic help_topic_id) { 826 HelpAppLauncher::HelpTopic help_topic_id) {
832 CallJS("cr.ui.Oobe.showSignInError", 827 CallJS("cr.ui.Oobe.showSignInError", login_attempts, error_text,
833 base::FundamentalValue(login_attempts), 828 help_link_text, static_cast<int>(help_topic_id));
834 base::StringValue(error_text),
835 base::StringValue(help_link_text),
836 base::FundamentalValue(static_cast<int>(help_topic_id)));
837 } 829 }
838 830
839 void SigninScreenHandler::ShowErrorScreen(LoginDisplay::SigninError error_id) { 831 void SigninScreenHandler::ShowErrorScreen(LoginDisplay::SigninError error_id) {
840 switch (error_id) { 832 switch (error_id) {
841 case LoginDisplay::TPM_ERROR: 833 case LoginDisplay::TPM_ERROR:
842 CallJS("cr.ui.Oobe.showTpmError"); 834 CallJS("cr.ui.Oobe.showTpmError");
843 break; 835 break;
844 default: 836 default:
845 NOTREACHED() << "Unknown sign in error"; 837 NOTREACHED() << "Unknown sign in error";
846 break; 838 break;
847 } 839 }
848 } 840 }
849 841
850 void SigninScreenHandler::ShowSigninUI(const std::string& email) { 842 void SigninScreenHandler::ShowSigninUI(const std::string& email) {
851 base::StringValue email_value(email); 843 CallJS("cr.ui.Oobe.showSigninUI", email);
852 CallJS("cr.ui.Oobe.showSigninUI", email_value);
853 } 844 }
854 845
855 void SigninScreenHandler::ShowGaiaPasswordChanged(const std::string& username) { 846 void SigninScreenHandler::ShowGaiaPasswordChanged(const std::string& username) {
856 email_ = username; 847 email_ = username;
857 password_changed_for_.insert(email_); 848 password_changed_for_.insert(email_);
858 base::StringValue email_value(email_); 849 CallJS("cr.ui.Oobe.showSigninUI", email_);
859 CallJS("cr.ui.Oobe.showSigninUI", email_value); 850 CallJS("login.AccountPickerScreen.updateUserGaiaNeeded", email_);
860 CallJS("login.AccountPickerScreen.updateUserGaiaNeeded", email_value);
861 } 851 }
862 852
863 void SigninScreenHandler::ShowPasswordChangedDialog(bool show_password_error) { 853 void SigninScreenHandler::ShowPasswordChangedDialog(bool show_password_error) {
864 base::FundamentalValue showError(show_password_error); 854 CallJS("cr.ui.Oobe.showPasswordChangedScreen", show_password_error);
865 CallJS("cr.ui.Oobe.showPasswordChangedScreen", showError);
866 } 855 }
867 856
868 void SigninScreenHandler::ShowSigninScreenForCreds( 857 void SigninScreenHandler::ShowSigninScreenForCreds(
869 const std::string& username, 858 const std::string& username,
870 const std::string& password) { 859 const std::string& password) {
871 VLOG(2) << "ShowSigninScreenForCreds " << username << " " << password; 860 VLOG(2) << "ShowSigninScreenForCreds " << username << " " << password;
872 861
873 test_user_ = username; 862 test_user_ = username;
874 test_pass_ = password; 863 test_pass_ = password;
875 HandleShowAddUser(NULL); 864 HandleShowAddUser(NULL);
876 } 865 }
877 866
878 void SigninScreenHandler::SetGaiaOriginForTesting(const std::string& arg) { 867 void SigninScreenHandler::SetGaiaOriginForTesting(const std::string& arg) {
879 gaia_origin_for_test_ = arg; 868 gaia_origin_for_test_ = arg;
880 } 869 }
881 870
882 void SigninScreenHandler::OnBrowsingDataRemoverDone() { 871 void SigninScreenHandler::OnBrowsingDataRemoverDone() {
883 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 872 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
884 cookie_remover_ = NULL; 873 cookie_remover_ = NULL;
885 cookies_cleared_ = true; 874 cookies_cleared_ = true;
886 cookie_remover_callback_.Run(); 875 cookie_remover_callback_.Run();
887 cookie_remover_callback_.Reset(); 876 cookie_remover_callback_.Reset();
888 } 877 }
889 878
890 void SigninScreenHandler::OnCapsLockChange(bool enabled) { 879 void SigninScreenHandler::OnCapsLockChange(bool enabled) {
891 if (page_is_ready()) { 880 if (page_is_ready())
892 base::FundamentalValue capsLockState(enabled); 881 CallJS("login.AccountPickerScreen.setCapsLockState", enabled);
893 CallJS("login.AccountPickerScreen.setCapsLockState", capsLockState);
894 }
895 } 882 }
896 883
897 void SigninScreenHandler::Observe(int type, 884 void SigninScreenHandler::Observe(int type,
898 const content::NotificationSource& source, 885 const content::NotificationSource& source,
899 const content::NotificationDetails& details) { 886 const content::NotificationDetails& details) {
900 switch (type) { 887 switch (type) {
901 case chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED: { 888 case chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED: {
902 UpdateAuthExtension(); 889 UpdateAuthExtension();
903 UpdateAddButtonStatus(); 890 UpdateAddButtonStatus();
904 break; 891 break;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 CallJS("login.GaiaSigninScreen.loadAuthExtension", params); 1025 CallJS("login.GaiaSigninScreen.loadAuthExtension", params);
1039 } 1026 }
1040 1027
1041 void SigninScreenHandler::UpdateAuthExtension() { 1028 void SigninScreenHandler::UpdateAuthExtension() {
1042 DictionaryValue params; 1029 DictionaryValue params;
1043 UpdateAuthParamsFromSettings(&params, CrosSettings::Get()); 1030 UpdateAuthParamsFromSettings(&params, CrosSettings::Get());
1044 CallJS("login.GaiaSigninScreen.updateAuthExtension", params); 1031 CallJS("login.GaiaSigninScreen.updateAuthExtension", params);
1045 } 1032 }
1046 1033
1047 void SigninScreenHandler::UpdateAddButtonStatus() { 1034 void SigninScreenHandler::UpdateAddButtonStatus() {
1048 base::FundamentalValue disabled(AllWhitelistedUsersPresent()); 1035 CallJS("cr.ui.login.DisplayManager.updateAddUserButtonStatus",
1049 CallJS("cr.ui.login.DisplayManager.updateAddUserButtonStatus", disabled); 1036 AllWhitelistedUsersPresent());
1050 } 1037 }
1051 1038
1052 void SigninScreenHandler::HandleCompleteLogin(const std::string& typed_email, 1039 void SigninScreenHandler::HandleCompleteLogin(const std::string& typed_email,
1053 const std::string& password) { 1040 const std::string& password) {
1054 if (!delegate_) 1041 if (!delegate_)
1055 return; 1042 return;
1056 const std::string sanitized_email = gaia::SanitizeEmail(typed_email); 1043 const std::string sanitized_email = gaia::SanitizeEmail(typed_email);
1057 delegate_->SetDisplayEmail(sanitized_email); 1044 delegate_->SetDisplayEmail(sanitized_email);
1058 delegate_->CompleteLogin(UserContext(sanitized_email, 1045 delegate_->CompleteLogin(UserContext(sanitized_email,
1059 password, 1046 password,
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 !is_public_account && 1243 !is_public_account &&
1257 !signed_in && 1244 !signed_in &&
1258 !is_signin_to_add); 1245 !is_signin_to_add);
1259 1246
1260 users_list.Append(user_dict); 1247 users_list.Append(user_dict);
1261 if (!is_owner) 1248 if (!is_owner)
1262 ++non_owner_count; 1249 ++non_owner_count;
1263 } 1250 }
1264 } 1251 }
1265 1252
1266 base::FundamentalValue animated_value(animated); 1253 CallJS("login.AccountPickerScreen.loadUsers", users_list, animated,
1267 base::FundamentalValue guest_value(delegate_->IsShowGuest()); 1254 delegate_->IsShowGuest());
1268 CallJS("login.AccountPickerScreen.loadUsers",
1269 users_list, animated_value, guest_value);
1270 } 1255 }
1271 1256
1272 void SigninScreenHandler::HandleAccountPickerReady() { 1257 void SigninScreenHandler::HandleAccountPickerReady() {
1273 LOG(INFO) << "Login WebUI >> AccountPickerReady"; 1258 LOG(INFO) << "Login WebUI >> AccountPickerReady";
1274 1259
1275 if (delegate_ && !ScreenLocker::default_screen_locker() && 1260 if (delegate_ && !ScreenLocker::default_screen_locker() &&
1276 !chromeos::IsMachineHWIDCorrect() && 1261 !chromeos::IsMachineHWIDCorrect() &&
1277 !oobe_ui_) { 1262 !oobe_ui_) {
1278 delegate_->ShowWrongHWIDScreen(); 1263 delegate_->ShowWrongHWIDScreen();
1279 return; 1264 return;
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 if (!cros_settings) 1557 if (!cros_settings)
1573 return false; 1558 return false;
1574 1559
1575 // Offline login is allowed only when user pods are hidden. 1560 // Offline login is allowed only when user pods are hidden.
1576 bool show_pods; 1561 bool show_pods;
1577 cros_settings->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, &show_pods); 1562 cros_settings->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, &show_pods);
1578 return !show_pods; 1563 return !show_pods;
1579 } 1564 }
1580 1565
1581 } // namespace chromeos 1566 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698