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

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

Powered by Google App Engine
This is Rietveld 408576698