Index: chrome/browser/ui/webui/signin/user_manager_screen_handler.cc |
diff --git a/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc b/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc |
index 21aa3ede166300d5f68cdb60920c5508faf74525..602d65c031f94ba3a3f4ad1baf0bc4fdfff6ec30 100644 |
--- a/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc |
+++ b/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc |
@@ -71,6 +71,7 @@ const char kKeyIsDesktop[] = "isDesktopUser"; |
const char kKeyAvatarUrl[] = "userImage"; |
const char kKeyNeedsSignin[] = "needsSignin"; |
const char kKeyHasLocalCreds[] = "hasLocalCreds"; |
+const char kKeyIsProfileLoaded[] = "isProfileLoaded"; |
// JS API callback names. |
const char kJsApiUserManagerInitialize[] = "userManagerInitialize"; |
@@ -82,7 +83,8 @@ const char kJsApiUserManagerRemoveUser[] = "removeUser"; |
const char kJsApiUserManagerAttemptUnlock[] = "attemptUnlock"; |
const char kJsApiUserManagerLogRemoveUserWarningShown[] = |
"logRemoveUserWarningShown"; |
- |
+const char kJsApiUserManagerRemoveUserWarningLoadStats[] = |
+ "removeUserWarningLoadStats"; |
const size_t kAvatarIconSize = 180; |
const int kMaxOAuthRetries = 3; |
@@ -555,6 +557,50 @@ void UserManagerScreenHandler::HandleHardlockUserPod( |
HideUserPodCustomIcon(email); |
} |
+void UserManagerScreenHandler::HandleRemoveUserWarningLoadStats( |
+ const base::ListValue* args) { |
+ const base::Value* profile_path_value; |
+ |
+ if (!args->Get(0, &profile_path_value)) |
+ return; |
+ |
+ base::FilePath profile_path; |
+ |
+ if (!base::GetValueAsFilePath(*profile_path_value, &profile_path)) |
+ return; |
+ |
+ base::StringValue return_profile_path(profile_path.value()); |
+ Profile* profile = g_browser_process->profile_manager()-> |
+ GetProfileByPath(profile_path); |
+ |
+ if (!profile) |
+ return; |
+ |
+ profiles::GetProfileStatistics( |
+ profile, |
+ base::Bind( |
+ &UserManagerScreenHandler::RemoveUserDialogLoadStatsCallback, |
+ weak_ptr_factory_.GetWeakPtr(), profile_path), |
+ &tracker_); |
+} |
+ |
+void UserManagerScreenHandler::RemoveUserDialogLoadStatsCallback( |
+ base::FilePath profile_path, |
+ profiles::ProfileStatisticsReturn result) { |
+ // Copy result into return_value. |
+ base::StringValue return_profile_path(profile_path.value()); |
+ base::DictionaryValue return_value; |
+ for (const auto& item : result) { |
+ if (item.success) { |
+ return_value.SetIntegerWithoutPathExpansion(item.category, item.count); |
+ } else { |
+ return_value.SetBooleanWithoutPathExpansion(item.category, false); |
Mike Lerman
2015/08/17 14:23:38
This is a little ugly, to be placing a value that
lwchkg
2015/08/19 06:19:45
Two options here:
1. Leave boolean "false" here.
2
Mike Lerman
2015/08/20 14:52:11
Try the json thing; I expect it will yield very re
lwchkg
2015/08/20 16:06:24
Good. Anyway, we are already passing a json alread
lwchkg
2015/08/22 15:35:29
Updated on patch #13 already. I've forgot to annou
Mike Lerman
2015/08/24 14:45:40
This looks really good!
|
+ } |
+ } |
+ web_ui()->CallJavascriptFunction("updateRemoveWarningDialog", |
+ return_profile_path, return_value); |
+} |
+ |
void UserManagerScreenHandler::OnGetTokenInfoResponse( |
scoped_ptr<base::DictionaryValue> token_info) { |
// Password is unchanged so user just mistyped it. Ask again. |
@@ -599,6 +645,9 @@ void UserManagerScreenHandler::RegisterMessages() { |
base::Unretained(this))); |
web_ui()->RegisterMessageCallback(kJsApiUserManagerLogRemoveUserWarningShown, |
base::Bind(&HandleLogRemoveUserWarningShown)); |
+ web_ui()->RegisterMessageCallback(kJsApiUserManagerRemoveUserWarningLoadStats, |
+ base::Bind(&UserManagerScreenHandler::HandleRemoveUserWarningLoadStats, |
+ base::Unretained(this))); |
const content::WebUI::MessageCallback& kDoNothingCallback = |
base::Bind(&HandleAndDoNothing); |
@@ -655,8 +704,26 @@ void UserManagerScreenHandler::GetLocalizedValues( |
// For AccountPickerScreen, the remove user warning overlay. |
localized_strings->SetString("removeUserWarningButtonTitle", |
l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_BUTTON)); |
- localized_strings->SetString("removeUserWarningText", |
- l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING)); |
+ localized_strings->SetString("removeUserWarningTextNonSync", |
+ l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_NONSYNC)); |
+ localized_strings->SetString("removeUserWarningTextNonSyncNoStats", |
+ l10n_util::GetStringUTF16( |
+ IDS_LOGIN_POD_USER_REMOVE_WARNING_NONSYNC_NOSTATS)); |
+ localized_strings->SetString("removeUserWarningTextHistory", |
+ l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_HISTORY)); |
+ localized_strings->SetString("removeUserWarningTextPasswords", |
+ l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_PASSWORDS)); |
+ localized_strings->SetString("removeUserWarningTextBookmarks", |
+ l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_BOOKMARKS)); |
+ localized_strings->SetString("removeUserWarningTextSettings", |
+ l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_SETTINGS)); |
+ localized_strings->SetString("removeUserWarningTextCalculating", |
+ l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_CALCULATING)); |
+ localized_strings->SetString("removeUserWarningTextSync", |
+ l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_SYNC)); |
+ localized_strings->SetString("removeUserWarningTextSyncNoStats", |
+ l10n_util::GetStringUTF16( |
+ IDS_LOGIN_POD_USER_REMOVE_WARNING_SYNC_NOSTATS)); |
localized_strings->SetString("removeLegacySupervisedUserWarningText", |
l10n_util::GetStringFUTF16( |
IDS_LOGIN_POD_LEGACY_SUPERVISED_USER_REMOVE_WARNING, |
@@ -758,6 +825,12 @@ void UserManagerScreenHandler::SendUserList() { |
profile_value->SetString( |
kKeyAvatarUrl, GetAvatarImageAtIndex(i, info_cache)); |
+ // GetProfileByPath returns a pointer if the profile is fully loaded, NULL |
+ // otherwise. |
+ Profile* profile = |
+ g_browser_process->profile_manager()->GetProfileByPath(profile_path); |
+ profile_value->SetBoolean(kKeyIsProfileLoaded, profile != nullptr); |
+ |
users_list.Append(profile_value); |
} |