Chromium Code Reviews| 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..b7247622d759ca85a43d29ed4fede3da7ed7a515 100644 |
| --- a/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc |
| +++ b/chrome/browser/ui/webui/signin/user_manager_screen_handler.cc |
| @@ -22,6 +22,7 @@ |
| #include "chrome/browser/profiles/profile_info_cache_observer.h" |
| #include "chrome/browser/profiles/profile_manager.h" |
| #include "chrome/browser/profiles/profile_metrics.h" |
| +#include "chrome/browser/profiles/profile_statistics.h" |
| #include "chrome/browser/profiles/profile_window.h" |
| #include "chrome/browser/profiles/profiles_state.h" |
| #include "chrome/browser/signin/local_auth.h" |
| @@ -71,6 +72,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,6 +585,31 @@ void UserManagerScreenHandler::HandleRemoveUserWarningLoadStats( |
| if (!profile) |
| return; |
| + if (!chrome::FindBrowserWithProfile(profile, desktop_type_)) { |
| + // If no windows are open for that profile, the statistics in |
| + // ProfileInfoCache are update. The statistics in ProfileInfoCache are |
|
Mike Lerman
2015/11/26 15:06:25
update -> up to date.
lwchkg
2015/12/02 15:33:34
Acknowledged with thanks.
|
| + // returned because the copy in user_pod_row.js may be outdated. |
| + // However, if a statistic failed in ProfileInfoCache, then the actual |
|
Mike Lerman
2015/11/26 15:06:25
I don't know what "statistic failed in ProfileInfo
lwchkg
2015/12/02 15:33:34
It means that one or more statistics are missing i
|
| + // statistics are queried instead. |
| + base::DictionaryValue return_value; |
| + profiles::ProfileCategoryStats stats = |
| + profiles::GetProfileStatisticsFromCache(profile_path); |
| + bool stats_success = true; |
| + for (const auto& item : stats) { |
| + scoped_ptr<base::DictionaryValue> stat(new base::DictionaryValue); |
| + stat->SetIntegerWithoutPathExpansion("count", item.count); |
| + stat->SetBooleanWithoutPathExpansion("success", item.success); |
| + return_value.SetWithoutPathExpansion(item.category, stat.Pass()); |
| + stats_success &= item.success; |
| + } |
| + if (stats_success) { |
| + web_ui()->CallJavascriptFunction("updateRemoveWarningDialog", |
| + base::StringValue(profile_path.value()), |
| + return_value); |
| + return; |
| + } |
| + } |
| + |
| profiles::GetProfileStatistics( |
| profile, |
| base::Bind( |
| @@ -595,16 +622,16 @@ 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 +904,17 @@ void UserManagerScreenHandler::SendUserList() { |
| profile_value->SetString( |
| kKeyAvatarUrl, GetAvatarImageAtIndex(i, info_cache)); |
| + profiles::ProfileCategoryStats stats = |
| + profiles::GetProfileStatisticsFromCache(profile_path); |
| + scoped_ptr<base::DictionaryValue> stats_dict(new base::DictionaryValue); |
| + for (const auto& item : stats) { |
| + scoped_ptr<base::DictionaryValue> stat(new base::DictionaryValue); |
| + stat->SetIntegerWithoutPathExpansion("count", item.count); |
| + stat->SetBooleanWithoutPathExpansion("success", item.success); |
| + stats_dict->SetWithoutPathExpansion(item.category, stat.Pass()); |
| + } |
| + profile_value->SetWithoutPathExpansion(kKeyStatistics, stats_dict.Pass()); |
| + |
| // GetProfileByPath returns a pointer if the profile is fully loaded, NULL |
| // otherwise. |
| Profile* profile = |