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

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

Issue 2960613002: Remove total item count in remove profile warning (Closed)
Patch Set: Less scary warning for sync users Created 3 years, 5 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
« no previous file with comments | « chrome/app/google_chrome_strings.grd ('k') | ui/login/account_picker/md_user_pod_row.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 const char kKeyProfilePath[] = "profilePath"; 82 const char kKeyProfilePath[] = "profilePath";
83 const char kKeyPublicAccount[] = "publicAccount"; 83 const char kKeyPublicAccount[] = "publicAccount";
84 const char kKeyLegacySupervisedUser[] = "legacySupervisedUser"; 84 const char kKeyLegacySupervisedUser[] = "legacySupervisedUser";
85 const char kKeyChildUser[] = "childUser"; 85 const char kKeyChildUser[] = "childUser";
86 const char kKeyCanRemove[] = "canRemove"; 86 const char kKeyCanRemove[] = "canRemove";
87 const char kKeyIsOwner[] = "isOwner"; 87 const char kKeyIsOwner[] = "isOwner";
88 const char kKeyIsDesktop[] = "isDesktopUser"; 88 const char kKeyIsDesktop[] = "isDesktopUser";
89 const char kKeyAvatarUrl[] = "userImage"; 89 const char kKeyAvatarUrl[] = "userImage";
90 const char kKeyNeedsSignin[] = "needsSignin"; 90 const char kKeyNeedsSignin[] = "needsSignin";
91 const char kKeyHasLocalCreds[] = "hasLocalCreds"; 91 const char kKeyHasLocalCreds[] = "hasLocalCreds";
92 const char kKeyStatistics[] = "statistics";
93 const char kKeyIsProfileLoaded[] = "isProfileLoaded"; 92 const char kKeyIsProfileLoaded[] = "isProfileLoaded";
94 93
95 // JS API callback names. 94 // JS API callback names.
96 const char kJsApiUserManagerInitialize[] = "userManagerInitialize"; 95 const char kJsApiUserManagerInitialize[] = "userManagerInitialize";
97 const char kJsApiUserManagerAuthLaunchUser[] = "authenticatedLaunchUser"; 96 const char kJsApiUserManagerAuthLaunchUser[] = "authenticatedLaunchUser";
98 const char kJsApiUserManagerLaunchGuest[] = "launchGuest"; 97 const char kJsApiUserManagerLaunchGuest[] = "launchGuest";
99 const char kJsApiUserManagerLaunchUser[] = "launchUser"; 98 const char kJsApiUserManagerLaunchUser[] = "launchUser";
100 const char kJsApiUserManagerRemoveUser[] = "removeUser"; 99 const char kJsApiUserManagerRemoveUser[] = "removeUser";
101 const char kJsApiUserManagerAttemptUnlock[] = "attemptUnlock"; 100 const char kJsApiUserManagerAttemptUnlock[] = "attemptUnlock";
102 const char kJsApiUserManagerLogRemoveUserWarningShown[] = 101 const char kJsApiUserManagerLogRemoveUserWarningShown[] =
103 "logRemoveUserWarningShown"; 102 "logRemoveUserWarningShown";
104 const char kJsApiUserManagerRemoveUserWarningLoadStats[] = 103 const char kJsApiUserManagerRemoveUserWarningLoadStats[] =
105 "removeUserWarningLoadStats"; 104 "removeUserWarningLoadStats";
106 const char kJsApiUserManagerGetRemoveWarningDialogMessage[] =
107 "getRemoveWarningDialogMessage";
108 const char kJsApiUserManagerAreAllProfilesLocked[] = 105 const char kJsApiUserManagerAreAllProfilesLocked[] =
109 "areAllProfilesLocked"; 106 "areAllProfilesLocked";
110 const size_t kAvatarIconSize = 180; 107 const size_t kAvatarIconSize = 180;
111 const int kMaxOAuthRetries = 3; 108 const int kMaxOAuthRetries = 3;
112 109
113 void HandleAndDoNothing(const base::ListValue* args) { 110 void HandleAndDoNothing(const base::ListValue* args) {
114 } 111 }
115 112
116 std::string GetAvatarImage(const ProfileAttributesEntry* entry) { 113 std::string GetAvatarImage(const ProfileAttributesEntry* entry) {
117 bool is_gaia_picture = entry->IsUsingGAIAPicture() && 114 bool is_gaia_picture = entry->IsUsingGAIAPicture() &&
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 624
628 void UserManagerScreenHandler::RemoveUserDialogLoadStatsCallback( 625 void UserManagerScreenHandler::RemoveUserDialogLoadStatsCallback(
629 base::FilePath profile_path, 626 base::FilePath profile_path,
630 base::Time start_time, 627 base::Time start_time,
631 profiles::ProfileCategoryStats result) { 628 profiles::ProfileCategoryStats result) {
632 // Copy result into return_value. 629 // Copy result into return_value.
633 base::DictionaryValue return_value; 630 base::DictionaryValue return_value;
634 for (const auto& item : result) { 631 for (const auto& item : result) {
635 auto stat = base::MakeUnique<base::DictionaryValue>(); 632 auto stat = base::MakeUnique<base::DictionaryValue>();
636 stat->SetIntegerWithoutPathExpansion("count", item.count); 633 stat->SetIntegerWithoutPathExpansion("count", item.count);
637 stat->SetBooleanWithoutPathExpansion("success", true);
638 return_value.SetWithoutPathExpansion(item.category, std::move(stat)); 634 return_value.SetWithoutPathExpansion(item.category, std::move(stat));
639 } 635 }
640 if (result.size() == profiles::kProfileStatisticsCategories.size()) { 636 if (result.size() == profiles::kProfileStatisticsCategories.size()) {
641 // All categories are finished. 637 // All categories are finished.
642 UMA_HISTOGRAM_TIMES("Profile.RemoveUserWarningStatsTime", 638 UMA_HISTOGRAM_TIMES("Profile.RemoveUserWarningStatsTime",
643 base::Time::Now() - start_time); 639 base::Time::Now() - start_time);
644 } 640 }
645 web_ui()->CallJavascriptFunctionUnsafe("updateRemoveWarningDialog", 641 web_ui()->CallJavascriptFunctionUnsafe("updateRemoveWarningDialog",
646 base::Value(profile_path.value()), 642 base::Value(profile_path.value()),
647 return_value); 643 return_value);
648 } 644 }
649 645
650 void UserManagerScreenHandler::HandleGetRemoveWarningDialogMessage(
651 const base::ListValue* args) {
652 const base::DictionaryValue* arg;
653 if (!args->GetDictionary(0, &arg))
654 return;
655
656 std::string profile_path("");
657 bool is_synced_user = false;
658 bool has_errors = false;
659
660 if (!arg->GetString("profilePath", &profile_path) ||
661 !arg->GetBoolean("isSyncedUser", &is_synced_user) ||
662 !arg->GetBoolean("hasErrors", &has_errors))
663 return;
664
665 int total_count = 0;
666 if (!arg->GetInteger("totalCount", &total_count))
667 return;
668
669 int message_id = is_synced_user ?
670 (has_errors ? IDS_LOGIN_POD_USER_REMOVE_WARNING_SYNC_WITH_ERRORS :
671 IDS_LOGIN_POD_USER_REMOVE_WARNING_SYNC) :
672 (has_errors ? IDS_LOGIN_POD_USER_REMOVE_WARNING_NONSYNC_WITH_ERRORS :
673 IDS_LOGIN_POD_USER_REMOVE_WARNING_NONSYNC);
674
675 base::Value message =
676 base::Value(l10n_util::GetPluralStringFUTF16(message_id, total_count));
677
678 web_ui()->CallJavascriptFunctionUnsafe("updateRemoveWarningDialogSetMessage",
679 base::Value(profile_path), message,
680 base::Value(total_count));
681 }
682
683 void UserManagerScreenHandler::OnGetTokenInfoResponse( 646 void UserManagerScreenHandler::OnGetTokenInfoResponse(
684 std::unique_ptr<base::DictionaryValue> token_info) { 647 std::unique_ptr<base::DictionaryValue> token_info) {
685 // Password is unchanged so user just mistyped it. Ask again. 648 // Password is unchanged so user just mistyped it. Ask again.
686 ReportAuthenticationResult(false, ProfileMetrics::AUTH_FAILED); 649 ReportAuthenticationResult(false, ProfileMetrics::AUTH_FAILED);
687 } 650 }
688 651
689 void UserManagerScreenHandler::OnOAuthError() { 652 void UserManagerScreenHandler::OnOAuthError() {
690 // Password has changed. Go through online signin flow. 653 // Password has changed. Go through online signin flow.
691 DCHECK(!email_address_.empty()); 654 DCHECK(!email_address_.empty());
692 oauth_client_.reset(); 655 oauth_client_.reset();
(...skipping 26 matching lines...) Expand all
719 base::Unretained(this))); 682 base::Unretained(this)));
720 web_ui()->RegisterMessageCallback(kJsApiUserManagerAttemptUnlock, 683 web_ui()->RegisterMessageCallback(kJsApiUserManagerAttemptUnlock,
721 base::Bind(&UserManagerScreenHandler::HandleAttemptUnlock, 684 base::Bind(&UserManagerScreenHandler::HandleAttemptUnlock,
722 base::Unretained(this))); 685 base::Unretained(this)));
723 web_ui()->RegisterMessageCallback(kJsApiUserManagerLogRemoveUserWarningShown, 686 web_ui()->RegisterMessageCallback(kJsApiUserManagerLogRemoveUserWarningShown,
724 base::Bind(&HandleLogRemoveUserWarningShown)); 687 base::Bind(&HandleLogRemoveUserWarningShown));
725 web_ui()->RegisterMessageCallback(kJsApiUserManagerRemoveUserWarningLoadStats, 688 web_ui()->RegisterMessageCallback(kJsApiUserManagerRemoveUserWarningLoadStats,
726 base::Bind(&UserManagerScreenHandler::HandleRemoveUserWarningLoadStats, 689 base::Bind(&UserManagerScreenHandler::HandleRemoveUserWarningLoadStats,
727 base::Unretained(this))); 690 base::Unretained(this)));
728 web_ui()->RegisterMessageCallback( 691 web_ui()->RegisterMessageCallback(
729 kJsApiUserManagerGetRemoveWarningDialogMessage,
730 base::Bind(&UserManagerScreenHandler::HandleGetRemoveWarningDialogMessage,
731 base::Unretained(this)));
732 web_ui()->RegisterMessageCallback(
733 kJsApiUserManagerAreAllProfilesLocked, 692 kJsApiUserManagerAreAllProfilesLocked,
734 base::Bind(&UserManagerScreenHandler::HandleAreAllProfilesLocked, 693 base::Bind(&UserManagerScreenHandler::HandleAreAllProfilesLocked,
735 base::Unretained(this))); 694 base::Unretained(this)));
736 695
737 const content::WebUI::MessageCallback& kDoNothingCallback = 696 const content::WebUI::MessageCallback& kDoNothingCallback =
738 base::Bind(&HandleAndDoNothing); 697 base::Bind(&HandleAndDoNothing);
739 698
740 // Unused callbacks from screen_account_picker.js 699 // Unused callbacks from screen_account_picker.js
741 web_ui()->RegisterMessageCallback("accountPickerReady", kDoNothingCallback); 700 web_ui()->RegisterMessageCallback("accountPickerReady", kDoNothingCallback);
742 web_ui()->RegisterMessageCallback("loginUIStateChanged", kDoNothingCallback); 701 web_ui()->RegisterMessageCallback("loginUIStateChanged", kDoNothingCallback);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 IDS_LOGIN_POD_MENU_REMOVE_ITEM_ACCESSIBLE_NAME)); 742 IDS_LOGIN_POD_MENU_REMOVE_ITEM_ACCESSIBLE_NAME));
784 localized_strings->SetString("removeUser", 743 localized_strings->SetString("removeUser",
785 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_BUTTON)); 744 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_BUTTON));
786 localized_strings->SetString("passwordFieldAccessibleName", 745 localized_strings->SetString("passwordFieldAccessibleName",
787 l10n_util::GetStringUTF16(IDS_LOGIN_POD_PASSWORD_FIELD_ACCESSIBLE_NAME)); 746 l10n_util::GetStringUTF16(IDS_LOGIN_POD_PASSWORD_FIELD_ACCESSIBLE_NAME));
788 localized_strings->SetString("bootIntoWallpaper", "off"); 747 localized_strings->SetString("bootIntoWallpaper", "off");
789 748
790 // For AccountPickerScreen, the remove user warning overlay. 749 // For AccountPickerScreen, the remove user warning overlay.
791 localized_strings->SetString("removeUserWarningButtonTitle", 750 localized_strings->SetString("removeUserWarningButtonTitle",
792 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_BUTTON)); 751 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_BUTTON));
793 localized_strings->SetString("removeUserWarningTextNonSyncNoStats", 752 localized_strings->SetString(
794 l10n_util::GetStringUTF16( 753 "removeUserWarningTextNonSync",
795 IDS_LOGIN_POD_USER_REMOVE_WARNING_NONSYNC_NOSTATS)); 754 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_NONSYNC));
796 localized_strings->SetString("removeUserWarningTextNonSyncCalculating",
797 l10n_util::GetStringUTF16(
798 IDS_LOGIN_POD_USER_REMOVE_WARNING_NONSYNC_CALCULATING));
799 localized_strings->SetString("removeUserWarningTextHistory", 755 localized_strings->SetString("removeUserWarningTextHistory",
800 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_HISTORY)); 756 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_HISTORY));
801 localized_strings->SetString("removeUserWarningTextPasswords", 757 localized_strings->SetString("removeUserWarningTextPasswords",
802 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_PASSWORDS)); 758 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_PASSWORDS));
803 localized_strings->SetString("removeUserWarningTextBookmarks", 759 localized_strings->SetString("removeUserWarningTextBookmarks",
804 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_BOOKMARKS)); 760 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_BOOKMARKS));
805 localized_strings->SetString( 761 localized_strings->SetString(
806 "removeUserWarningTextAutofill", 762 "removeUserWarningTextAutofill",
807 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_AUTOFILL)); 763 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_AUTOFILL));
808 localized_strings->SetString("removeUserWarningTextCalculating", 764 localized_strings->SetString("removeUserWarningTextCalculating",
809 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_CALCULATING)); 765 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_CALCULATING));
810 localized_strings->SetString("removeUserWarningTextSyncNoStats", 766 localized_strings->SetString(
811 l10n_util::GetStringUTF16( 767 "removeUserWarningTextSync",
812 IDS_LOGIN_POD_USER_REMOVE_WARNING_SYNC_NOSTATS)); 768 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_SYNC));
813 localized_strings->SetString("removeUserWarningTextSyncCalculating",
814 l10n_util::GetStringUTF16(
815 IDS_LOGIN_POD_USER_REMOVE_WARNING_SYNC_CALCULATING));
816 localized_strings->SetString("removeLegacySupervisedUserWarningText", 769 localized_strings->SetString("removeLegacySupervisedUserWarningText",
817 l10n_util::GetStringFUTF16( 770 l10n_util::GetStringFUTF16(
818 IDS_LOGIN_POD_LEGACY_SUPERVISED_USER_REMOVE_WARNING, 771 IDS_LOGIN_POD_LEGACY_SUPERVISED_USER_REMOVE_WARNING,
819 base::UTF8ToUTF16( 772 base::UTF8ToUTF16(
820 chrome::kLegacySupervisedUserManagementDisplayURL))); 773 chrome::kLegacySupervisedUserManagementDisplayURL)));
821 localized_strings->SetString( 774 localized_strings->SetString(
822 "removeNonOwnerUserWarningText", 775 "removeNonOwnerUserWarningText",
823 l10n_util::GetStringUTF16(IDS_LOGIN_POD_NON_OWNER_USER_REMOVE_WARNING)); 776 l10n_util::GetStringUTF16(IDS_LOGIN_POD_NON_OWNER_USER_REMOVE_WARNING));
824 777
825 // Strings needed for the User Manager tutorial slides. 778 // Strings needed for the User Manager tutorial slides.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 entry->IsLegacySupervised()); 884 entry->IsLegacySupervised());
932 profile_value->SetBoolean(kKeyChildUser, entry->IsChild()); 885 profile_value->SetBoolean(kKeyChildUser, entry->IsChild());
933 profile_value->SetBoolean(kKeyNeedsSignin, entry->IsSigninRequired()); 886 profile_value->SetBoolean(kKeyNeedsSignin, entry->IsSigninRequired());
934 profile_value->SetBoolean(kKeyHasLocalCreds, 887 profile_value->SetBoolean(kKeyHasLocalCreds,
935 !entry->GetLocalAuthCredentials().empty()); 888 !entry->GetLocalAuthCredentials().empty());
936 profile_value->SetBoolean(kKeyIsOwner, false); 889 profile_value->SetBoolean(kKeyIsOwner, false);
937 profile_value->SetBoolean(kKeyCanRemove, can_remove); 890 profile_value->SetBoolean(kKeyCanRemove, can_remove);
938 profile_value->SetBoolean(kKeyIsDesktop, true); 891 profile_value->SetBoolean(kKeyIsDesktop, true);
939 profile_value->SetString(kKeyAvatarUrl, GetAvatarImage(entry)); 892 profile_value->SetString(kKeyAvatarUrl, GetAvatarImage(entry));
940 893
941 // Add statistics dictionary (the actual statistics will be populated
942 // once they are retrieved from the profile).
943 auto stats_dict = base::MakeUnique<base::DictionaryValue>();
944 for (const char* category : profiles::kProfileStatisticsCategories) {
945 auto stat = base::MakeUnique<base::DictionaryValue>();
946 stat->SetIntegerWithoutPathExpansion("count", 0);
947 stat->SetBooleanWithoutPathExpansion("success", false);
948 stats_dict->SetWithoutPathExpansion(category, std::move(stat));
949 }
950 profile_value->SetWithoutPathExpansion(kKeyStatistics,
951 std::move(stats_dict));
952 // GetProfileByPath returns a pointer if the profile is fully loaded, NULL 894 // GetProfileByPath returns a pointer if the profile is fully loaded, NULL
953 // otherwise. 895 // otherwise.
954 Profile* profile = 896 Profile* profile =
955 g_browser_process->profile_manager()->GetProfileByPath(profile_path); 897 g_browser_process->profile_manager()->GetProfileByPath(profile_path);
956 profile_value->SetBoolean(kKeyIsProfileLoaded, profile != nullptr); 898 profile_value->SetBoolean(kKeyIsProfileLoaded, profile != nullptr);
957 899
958 users_list.Append(std::move(profile_value)); 900 users_list.Append(std::move(profile_value));
959 } 901 }
960 902
961 web_ui()->CallJavascriptFunctionUnsafe("login.AccountPickerScreen.loadUsers", 903 web_ui()->CallJavascriptFunctionUnsafe("login.AccountPickerScreen.loadUsers",
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 Profile* profile, Profile::CreateStatus profile_create_status) { 984 Profile* profile, Profile::CreateStatus profile_create_status) {
1043 Browser* browser = chrome::FindAnyBrowser(profile, false); 985 Browser* browser = chrome::FindAnyBrowser(profile, false);
1044 if (browser && browser->window()) { 986 if (browser && browser->window()) {
1045 OnBrowserWindowReady(browser); 987 OnBrowserWindowReady(browser);
1046 } else { 988 } else {
1047 registrar_.Add(this, 989 registrar_.Add(this,
1048 chrome::NOTIFICATION_BROWSER_WINDOW_READY, 990 chrome::NOTIFICATION_BROWSER_WINDOW_READY,
1049 content::NotificationService::AllSources()); 991 content::NotificationService::AllSources());
1050 } 992 }
1051 } 993 }
OLDNEW
« no previous file with comments | « chrome/app/google_chrome_strings.grd ('k') | ui/login/account_picker/md_user_pod_row.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698