| 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 3fc1e82f4e9ae1b60b5cd7acb28bee5ce0b96a10..c28c19873e48a5f1288cefdac7579c3f01163a02 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 kKeyStatistics[] = "statistics";
|
| const char kKeyIsProfileLoaded[] = "isProfileLoaded";
|
|
|
| // JS API callback names.
|
| @@ -583,28 +584,51 @@ void UserManagerScreenHandler::HandleRemoveUserWarningLoadStats(
|
| if (!profile)
|
| return;
|
|
|
| - profiles::GetProfileStatistics(
|
| - profile,
|
| - base::Bind(
|
| - &UserManagerScreenHandler::RemoveUserDialogLoadStatsCallback,
|
| - weak_ptr_factory_.GetWeakPtr(), profile_path),
|
| - &tracker_);
|
| + if (chrome::FindBrowserWithProfile(profile, desktop_type_)) {
|
| + profiles::GetProfileStatistics(
|
| + profile,
|
| + base::Bind(
|
| + &UserManagerScreenHandler::RemoveUserDialogLoadStatsCallback,
|
| + weak_ptr_factory_.GetWeakPtr(), profile_path),
|
| + &tracker_);
|
| + } else {
|
| + // If no windows are open for that profile, the statistics in
|
| + // ProfileInfoCache are update. The statistics in ProfileInfoCache are
|
| + // returned because the copy in user_pod_row.js may be outdated.
|
| + ProfileInfoCache& profile_info_cache =
|
| + g_browser_process->profile_manager()->GetProfileInfoCache();
|
| + ProfileAttributesEntry* entry = nullptr;
|
| + const base::FilePath profile_path = profile->GetPath();
|
| + if (profile_info_cache.GetProfileAttributesWithPath(profile_path, &entry)) {
|
| + std::map<std::string, int> stats = entry->GetAllStatistics();
|
| + base::DictionaryValue return_value;
|
| + for (const auto& item : stats) {
|
| + scoped_ptr<base::DictionaryValue> stat(new base::DictionaryValue);
|
| + stat->SetIntegerWithoutPathExpansion("count", item.second);
|
| + stat->SetBooleanWithoutPathExpansion("success", true);
|
| + return_value.SetWithoutPathExpansion(item.first, stat.Pass());
|
| + }
|
| + web_ui()->CallJavascriptFunction("updateRemoveWarningDialog",
|
| + base::StringValue(profile_path.value()),
|
| + return_value);
|
| + }
|
| + }
|
| }
|
|
|
| void UserManagerScreenHandler::RemoveUserDialogLoadStatsCallback(
|
| base::FilePath profile_path,
|
| profiles::ProfileCategoryStats result) {
|
| // Copy result into return_value.
|
| - base::StringValue return_profile_path(profile_path.value());
|
| base::DictionaryValue return_value;
|
| for (const auto& item : result) {
|
| - base::DictionaryValue* stat = new base::DictionaryValue();
|
| + scoped_ptr<base::DictionaryValue> stat(new base::DictionaryValue);
|
| stat->SetIntegerWithoutPathExpansion("count", item.count);
|
| stat->SetBooleanWithoutPathExpansion("success", item.success);
|
| - return_value.SetWithoutPathExpansion(item.category, stat);
|
| + return_value.SetWithoutPathExpansion(item.category, stat.Pass());
|
| }
|
| web_ui()->CallJavascriptFunction("updateRemoveWarningDialog",
|
| - return_profile_path, return_value);
|
| + base::StringValue(profile_path.value()),
|
| + return_value);
|
| }
|
|
|
| void UserManagerScreenHandler::HandleGetRemoveWarningDialogMessage(
|
| @@ -877,6 +901,13 @@ void UserManagerScreenHandler::SendUserList() {
|
| profile_value->SetString(
|
| kKeyAvatarUrl, GetAvatarImageAtIndex(i, info_cache));
|
|
|
| + std::map<std::string, int> stats =
|
| + info_cache->GetAllStatisticsOfProfileAtIndex(i);
|
| + scoped_ptr<base::DictionaryValue> stats_dict(new base::DictionaryValue);
|
| + for (const auto& stat : stats)
|
| + stats_dict->SetIntegerWithoutPathExpansion(stat.first, stat.second);
|
| + profile_value->SetWithoutPathExpansion(kKeyStatistics, stats_dict.Pass());
|
| +
|
| // GetProfileByPath returns a pointer if the profile is fully loaded, NULL
|
| // otherwise.
|
| Profile* profile =
|
|
|