| OLD | NEW |
| 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 const base::string16& message) { | 296 const base::string16& message) { |
| 297 web_ui()->CallJavascriptFunction( | 297 web_ui()->CallJavascriptFunction( |
| 298 "login.AccountPickerScreen.showBannerMessage", | 298 "login.AccountPickerScreen.showBannerMessage", |
| 299 base::StringValue(message)); | 299 base::StringValue(message)); |
| 300 } | 300 } |
| 301 | 301 |
| 302 void UserManagerScreenHandler::ShowUserPodCustomIcon( | 302 void UserManagerScreenHandler::ShowUserPodCustomIcon( |
| 303 const AccountId& account_id, | 303 const AccountId& account_id, |
| 304 const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& | 304 const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions& |
| 305 icon_options) { | 305 icon_options) { |
| 306 scoped_ptr<base::DictionaryValue> icon = icon_options.ToDictionaryValue(); | 306 std::unique_ptr<base::DictionaryValue> icon = |
| 307 icon_options.ToDictionaryValue(); |
| 307 if (!icon || icon->empty()) | 308 if (!icon || icon->empty()) |
| 308 return; | 309 return; |
| 309 web_ui()->CallJavascriptFunction( | 310 web_ui()->CallJavascriptFunction( |
| 310 "login.AccountPickerScreen.showUserPodCustomIcon", | 311 "login.AccountPickerScreen.showUserPodCustomIcon", |
| 311 base::StringValue(account_id.GetUserEmail()), *icon); | 312 base::StringValue(account_id.GetUserEmail()), *icon); |
| 312 } | 313 } |
| 313 | 314 |
| 314 void UserManagerScreenHandler::HideUserPodCustomIcon( | 315 void UserManagerScreenHandler::HideUserPodCustomIcon( |
| 315 const AccountId& account_id) { | 316 const AccountId& account_id) { |
| 316 web_ui()->CallJavascriptFunction( | 317 web_ui()->CallJavascriptFunction( |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 // ProfileAttributesStorage are returned because the copy in user_pod_row.js | 563 // ProfileAttributesStorage are returned because the copy in user_pod_row.js |
| 563 // may be outdated. However, if some statistics are missing in | 564 // may be outdated. However, if some statistics are missing in |
| 564 // ProfileAttributesStorage (i.e. |item.success| is false), then the actual | 565 // ProfileAttributesStorage (i.e. |item.success| is false), then the actual |
| 565 // statistics are queried instead. | 566 // statistics are queried instead. |
| 566 base::DictionaryValue return_value; | 567 base::DictionaryValue return_value; |
| 567 profiles::ProfileCategoryStats stats = | 568 profiles::ProfileCategoryStats stats = |
| 568 ProfileStatistics::GetProfileStatisticsFromAttributesStorage( | 569 ProfileStatistics::GetProfileStatisticsFromAttributesStorage( |
| 569 profile_path); | 570 profile_path); |
| 570 bool stats_success = true; | 571 bool stats_success = true; |
| 571 for (const auto& item : stats) { | 572 for (const auto& item : stats) { |
| 572 scoped_ptr<base::DictionaryValue> stat(new base::DictionaryValue); | 573 std::unique_ptr<base::DictionaryValue> stat(new base::DictionaryValue); |
| 573 stat->SetIntegerWithoutPathExpansion("count", item.count); | 574 stat->SetIntegerWithoutPathExpansion("count", item.count); |
| 574 stat->SetBooleanWithoutPathExpansion("success", item.success); | 575 stat->SetBooleanWithoutPathExpansion("success", item.success); |
| 575 return_value.SetWithoutPathExpansion(item.category, std::move(stat)); | 576 return_value.SetWithoutPathExpansion(item.category, std::move(stat)); |
| 576 stats_success &= item.success; | 577 stats_success &= item.success; |
| 577 } | 578 } |
| 578 if (stats_success) { | 579 if (stats_success) { |
| 579 web_ui()->CallJavascriptFunction("updateRemoveWarningDialog", | 580 web_ui()->CallJavascriptFunction("updateRemoveWarningDialog", |
| 580 base::StringValue(profile_path.value()), | 581 base::StringValue(profile_path.value()), |
| 581 return_value); | 582 return_value); |
| 582 return; | 583 return; |
| 583 } | 584 } |
| 584 } | 585 } |
| 585 | 586 |
| 586 ProfileStatisticsFactory::GetForProfile(profile)->GatherStatistics( | 587 ProfileStatisticsFactory::GetForProfile(profile)->GatherStatistics( |
| 587 base::Bind( | 588 base::Bind( |
| 588 &UserManagerScreenHandler::RemoveUserDialogLoadStatsCallback, | 589 &UserManagerScreenHandler::RemoveUserDialogLoadStatsCallback, |
| 589 weak_ptr_factory_.GetWeakPtr(), profile_path)); | 590 weak_ptr_factory_.GetWeakPtr(), profile_path)); |
| 590 } | 591 } |
| 591 | 592 |
| 592 void UserManagerScreenHandler::RemoveUserDialogLoadStatsCallback( | 593 void UserManagerScreenHandler::RemoveUserDialogLoadStatsCallback( |
| 593 base::FilePath profile_path, | 594 base::FilePath profile_path, |
| 594 profiles::ProfileCategoryStats result) { | 595 profiles::ProfileCategoryStats result) { |
| 595 // Copy result into return_value. | 596 // Copy result into return_value. |
| 596 base::DictionaryValue return_value; | 597 base::DictionaryValue return_value; |
| 597 for (const auto& item : result) { | 598 for (const auto& item : result) { |
| 598 scoped_ptr<base::DictionaryValue> stat(new base::DictionaryValue); | 599 std::unique_ptr<base::DictionaryValue> stat(new base::DictionaryValue); |
| 599 stat->SetIntegerWithoutPathExpansion("count", item.count); | 600 stat->SetIntegerWithoutPathExpansion("count", item.count); |
| 600 stat->SetBooleanWithoutPathExpansion("success", item.success); | 601 stat->SetBooleanWithoutPathExpansion("success", item.success); |
| 601 return_value.SetWithoutPathExpansion(item.category, std::move(stat)); | 602 return_value.SetWithoutPathExpansion(item.category, std::move(stat)); |
| 602 } | 603 } |
| 603 web_ui()->CallJavascriptFunction("updateRemoveWarningDialog", | 604 web_ui()->CallJavascriptFunction("updateRemoveWarningDialog", |
| 604 base::StringValue(profile_path.value()), | 605 base::StringValue(profile_path.value()), |
| 605 return_value); | 606 return_value); |
| 606 } | 607 } |
| 607 | 608 |
| 608 void UserManagerScreenHandler::HandleGetRemoveWarningDialogMessage( | 609 void UserManagerScreenHandler::HandleGetRemoveWarningDialogMessage( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 633 base::StringValue message = base::StringValue( | 634 base::StringValue message = base::StringValue( |
| 634 l10n_util::GetPluralStringFUTF16(message_id, total_count)); | 635 l10n_util::GetPluralStringFUTF16(message_id, total_count)); |
| 635 | 636 |
| 636 web_ui()->CallJavascriptFunction("updateRemoveWarningDialogSetMessage", | 637 web_ui()->CallJavascriptFunction("updateRemoveWarningDialogSetMessage", |
| 637 base::StringValue(profile_path), | 638 base::StringValue(profile_path), |
| 638 message, | 639 message, |
| 639 base::FundamentalValue(total_count)); | 640 base::FundamentalValue(total_count)); |
| 640 } | 641 } |
| 641 | 642 |
| 642 void UserManagerScreenHandler::OnGetTokenInfoResponse( | 643 void UserManagerScreenHandler::OnGetTokenInfoResponse( |
| 643 scoped_ptr<base::DictionaryValue> token_info) { | 644 std::unique_ptr<base::DictionaryValue> token_info) { |
| 644 // Password is unchanged so user just mistyped it. Ask again. | 645 // Password is unchanged so user just mistyped it. Ask again. |
| 645 ReportAuthenticationResult(false, ProfileMetrics::AUTH_FAILED); | 646 ReportAuthenticationResult(false, ProfileMetrics::AUTH_FAILED); |
| 646 } | 647 } |
| 647 | 648 |
| 648 void UserManagerScreenHandler::OnOAuthError() { | 649 void UserManagerScreenHandler::OnOAuthError() { |
| 649 // Password has changed. Go through online signin flow. | 650 // Password has changed. Go through online signin flow. |
| 650 DCHECK(!email_address_.empty()); | 651 DCHECK(!email_address_.empty()); |
| 651 oauth_client_.reset(); | 652 oauth_client_.reset(); |
| 652 UserManager::ShowReauthDialog(web_ui()->GetWebContents()->GetBrowserContext(), | 653 UserManager::ShowReauthDialog(web_ui()->GetWebContents()->GetBrowserContext(), |
| 653 email_address_); | 654 email_address_); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 profile_value->SetBoolean(kKeyHasLocalCreds, | 866 profile_value->SetBoolean(kKeyHasLocalCreds, |
| 866 !entry->GetLocalAuthCredentials().empty()); | 867 !entry->GetLocalAuthCredentials().empty()); |
| 867 profile_value->SetBoolean(kKeyIsOwner, false); | 868 profile_value->SetBoolean(kKeyIsOwner, false); |
| 868 profile_value->SetBoolean(kKeyCanRemove, can_remove); | 869 profile_value->SetBoolean(kKeyCanRemove, can_remove); |
| 869 profile_value->SetBoolean(kKeyIsDesktop, true); | 870 profile_value->SetBoolean(kKeyIsDesktop, true); |
| 870 profile_value->SetString(kKeyAvatarUrl, GetAvatarImage(entry)); | 871 profile_value->SetString(kKeyAvatarUrl, GetAvatarImage(entry)); |
| 871 | 872 |
| 872 profiles::ProfileCategoryStats stats = | 873 profiles::ProfileCategoryStats stats = |
| 873 ProfileStatistics::GetProfileStatisticsFromAttributesStorage( | 874 ProfileStatistics::GetProfileStatisticsFromAttributesStorage( |
| 874 profile_path); | 875 profile_path); |
| 875 scoped_ptr<base::DictionaryValue> stats_dict(new base::DictionaryValue); | 876 std::unique_ptr<base::DictionaryValue> stats_dict( |
| 877 new base::DictionaryValue); |
| 876 for (const auto& item : stats) { | 878 for (const auto& item : stats) { |
| 877 scoped_ptr<base::DictionaryValue> stat(new base::DictionaryValue); | 879 std::unique_ptr<base::DictionaryValue> stat(new base::DictionaryValue); |
| 878 stat->SetIntegerWithoutPathExpansion("count", item.count); | 880 stat->SetIntegerWithoutPathExpansion("count", item.count); |
| 879 stat->SetBooleanWithoutPathExpansion("success", item.success); | 881 stat->SetBooleanWithoutPathExpansion("success", item.success); |
| 880 stats_dict->SetWithoutPathExpansion(item.category, std::move(stat)); | 882 stats_dict->SetWithoutPathExpansion(item.category, std::move(stat)); |
| 881 } | 883 } |
| 882 profile_value->SetWithoutPathExpansion(kKeyStatistics, | 884 profile_value->SetWithoutPathExpansion(kKeyStatistics, |
| 883 std::move(stats_dict)); | 885 std::move(stats_dict)); |
| 884 | 886 |
| 885 // GetProfileByPath returns a pointer if the profile is fully loaded, NULL | 887 // GetProfileByPath returns a pointer if the profile is fully loaded, NULL |
| 886 // otherwise. | 888 // otherwise. |
| 887 Profile* profile = | 889 Profile* profile = |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 Profile* profile, Profile::CreateStatus profile_create_status) { | 979 Profile* profile, Profile::CreateStatus profile_create_status) { |
| 978 Browser* browser = chrome::FindAnyBrowser(profile, false); | 980 Browser* browser = chrome::FindAnyBrowser(profile, false); |
| 979 if (browser && browser->window()) { | 981 if (browser && browser->window()) { |
| 980 OnBrowserWindowReady(browser); | 982 OnBrowserWindowReady(browser); |
| 981 } else { | 983 } else { |
| 982 registrar_.Add(this, | 984 registrar_.Add(this, |
| 983 chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 985 chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
| 984 content::NotificationService::AllSources()); | 986 content::NotificationService::AllSources()); |
| 985 } | 987 } |
| 986 } | 988 } |
| OLD | NEW |