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

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: Addressed comments 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 kJsApiUserManagerIsAtLeastOneProfileUnlocked[] =
103 "isAtLeastOneProfileUnlocked";
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::HandleIsAtLeastOneProfileUnlocked(
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(!profiles::AreAllProfilesLocked()));
509 }
510
487 void UserManagerScreenHandler::HandleLaunchUser(const base::ListValue* args) { 511 void UserManagerScreenHandler::HandleLaunchUser(const base::ListValue* args) {
488 const base::Value* profile_path_value = NULL; 512 const base::Value* profile_path_value = NULL;
489 if (!args->Get(0, &profile_path_value)) 513 if (!args->Get(0, &profile_path_value))
490 return; 514 return;
491 515
492 base::FilePath profile_path; 516 base::FilePath profile_path;
493 if (!base::GetValueAsFilePath(*profile_path_value, &profile_path)) 517 if (!base::GetValueAsFilePath(*profile_path_value, &profile_path))
494 return; 518 return;
495 519
496 ProfileAttributesEntry* entry; 520 ProfileAttributesEntry* entry;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 base::Unretained(this))); 706 base::Unretained(this)));
683 web_ui()->RegisterMessageCallback(kJsApiUserManagerLogRemoveUserWarningShown, 707 web_ui()->RegisterMessageCallback(kJsApiUserManagerLogRemoveUserWarningShown,
684 base::Bind(&HandleLogRemoveUserWarningShown)); 708 base::Bind(&HandleLogRemoveUserWarningShown));
685 web_ui()->RegisterMessageCallback(kJsApiUserManagerRemoveUserWarningLoadStats, 709 web_ui()->RegisterMessageCallback(kJsApiUserManagerRemoveUserWarningLoadStats,
686 base::Bind(&UserManagerScreenHandler::HandleRemoveUserWarningLoadStats, 710 base::Bind(&UserManagerScreenHandler::HandleRemoveUserWarningLoadStats,
687 base::Unretained(this))); 711 base::Unretained(this)));
688 web_ui()->RegisterMessageCallback( 712 web_ui()->RegisterMessageCallback(
689 kJsApiUserManagerGetRemoveWarningDialogMessage, 713 kJsApiUserManagerGetRemoveWarningDialogMessage,
690 base::Bind(&UserManagerScreenHandler::HandleGetRemoveWarningDialogMessage, 714 base::Bind(&UserManagerScreenHandler::HandleGetRemoveWarningDialogMessage,
691 base::Unretained(this))); 715 base::Unretained(this)));
716 web_ui()->RegisterMessageCallback(
717 kJsApiUserManagerIsAtLeastOneProfileUnlocked,
718 base::Bind(&UserManagerScreenHandler::HandleIsAtLeastOneProfileUnlocked,
719 base::Unretained(this)));
692 720
693 const content::WebUI::MessageCallback& kDoNothingCallback = 721 const content::WebUI::MessageCallback& kDoNothingCallback =
694 base::Bind(&HandleAndDoNothing); 722 base::Bind(&HandleAndDoNothing);
695 723
696 // Unused callbacks from screen_account_picker.js 724 // Unused callbacks from screen_account_picker.js
697 web_ui()->RegisterMessageCallback("accountPickerReady", kDoNothingCallback); 725 web_ui()->RegisterMessageCallback("accountPickerReady", kDoNothingCallback);
698 web_ui()->RegisterMessageCallback("loginUIStateChanged", kDoNothingCallback); 726 web_ui()->RegisterMessageCallback("loginUIStateChanged", kDoNothingCallback);
699 web_ui()->RegisterMessageCallback("hideCaptivePortal", kDoNothingCallback); 727 web_ui()->RegisterMessageCallback("hideCaptivePortal", kDoNothingCallback);
700 web_ui()->RegisterMessageCallback("getTouchViewState", kDoNothingCallback); 728 web_ui()->RegisterMessageCallback("getTouchViewState", kDoNothingCallback);
701 // Unused callbacks from display_manager.js 729 // 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()); 847 localized_strings->SetString("signinBannerText", base::string16());
820 localized_strings->SetString("launchAppButton", base::string16()); 848 localized_strings->SetString("launchAppButton", base::string16());
821 localized_strings->SetString("multiProfilesRestrictedPolicyTitle", 849 localized_strings->SetString("multiProfilesRestrictedPolicyTitle",
822 base::string16()); 850 base::string16());
823 localized_strings->SetString("multiProfilesNotAllowedPolicyMsg", 851 localized_strings->SetString("multiProfilesNotAllowedPolicyMsg",
824 base::string16()); 852 base::string16());
825 localized_strings->SetString("multiProfilesPrimaryOnlyPolicyMsg", 853 localized_strings->SetString("multiProfilesPrimaryOnlyPolicyMsg",
826 base::string16()); 854 base::string16());
827 localized_strings->SetString("multiProfilesOwnerPrimaryOnlyMsg", 855 localized_strings->SetString("multiProfilesOwnerPrimaryOnlyMsg",
828 base::string16()); 856 base::string16());
857
858 // Error message when trying to add a profile while all profiles are locked.
859 localized_strings->SetString("AddProfileAllProfilesLockedError",
860 l10n_util::GetStringUTF16(
861 IDS_USER_MANAGER_ADD_PROFILE_PROFILES_LOCKED_ERROR));
862 // Error message when trying to browse as guest while all profiles are locked.
863 localized_strings->SetString("BrowseAsGuestAllProfilesLockedError",
864 l10n_util::GetStringUTF16(
865 IDS_USER_MANAGER_GO_GUEST_PROFILES_LOCKED_ERROR));
829 } 866 }
830 867
831 void UserManagerScreenHandler::SendUserList() { 868 void UserManagerScreenHandler::SendUserList() {
832 base::ListValue users_list; 869 base::ListValue users_list;
833 std::vector<ProfileAttributesEntry*> entries = 870 std::vector<ProfileAttributesEntry*> entries =
834 g_browser_process->profile_manager()->GetProfileAttributesStorage(). 871 g_browser_process->profile_manager()->GetProfileAttributesStorage().
835 GetAllProfilesAttributesSortedByName(); 872 GetAllProfilesAttributesSortedByName();
836 user_auth_type_map_.clear(); 873 user_auth_type_map_.clear();
837 874
838 // Profile deletion is not allowed in Metro mode. 875 // 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) { 1014 Profile* profile, Profile::CreateStatus profile_create_status) {
978 Browser* browser = chrome::FindAnyBrowser(profile, false); 1015 Browser* browser = chrome::FindAnyBrowser(profile, false);
979 if (browser && browser->window()) { 1016 if (browser && browser->window()) {
980 OnBrowserWindowReady(browser); 1017 OnBrowserWindowReady(browser);
981 } else { 1018 } else {
982 registrar_.Add(this, 1019 registrar_.Add(this,
983 chrome::NOTIFICATION_BROWSER_WINDOW_READY, 1020 chrome::NOTIFICATION_BROWSER_WINDOW_READY,
984 content::NotificationService::AllSources()); 1021 content::NotificationService::AllSources());
985 } 1022 }
986 } 1023 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698