| 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type, | 353 proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type, |
| 354 const base::string16& auth_value) { | 354 const base::string16& auth_value) { |
| 355 if (GetAuthType(account_id) == | 355 if (GetAuthType(account_id) == |
| 356 proximity_auth::ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD) | 356 proximity_auth::ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD) |
| 357 return; | 357 return; |
| 358 | 358 |
| 359 user_auth_type_map_[account_id.GetUserEmail()] = auth_type; | 359 user_auth_type_map_[account_id.GetUserEmail()] = auth_type; |
| 360 web_ui()->CallJavascriptFunctionUnsafe( | 360 web_ui()->CallJavascriptFunctionUnsafe( |
| 361 "login.AccountPickerScreen.setAuthType", | 361 "login.AccountPickerScreen.setAuthType", |
| 362 base::StringValue(account_id.GetUserEmail()), | 362 base::StringValue(account_id.GetUserEmail()), |
| 363 base::FundamentalValue(auth_type), base::StringValue(auth_value)); | 363 base::Value(auth_type), base::StringValue(auth_value)); |
| 364 } | 364 } |
| 365 | 365 |
| 366 proximity_auth::ScreenlockBridge::LockHandler::AuthType | 366 proximity_auth::ScreenlockBridge::LockHandler::AuthType |
| 367 UserManagerScreenHandler::GetAuthType(const AccountId& account_id) const { | 367 UserManagerScreenHandler::GetAuthType(const AccountId& account_id) const { |
| 368 const auto it = user_auth_type_map_.find(account_id.GetUserEmail()); | 368 const auto it = user_auth_type_map_.find(account_id.GetUserEmail()); |
| 369 if (it == user_auth_type_map_.end()) | 369 if (it == user_auth_type_map_.end()) |
| 370 return proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD; | 370 return proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD; |
| 371 return it->second; | 371 return it->second; |
| 372 } | 372 } |
| 373 | 373 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 391 NOTREACHED(); | 391 NOTREACHED(); |
| 392 } | 392 } |
| 393 | 393 |
| 394 void UserManagerScreenHandler::HandleInitialize(const base::ListValue* args) { | 394 void UserManagerScreenHandler::HandleInitialize(const base::ListValue* args) { |
| 395 // If the URL has a hash parameter, store it for later. | 395 // If the URL has a hash parameter, store it for later. |
| 396 args->GetString(0, &url_hash_); | 396 args->GetString(0, &url_hash_); |
| 397 | 397 |
| 398 SendUserList(); | 398 SendUserList(); |
| 399 web_ui()->CallJavascriptFunctionUnsafe( | 399 web_ui()->CallJavascriptFunctionUnsafe( |
| 400 "cr.ui.UserManager.showUserManagerScreen", | 400 "cr.ui.UserManager.showUserManagerScreen", |
| 401 base::FundamentalValue(IsGuestModeEnabled()), | 401 base::Value(IsGuestModeEnabled()), |
| 402 base::FundamentalValue(IsAddPersonEnabled())); | 402 base::Value(IsAddPersonEnabled())); |
| 403 | 403 |
| 404 proximity_auth::ScreenlockBridge::Get()->SetLockHandler(this); | 404 proximity_auth::ScreenlockBridge::Get()->SetLockHandler(this); |
| 405 } | 405 } |
| 406 | 406 |
| 407 void UserManagerScreenHandler::HandleAuthenticatedLaunchUser( | 407 void UserManagerScreenHandler::HandleAuthenticatedLaunchUser( |
| 408 const base::ListValue* args) { | 408 const base::ListValue* args) { |
| 409 const base::Value* profile_path_value; | 409 const base::Value* profile_path_value; |
| 410 if (!args->Get(0, &profile_path_value)) | 410 if (!args->Get(0, &profile_path_value)) |
| 411 return; | 411 return; |
| 412 | 412 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 void UserManagerScreenHandler::HandleAreAllProfilesLocked( | 517 void UserManagerScreenHandler::HandleAreAllProfilesLocked( |
| 518 const base::ListValue* args) { | 518 const base::ListValue* args) { |
| 519 std::string webui_callback_id; | 519 std::string webui_callback_id; |
| 520 CHECK_EQ(1U, args->GetSize()); | 520 CHECK_EQ(1U, args->GetSize()); |
| 521 bool success = args->GetString(0, &webui_callback_id); | 521 bool success = args->GetString(0, &webui_callback_id); |
| 522 DCHECK(success); | 522 DCHECK(success); |
| 523 | 523 |
| 524 AllowJavascript(); | 524 AllowJavascript(); |
| 525 ResolveJavascriptCallback( | 525 ResolveJavascriptCallback( |
| 526 base::StringValue(webui_callback_id), | 526 base::StringValue(webui_callback_id), |
| 527 base::FundamentalValue( | 527 base::Value( |
| 528 profiles::AreAllNonChildNonSupervisedProfilesLocked())); | 528 profiles::AreAllNonChildNonSupervisedProfilesLocked())); |
| 529 } | 529 } |
| 530 | 530 |
| 531 void UserManagerScreenHandler::HandleLaunchUser(const base::ListValue* args) { | 531 void UserManagerScreenHandler::HandleLaunchUser(const base::ListValue* args) { |
| 532 const base::Value* profile_path_value = NULL; | 532 const base::Value* profile_path_value = NULL; |
| 533 if (!args->Get(0, &profile_path_value)) | 533 if (!args->Get(0, &profile_path_value)) |
| 534 return; | 534 return; |
| 535 | 535 |
| 536 base::FilePath profile_path; | 536 base::FilePath profile_path; |
| 537 if (!base::GetValueAsFilePath(*profile_path_value, &profile_path)) | 537 if (!base::GetValueAsFilePath(*profile_path_value, &profile_path)) |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 (has_errors ? IDS_LOGIN_POD_USER_REMOVE_WARNING_SYNC_WITH_ERRORS : | 671 (has_errors ? IDS_LOGIN_POD_USER_REMOVE_WARNING_SYNC_WITH_ERRORS : |
| 672 IDS_LOGIN_POD_USER_REMOVE_WARNING_SYNC) : | 672 IDS_LOGIN_POD_USER_REMOVE_WARNING_SYNC) : |
| 673 (has_errors ? IDS_LOGIN_POD_USER_REMOVE_WARNING_NONSYNC_WITH_ERRORS : | 673 (has_errors ? IDS_LOGIN_POD_USER_REMOVE_WARNING_NONSYNC_WITH_ERRORS : |
| 674 IDS_LOGIN_POD_USER_REMOVE_WARNING_NONSYNC); | 674 IDS_LOGIN_POD_USER_REMOVE_WARNING_NONSYNC); |
| 675 | 675 |
| 676 base::StringValue message = base::StringValue( | 676 base::StringValue message = base::StringValue( |
| 677 l10n_util::GetPluralStringFUTF16(message_id, total_count)); | 677 l10n_util::GetPluralStringFUTF16(message_id, total_count)); |
| 678 | 678 |
| 679 web_ui()->CallJavascriptFunctionUnsafe( | 679 web_ui()->CallJavascriptFunctionUnsafe( |
| 680 "updateRemoveWarningDialogSetMessage", base::StringValue(profile_path), | 680 "updateRemoveWarningDialogSetMessage", base::StringValue(profile_path), |
| 681 message, base::FundamentalValue(total_count)); | 681 message, base::Value(total_count)); |
| 682 } | 682 } |
| 683 | 683 |
| 684 void UserManagerScreenHandler::OnGetTokenInfoResponse( | 684 void UserManagerScreenHandler::OnGetTokenInfoResponse( |
| 685 std::unique_ptr<base::DictionaryValue> token_info) { | 685 std::unique_ptr<base::DictionaryValue> token_info) { |
| 686 // Password is unchanged so user just mistyped it. Ask again. | 686 // Password is unchanged so user just mistyped it. Ask again. |
| 687 ReportAuthenticationResult(false, ProfileMetrics::AUTH_FAILED); | 687 ReportAuthenticationResult(false, ProfileMetrics::AUTH_FAILED); |
| 688 } | 688 } |
| 689 | 689 |
| 690 void UserManagerScreenHandler::OnOAuthError() { | 690 void UserManagerScreenHandler::OnOAuthError() { |
| 691 // Password has changed. Go through online signin flow. | 691 // Password has changed. Go through online signin flow. |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 // otherwise. | 944 // otherwise. |
| 945 Profile* profile = | 945 Profile* profile = |
| 946 g_browser_process->profile_manager()->GetProfileByPath(profile_path); | 946 g_browser_process->profile_manager()->GetProfileByPath(profile_path); |
| 947 profile_value->SetBoolean(kKeyIsProfileLoaded, profile != nullptr); | 947 profile_value->SetBoolean(kKeyIsProfileLoaded, profile != nullptr); |
| 948 | 948 |
| 949 users_list.Append(std::move(profile_value)); | 949 users_list.Append(std::move(profile_value)); |
| 950 } | 950 } |
| 951 | 951 |
| 952 web_ui()->CallJavascriptFunctionUnsafe( | 952 web_ui()->CallJavascriptFunctionUnsafe( |
| 953 "login.AccountPickerScreen.loadUsers", users_list, | 953 "login.AccountPickerScreen.loadUsers", users_list, |
| 954 base::FundamentalValue(IsGuestModeEnabled())); | 954 base::Value(IsGuestModeEnabled())); |
| 955 | 955 |
| 956 // This is the latest C++ code we have in the flow to show the UserManager. | 956 // This is the latest C++ code we have in the flow to show the UserManager. |
| 957 // This may be invoked more than once per UserManager lifetime; the | 957 // This may be invoked more than once per UserManager lifetime; the |
| 958 // UserManager will ensure all relevant logging only happens once. | 958 // UserManager will ensure all relevant logging only happens once. |
| 959 UserManager::OnUserManagerShown(); | 959 UserManager::OnUserManagerShown(); |
| 960 } | 960 } |
| 961 | 961 |
| 962 void UserManagerScreenHandler::ReportAuthenticationResult( | 962 void UserManagerScreenHandler::ReportAuthenticationResult( |
| 963 bool success, | 963 bool success, |
| 964 ProfileMetrics::ProfileAuth auth) { | 964 ProfileMetrics::ProfileAuth auth) { |
| 965 ProfileMetrics::LogProfileAuthResult(auth); | 965 ProfileMetrics::LogProfileAuthResult(auth); |
| 966 email_address_.clear(); | 966 email_address_.clear(); |
| 967 | 967 |
| 968 if (success) { | 968 if (success) { |
| 969 profiles::SwitchToProfile( | 969 profiles::SwitchToProfile( |
| 970 authenticating_profile_path_, true, | 970 authenticating_profile_path_, true, |
| 971 base::Bind(&UserManagerScreenHandler::OnSwitchToProfileComplete, | 971 base::Bind(&UserManagerScreenHandler::OnSwitchToProfileComplete, |
| 972 weak_ptr_factory_.GetWeakPtr()), | 972 weak_ptr_factory_.GetWeakPtr()), |
| 973 ProfileMetrics::SWITCH_PROFILE_UNLOCK); | 973 ProfileMetrics::SWITCH_PROFILE_UNLOCK); |
| 974 } else { | 974 } else { |
| 975 web_ui()->CallJavascriptFunctionUnsafe( | 975 web_ui()->CallJavascriptFunctionUnsafe( |
| 976 "cr.ui.UserManager.showSignInError", base::FundamentalValue(0), | 976 "cr.ui.UserManager.showSignInError", base::Value(0), |
| 977 base::StringValue(l10n_util::GetStringUTF8( | 977 base::StringValue(l10n_util::GetStringUTF8( |
| 978 auth == ProfileMetrics::AUTH_FAILED_OFFLINE | 978 auth == ProfileMetrics::AUTH_FAILED_OFFLINE |
| 979 ? IDS_LOGIN_ERROR_AUTHENTICATING_OFFLINE | 979 ? IDS_LOGIN_ERROR_AUTHENTICATING_OFFLINE |
| 980 : IDS_LOGIN_ERROR_AUTHENTICATING)), | 980 : IDS_LOGIN_ERROR_AUTHENTICATING)), |
| 981 base::StringValue(""), base::FundamentalValue(0)); | 981 base::StringValue(""), base::Value(0)); |
| 982 } | 982 } |
| 983 } | 983 } |
| 984 | 984 |
| 985 void UserManagerScreenHandler::OnBrowserWindowReady(Browser* browser) { | 985 void UserManagerScreenHandler::OnBrowserWindowReady(Browser* browser) { |
| 986 DCHECK(browser); | 986 DCHECK(browser); |
| 987 DCHECK(browser->window()); | 987 DCHECK(browser->window()); |
| 988 | 988 |
| 989 // Unlock the profile after browser opens so startup can read the lock bit. | 989 // Unlock the profile after browser opens so startup can read the lock bit. |
| 990 // Any necessary authentication must have been successful to reach this point. | 990 // Any necessary authentication must have been successful to reach this point. |
| 991 if (!browser->profile()->IsGuestSession()) { | 991 if (!browser->profile()->IsGuestSession()) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 Profile* profile, Profile::CreateStatus profile_create_status) { | 1029 Profile* profile, Profile::CreateStatus profile_create_status) { |
| 1030 Browser* browser = chrome::FindAnyBrowser(profile, false); | 1030 Browser* browser = chrome::FindAnyBrowser(profile, false); |
| 1031 if (browser && browser->window()) { | 1031 if (browser && browser->window()) { |
| 1032 OnBrowserWindowReady(browser); | 1032 OnBrowserWindowReady(browser); |
| 1033 } else { | 1033 } else { |
| 1034 registrar_.Add(this, | 1034 registrar_.Add(this, |
| 1035 chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 1035 chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
| 1036 content::NotificationService::AllSources()); | 1036 content::NotificationService::AllSources()); |
| 1037 } | 1037 } |
| 1038 } | 1038 } |
| OLD | NEW |