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

Side by Side Diff: chrome/browser/ui/webui/signin/user_manager_screen_handler.cc

Issue 2025433002: MD User Manager: Display error message when all profiles are locked. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments + Avoid breaking the tests 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 unified diff | Download patch
OLDNEW
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 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 const char kJsApiUserManagerLaunchGuest[] = "launchGuest"; 92 const char kJsApiUserManagerLaunchGuest[] = "launchGuest";
93 const char kJsApiUserManagerLaunchUser[] = "launchUser"; 93 const char kJsApiUserManagerLaunchUser[] = "launchUser";
94 const char kJsApiUserManagerRemoveUser[] = "removeUser"; 94 const char kJsApiUserManagerRemoveUser[] = "removeUser";
95 const char kJsApiUserManagerAttemptUnlock[] = "attemptUnlock"; 95 const char kJsApiUserManagerAttemptUnlock[] = "attemptUnlock";
96 const char kJsApiUserManagerLogRemoveUserWarningShown[] = 96 const char kJsApiUserManagerLogRemoveUserWarningShown[] =
97 "logRemoveUserWarningShown"; 97 "logRemoveUserWarningShown";
98 const char kJsApiUserManagerRemoveUserWarningLoadStats[] = 98 const char kJsApiUserManagerRemoveUserWarningLoadStats[] =
99 "removeUserWarningLoadStats"; 99 "removeUserWarningLoadStats";
100 const char kJsApiUserManagerGetRemoveWarningDialogMessage[] = 100 const char kJsApiUserManagerGetRemoveWarningDialogMessage[] =
101 "getRemoveWarningDialogMessage"; 101 "getRemoveWarningDialogMessage";
102 const char kJsApiUserManagerAreAllProfilesLocked[] =
103 "areAllProfilesLocked";
102 const size_t kAvatarIconSize = 180; 104 const size_t kAvatarIconSize = 180;
103 const int kMaxOAuthRetries = 3; 105 const int kMaxOAuthRetries = 3;
104 106
105 void HandleAndDoNothing(const base::ListValue* args) { 107 void HandleAndDoNothing(const base::ListValue* args) {
106 } 108 }
107 109
108 std::string GetAvatarImage(const ProfileAttributesEntry* entry) { 110 std::string GetAvatarImage(const ProfileAttributesEntry* entry) {
109 bool is_gaia_picture = entry->IsUsingGAIAPicture() && 111 bool is_gaia_picture = entry->IsUsingGAIAPicture() &&
110 entry->GetGAIAPicture() != nullptr; 112 entry->GetGAIAPicture() != nullptr;
111 113
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 } 460 }
459 461
460 base::FilePath profile_path; 462 base::FilePath profile_path;
461 if (!base::GetValueAsFilePath(*profile_path_value, &profile_path)) { 463 if (!base::GetValueAsFilePath(*profile_path_value, &profile_path)) {
462 NOTREACHED(); 464 NOTREACHED();
463 return; 465 return;
464 } 466 }
465 467
466 DCHECK(profiles::IsMultipleProfilesEnabled()); 468 DCHECK(profiles::IsMultipleProfilesEnabled());
467 469
470 if (profiles::AreAllProfilesLocked()) {
471 web_ui()->CallJavascriptFunction(
472 "cr.webUIListenerCallback",
473 base::StringValue("show-error-dialog"),
474 base::StringValue(l10n_util::GetStringUTF8(
475 IDS_USER_MANAGER_REMOVE_PROFILE_PROFILES_LOCKED_ERROR)));
476 return;
477 }
478
468 // The callback is run if the only profile has been deleted, and a new 479 // The callback is run if the only profile has been deleted, and a new
469 // profile has been created to replace it. 480 // profile has been created to replace it.
470 webui::DeleteProfileAtPath(profile_path, 481 webui::DeleteProfileAtPath(profile_path,
471 web_ui(), 482 web_ui(),
472 ProfileMetrics::DELETE_PROFILE_USER_MANAGER); 483 ProfileMetrics::DELETE_PROFILE_USER_MANAGER);
473 } 484 }
474 485
475 void UserManagerScreenHandler::HandleLaunchGuest(const base::ListValue* args) { 486 void UserManagerScreenHandler::HandleLaunchGuest(const base::ListValue* args) {
476 if (IsGuestModeEnabled()) { 487 if (IsGuestModeEnabled()) {
477 profiles::SwitchToGuestProfile( 488 profiles::SwitchToGuestProfile(
478 base::Bind(&UserManagerScreenHandler::OnSwitchToProfileComplete, 489 base::Bind(&UserManagerScreenHandler::OnSwitchToProfileComplete,
479 weak_ptr_factory_.GetWeakPtr())); 490 weak_ptr_factory_.GetWeakPtr()));
480 } else { 491 } else {
481 // The UI should have prevented the user from allowing the selection of 492 // The UI should have prevented the user from allowing the selection of
482 // guest mode. 493 // guest mode.
483 NOTREACHED(); 494 NOTREACHED();
484 } 495 }
485 } 496 }
486 497
498 void UserManagerScreenHandler::HandleAreAllProfilesLocked(
499 const base::ListValue* args) {
500 std::string webui_callback_id;
501 CHECK_EQ(1U, args->GetSize());
502 bool success = args->GetString(0, &webui_callback_id);
503 DCHECK(success);
504
505 web_ui()->CallJavascriptFunction(
506 "cr.webUIResponse",
507 base::StringValue(webui_callback_id),
508 base::FundamentalValue(true),
509 base::FundamentalValue(profiles::AreAllProfilesLocked()));
510 }
511
487 void UserManagerScreenHandler::HandleLaunchUser(const base::ListValue* args) { 512 void UserManagerScreenHandler::HandleLaunchUser(const base::ListValue* args) {
488 const base::Value* profile_path_value = NULL; 513 const base::Value* profile_path_value = NULL;
489 if (!args->Get(0, &profile_path_value)) 514 if (!args->Get(0, &profile_path_value))
490 return; 515 return;
491 516
492 base::FilePath profile_path; 517 base::FilePath profile_path;
493 if (!base::GetValueAsFilePath(*profile_path_value, &profile_path)) 518 if (!base::GetValueAsFilePath(*profile_path_value, &profile_path))
494 return; 519 return;
495 520
496 ProfileAttributesEntry* entry; 521 ProfileAttributesEntry* entry;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 base::Unretained(this))); 707 base::Unretained(this)));
683 web_ui()->RegisterMessageCallback(kJsApiUserManagerLogRemoveUserWarningShown, 708 web_ui()->RegisterMessageCallback(kJsApiUserManagerLogRemoveUserWarningShown,
684 base::Bind(&HandleLogRemoveUserWarningShown)); 709 base::Bind(&HandleLogRemoveUserWarningShown));
685 web_ui()->RegisterMessageCallback(kJsApiUserManagerRemoveUserWarningLoadStats, 710 web_ui()->RegisterMessageCallback(kJsApiUserManagerRemoveUserWarningLoadStats,
686 base::Bind(&UserManagerScreenHandler::HandleRemoveUserWarningLoadStats, 711 base::Bind(&UserManagerScreenHandler::HandleRemoveUserWarningLoadStats,
687 base::Unretained(this))); 712 base::Unretained(this)));
688 web_ui()->RegisterMessageCallback( 713 web_ui()->RegisterMessageCallback(
689 kJsApiUserManagerGetRemoveWarningDialogMessage, 714 kJsApiUserManagerGetRemoveWarningDialogMessage,
690 base::Bind(&UserManagerScreenHandler::HandleGetRemoveWarningDialogMessage, 715 base::Bind(&UserManagerScreenHandler::HandleGetRemoveWarningDialogMessage,
691 base::Unretained(this))); 716 base::Unretained(this)));
717 web_ui()->RegisterMessageCallback(
718 kJsApiUserManagerAreAllProfilesLocked,
719 base::Bind(&UserManagerScreenHandler::HandleAreAllProfilesLocked,
720 base::Unretained(this)));
692 721
693 const content::WebUI::MessageCallback& kDoNothingCallback = 722 const content::WebUI::MessageCallback& kDoNothingCallback =
694 base::Bind(&HandleAndDoNothing); 723 base::Bind(&HandleAndDoNothing);
695 724
696 // Unused callbacks from screen_account_picker.js 725 // Unused callbacks from screen_account_picker.js
697 web_ui()->RegisterMessageCallback("accountPickerReady", kDoNothingCallback); 726 web_ui()->RegisterMessageCallback("accountPickerReady", kDoNothingCallback);
698 web_ui()->RegisterMessageCallback("loginUIStateChanged", kDoNothingCallback); 727 web_ui()->RegisterMessageCallback("loginUIStateChanged", kDoNothingCallback);
699 web_ui()->RegisterMessageCallback("hideCaptivePortal", kDoNothingCallback); 728 web_ui()->RegisterMessageCallback("hideCaptivePortal", kDoNothingCallback);
700 web_ui()->RegisterMessageCallback("getTouchViewState", kDoNothingCallback); 729 web_ui()->RegisterMessageCallback("getTouchViewState", kDoNothingCallback);
701 // Unused callbacks from display_manager.js 730 // Unused callbacks from display_manager.js
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 localized_strings->SetString("signinBannerText", base::string16()); 848 localized_strings->SetString("signinBannerText", base::string16());
820 localized_strings->SetString("launchAppButton", base::string16()); 849 localized_strings->SetString("launchAppButton", base::string16());
821 localized_strings->SetString("multiProfilesRestrictedPolicyTitle", 850 localized_strings->SetString("multiProfilesRestrictedPolicyTitle",
822 base::string16()); 851 base::string16());
823 localized_strings->SetString("multiProfilesNotAllowedPolicyMsg", 852 localized_strings->SetString("multiProfilesNotAllowedPolicyMsg",
824 base::string16()); 853 base::string16());
825 localized_strings->SetString("multiProfilesPrimaryOnlyPolicyMsg", 854 localized_strings->SetString("multiProfilesPrimaryOnlyPolicyMsg",
826 base::string16()); 855 base::string16());
827 localized_strings->SetString("multiProfilesOwnerPrimaryOnlyMsg", 856 localized_strings->SetString("multiProfilesOwnerPrimaryOnlyMsg",
828 base::string16()); 857 base::string16());
858
859 // Error message when trying to add a profile while all profiles are locked.
860 localized_strings->SetString("AddProfileAllProfilesLockedError",
dpapad 2016/05/31 23:14:46 Nit: All other string IDs is this file start with
Moe 2016/06/01 12:48:42 Done.
861 l10n_util::GetStringUTF16(
862 IDS_USER_MANAGER_ADD_PROFILE_PROFILES_LOCKED_ERROR));
863 // Error message when trying to browse as guest while all profiles are locked.
864 localized_strings->SetString("BrowseAsGuestAllProfilesLockedError",
865 l10n_util::GetStringUTF16(
866 IDS_USER_MANAGER_GO_GUEST_PROFILES_LOCKED_ERROR));
829 } 867 }
830 868
831 void UserManagerScreenHandler::SendUserList() { 869 void UserManagerScreenHandler::SendUserList() {
832 base::ListValue users_list; 870 base::ListValue users_list;
833 std::vector<ProfileAttributesEntry*> entries = 871 std::vector<ProfileAttributesEntry*> entries =
834 g_browser_process->profile_manager()->GetProfileAttributesStorage(). 872 g_browser_process->profile_manager()->GetProfileAttributesStorage().
835 GetAllProfilesAttributesSortedByName(); 873 GetAllProfilesAttributesSortedByName();
836 user_auth_type_map_.clear(); 874 user_auth_type_map_.clear();
837 875
838 // Profile deletion is not allowed in Metro mode. 876 // Profile deletion is not allowed in Metro mode.
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 Profile* profile, Profile::CreateStatus profile_create_status) { 1015 Profile* profile, Profile::CreateStatus profile_create_status) {
978 Browser* browser = chrome::FindAnyBrowser(profile, false); 1016 Browser* browser = chrome::FindAnyBrowser(profile, false);
979 if (browser && browser->window()) { 1017 if (browser && browser->window()) {
980 OnBrowserWindowReady(browser); 1018 OnBrowserWindowReady(browser);
981 } else { 1019 } else {
982 registrar_.Add(this, 1020 registrar_.Add(this,
983 chrome::NOTIFICATION_BROWSER_WINDOW_READY, 1021 chrome::NOTIFICATION_BROWSER_WINDOW_READY,
984 content::NotificationService::AllSources()); 1022 content::NotificationService::AllSources());
985 } 1023 }
986 } 1024 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698