OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/signin/user_manager_screen_handler.h" | 5 #include "chrome/browser/ui/webui/signin/user_manager_screen_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 const AccountId& account_id, | 354 const AccountId& account_id, |
355 proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type, | 355 proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type, |
356 const base::string16& auth_value) { | 356 const base::string16& auth_value) { |
357 if (GetAuthType(account_id) == | 357 if (GetAuthType(account_id) == |
358 proximity_auth::ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD) | 358 proximity_auth::ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD) |
359 return; | 359 return; |
360 | 360 |
361 user_auth_type_map_[account_id.GetUserEmail()] = auth_type; | 361 user_auth_type_map_[account_id.GetUserEmail()] = auth_type; |
362 web_ui()->CallJavascriptFunctionUnsafe( | 362 web_ui()->CallJavascriptFunctionUnsafe( |
363 "login.AccountPickerScreen.setAuthType", | 363 "login.AccountPickerScreen.setAuthType", |
364 base::StringValue(account_id.GetUserEmail()), | 364 base::StringValue(account_id.GetUserEmail()), base::Value(auth_type), |
365 base::FundamentalValue(auth_type), base::StringValue(auth_value)); | 365 base::StringValue(auth_value)); |
366 } | 366 } |
367 | 367 |
368 proximity_auth::ScreenlockBridge::LockHandler::AuthType | 368 proximity_auth::ScreenlockBridge::LockHandler::AuthType |
369 UserManagerScreenHandler::GetAuthType(const AccountId& account_id) const { | 369 UserManagerScreenHandler::GetAuthType(const AccountId& account_id) const { |
370 const auto it = user_auth_type_map_.find(account_id.GetUserEmail()); | 370 const auto it = user_auth_type_map_.find(account_id.GetUserEmail()); |
371 if (it == user_auth_type_map_.end()) | 371 if (it == user_auth_type_map_.end()) |
372 return proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD; | 372 return proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD; |
373 return it->second; | 373 return it->second; |
374 } | 374 } |
375 | 375 |
(...skipping 17 matching lines...) Expand all Loading... |
393 NOTREACHED(); | 393 NOTREACHED(); |
394 } | 394 } |
395 | 395 |
396 void UserManagerScreenHandler::HandleInitialize(const base::ListValue* args) { | 396 void UserManagerScreenHandler::HandleInitialize(const base::ListValue* args) { |
397 // If the URL has a hash parameter, store it for later. | 397 // If the URL has a hash parameter, store it for later. |
398 args->GetString(0, &url_hash_); | 398 args->GetString(0, &url_hash_); |
399 | 399 |
400 SendUserList(); | 400 SendUserList(); |
401 web_ui()->CallJavascriptFunctionUnsafe( | 401 web_ui()->CallJavascriptFunctionUnsafe( |
402 "cr.ui.UserManager.showUserManagerScreen", | 402 "cr.ui.UserManager.showUserManagerScreen", |
403 base::FundamentalValue(IsGuestModeEnabled()), | 403 base::Value(IsGuestModeEnabled()), base::Value(IsAddPersonEnabled())); |
404 base::FundamentalValue(IsAddPersonEnabled())); | |
405 | 404 |
406 proximity_auth::ScreenlockBridge::Get()->SetLockHandler(this); | 405 proximity_auth::ScreenlockBridge::Get()->SetLockHandler(this); |
407 } | 406 } |
408 | 407 |
409 void UserManagerScreenHandler::HandleAuthenticatedLaunchUser( | 408 void UserManagerScreenHandler::HandleAuthenticatedLaunchUser( |
410 const base::ListValue* args) { | 409 const base::ListValue* args) { |
411 const base::Value* profile_path_value; | 410 const base::Value* profile_path_value; |
412 if (!args->Get(0, &profile_path_value)) | 411 if (!args->Get(0, &profile_path_value)) |
413 return; | 412 return; |
414 | 413 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 void UserManagerScreenHandler::HandleAreAllProfilesLocked( | 529 void UserManagerScreenHandler::HandleAreAllProfilesLocked( |
531 const base::ListValue* args) { | 530 const base::ListValue* args) { |
532 std::string webui_callback_id; | 531 std::string webui_callback_id; |
533 CHECK_EQ(1U, args->GetSize()); | 532 CHECK_EQ(1U, args->GetSize()); |
534 bool success = args->GetString(0, &webui_callback_id); | 533 bool success = args->GetString(0, &webui_callback_id); |
535 DCHECK(success); | 534 DCHECK(success); |
536 | 535 |
537 AllowJavascript(); | 536 AllowJavascript(); |
538 ResolveJavascriptCallback( | 537 ResolveJavascriptCallback( |
539 base::StringValue(webui_callback_id), | 538 base::StringValue(webui_callback_id), |
540 base::FundamentalValue( | 539 base::Value(profiles::AreAllNonChildNonSupervisedProfilesLocked())); |
541 profiles::AreAllNonChildNonSupervisedProfilesLocked())); | |
542 } | 540 } |
543 | 541 |
544 void UserManagerScreenHandler::HandleLaunchUser(const base::ListValue* args) { | 542 void UserManagerScreenHandler::HandleLaunchUser(const base::ListValue* args) { |
545 const base::Value* profile_path_value = NULL; | 543 const base::Value* profile_path_value = NULL; |
546 if (!args->Get(0, &profile_path_value)) | 544 if (!args->Get(0, &profile_path_value)) |
547 return; | 545 return; |
548 | 546 |
549 base::FilePath profile_path; | 547 base::FilePath profile_path; |
550 if (!base::GetValueAsFilePath(*profile_path_value, &profile_path)) | 548 if (!base::GetValueAsFilePath(*profile_path_value, &profile_path)) |
551 return; | 549 return; |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 | 680 |
683 int message_id = is_synced_user ? | 681 int message_id = is_synced_user ? |
684 (has_errors ? IDS_LOGIN_POD_USER_REMOVE_WARNING_SYNC_WITH_ERRORS : | 682 (has_errors ? IDS_LOGIN_POD_USER_REMOVE_WARNING_SYNC_WITH_ERRORS : |
685 IDS_LOGIN_POD_USER_REMOVE_WARNING_SYNC) : | 683 IDS_LOGIN_POD_USER_REMOVE_WARNING_SYNC) : |
686 (has_errors ? IDS_LOGIN_POD_USER_REMOVE_WARNING_NONSYNC_WITH_ERRORS : | 684 (has_errors ? IDS_LOGIN_POD_USER_REMOVE_WARNING_NONSYNC_WITH_ERRORS : |
687 IDS_LOGIN_POD_USER_REMOVE_WARNING_NONSYNC); | 685 IDS_LOGIN_POD_USER_REMOVE_WARNING_NONSYNC); |
688 | 686 |
689 base::StringValue message = base::StringValue( | 687 base::StringValue message = base::StringValue( |
690 l10n_util::GetPluralStringFUTF16(message_id, total_count)); | 688 l10n_util::GetPluralStringFUTF16(message_id, total_count)); |
691 | 689 |
692 web_ui()->CallJavascriptFunctionUnsafe( | 690 web_ui()->CallJavascriptFunctionUnsafe("updateRemoveWarningDialogSetMessage", |
693 "updateRemoveWarningDialogSetMessage", base::StringValue(profile_path), | 691 base::StringValue(profile_path), |
694 message, base::FundamentalValue(total_count)); | 692 message, base::Value(total_count)); |
695 } | 693 } |
696 | 694 |
697 void UserManagerScreenHandler::OnGetTokenInfoResponse( | 695 void UserManagerScreenHandler::OnGetTokenInfoResponse( |
698 std::unique_ptr<base::DictionaryValue> token_info) { | 696 std::unique_ptr<base::DictionaryValue> token_info) { |
699 // Password is unchanged so user just mistyped it. Ask again. | 697 // Password is unchanged so user just mistyped it. Ask again. |
700 ReportAuthenticationResult(false, ProfileMetrics::AUTH_FAILED); | 698 ReportAuthenticationResult(false, ProfileMetrics::AUTH_FAILED); |
701 } | 699 } |
702 | 700 |
703 void UserManagerScreenHandler::OnOAuthError() { | 701 void UserManagerScreenHandler::OnOAuthError() { |
704 // Password has changed. Go through online signin flow. | 702 // Password has changed. Go through online signin flow. |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 | 966 |
969 // GetProfileByPath returns a pointer if the profile is fully loaded, NULL | 967 // GetProfileByPath returns a pointer if the profile is fully loaded, NULL |
970 // otherwise. | 968 // otherwise. |
971 Profile* profile = | 969 Profile* profile = |
972 g_browser_process->profile_manager()->GetProfileByPath(profile_path); | 970 g_browser_process->profile_manager()->GetProfileByPath(profile_path); |
973 profile_value->SetBoolean(kKeyIsProfileLoaded, profile != nullptr); | 971 profile_value->SetBoolean(kKeyIsProfileLoaded, profile != nullptr); |
974 | 972 |
975 users_list.Append(std::move(profile_value)); | 973 users_list.Append(std::move(profile_value)); |
976 } | 974 } |
977 | 975 |
978 web_ui()->CallJavascriptFunctionUnsafe( | 976 web_ui()->CallJavascriptFunctionUnsafe("login.AccountPickerScreen.loadUsers", |
979 "login.AccountPickerScreen.loadUsers", users_list, | 977 users_list, |
980 base::FundamentalValue(IsGuestModeEnabled())); | 978 base::Value(IsGuestModeEnabled())); |
981 | 979 |
982 // This is the latest C++ code we have in the flow to show the UserManager. | 980 // This is the latest C++ code we have in the flow to show the UserManager. |
983 // This may be invoked more than once per UserManager lifetime; the | 981 // This may be invoked more than once per UserManager lifetime; the |
984 // UserManager will ensure all relevant logging only happens once. | 982 // UserManager will ensure all relevant logging only happens once. |
985 UserManager::OnUserManagerShown(); | 983 UserManager::OnUserManagerShown(); |
986 } | 984 } |
987 | 985 |
988 void UserManagerScreenHandler::ReportAuthenticationResult( | 986 void UserManagerScreenHandler::ReportAuthenticationResult( |
989 bool success, | 987 bool success, |
990 ProfileMetrics::ProfileAuth auth) { | 988 ProfileMetrics::ProfileAuth auth) { |
991 ProfileMetrics::LogProfileAuthResult(auth); | 989 ProfileMetrics::LogProfileAuthResult(auth); |
992 email_address_.clear(); | 990 email_address_.clear(); |
993 | 991 |
994 if (success) { | 992 if (success) { |
995 profiles::SwitchToProfile( | 993 profiles::SwitchToProfile( |
996 authenticating_profile_path_, true, | 994 authenticating_profile_path_, true, |
997 base::Bind(&UserManagerScreenHandler::OnSwitchToProfileComplete, | 995 base::Bind(&UserManagerScreenHandler::OnSwitchToProfileComplete, |
998 weak_ptr_factory_.GetWeakPtr()), | 996 weak_ptr_factory_.GetWeakPtr()), |
999 ProfileMetrics::SWITCH_PROFILE_UNLOCK); | 997 ProfileMetrics::SWITCH_PROFILE_UNLOCK); |
1000 } else { | 998 } else { |
1001 web_ui()->CallJavascriptFunctionUnsafe( | 999 web_ui()->CallJavascriptFunctionUnsafe( |
1002 "cr.ui.UserManager.showSignInError", base::FundamentalValue(0), | 1000 "cr.ui.UserManager.showSignInError", base::Value(0), |
1003 base::StringValue(l10n_util::GetStringUTF8( | 1001 base::StringValue(l10n_util::GetStringUTF8( |
1004 auth == ProfileMetrics::AUTH_FAILED_OFFLINE | 1002 auth == ProfileMetrics::AUTH_FAILED_OFFLINE |
1005 ? IDS_LOGIN_ERROR_AUTHENTICATING_OFFLINE | 1003 ? IDS_LOGIN_ERROR_AUTHENTICATING_OFFLINE |
1006 : IDS_LOGIN_ERROR_AUTHENTICATING)), | 1004 : IDS_LOGIN_ERROR_AUTHENTICATING)), |
1007 base::StringValue(""), base::FundamentalValue(0)); | 1005 base::StringValue(""), base::Value(0)); |
1008 } | 1006 } |
1009 } | 1007 } |
1010 | 1008 |
1011 void UserManagerScreenHandler::OnBrowserWindowReady(Browser* browser) { | 1009 void UserManagerScreenHandler::OnBrowserWindowReady(Browser* browser) { |
1012 DCHECK(browser); | 1010 DCHECK(browser); |
1013 DCHECK(browser->window()); | 1011 DCHECK(browser->window()); |
1014 | 1012 |
1015 // Unlock the profile after browser opens so startup can read the lock bit. | 1013 // Unlock the profile after browser opens so startup can read the lock bit. |
1016 // Any necessary authentication must have been successful to reach this point. | 1014 // Any necessary authentication must have been successful to reach this point. |
1017 if (!browser->profile()->IsGuestSession()) { | 1015 if (!browser->profile()->IsGuestSession()) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 Profile* profile, Profile::CreateStatus profile_create_status) { | 1053 Profile* profile, Profile::CreateStatus profile_create_status) { |
1056 Browser* browser = chrome::FindAnyBrowser(profile, false); | 1054 Browser* browser = chrome::FindAnyBrowser(profile, false); |
1057 if (browser && browser->window()) { | 1055 if (browser && browser->window()) { |
1058 OnBrowserWindowReady(browser); | 1056 OnBrowserWindowReady(browser); |
1059 } else { | 1057 } else { |
1060 registrar_.Add(this, | 1058 registrar_.Add(this, |
1061 chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 1059 chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
1062 content::NotificationService::AllSources()); | 1060 content::NotificationService::AllSources()); |
1063 } | 1061 } |
1064 } | 1062 } |
OLD | NEW |