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

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

Issue 1248613003: Issue 501916 : Add data type counts to profile deletion flow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Third draft - removed all password manager code Created 5 years, 4 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
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/profiler/scoped_tracker.h" 10 #include "base/profiler/scoped_tracker.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // JS API callback names. 74 // JS API callback names.
75 const char kJsApiUserManagerInitialize[] = "userManagerInitialize"; 75 const char kJsApiUserManagerInitialize[] = "userManagerInitialize";
76 const char kJsApiUserManagerAddUser[] = "addUser"; 76 const char kJsApiUserManagerAddUser[] = "addUser";
77 const char kJsApiUserManagerAuthLaunchUser[] = "authenticatedLaunchUser"; 77 const char kJsApiUserManagerAuthLaunchUser[] = "authenticatedLaunchUser";
78 const char kJsApiUserManagerLaunchGuest[] = "launchGuest"; 78 const char kJsApiUserManagerLaunchGuest[] = "launchGuest";
79 const char kJsApiUserManagerLaunchUser[] = "launchUser"; 79 const char kJsApiUserManagerLaunchUser[] = "launchUser";
80 const char kJsApiUserManagerRemoveUser[] = "removeUser"; 80 const char kJsApiUserManagerRemoveUser[] = "removeUser";
81 const char kJsApiUserManagerAttemptUnlock[] = "attemptUnlock"; 81 const char kJsApiUserManagerAttemptUnlock[] = "attemptUnlock";
82 const char kJsApiUserManagerLogRemoveUserWarningShown[] = 82 const char kJsApiUserManagerLogRemoveUserWarningShown[] =
83 "logRemoveUserWarningShown"; 83 "logRemoveUserWarningShown";
84 84 const char kJsApiUserManagerRemoveUserWarningLoadStats[] =
85 "removeUserWarningLoadStats";
85 const size_t kAvatarIconSize = 180; 86 const size_t kAvatarIconSize = 180;
86 const int kMaxOAuthRetries = 3; 87 const int kMaxOAuthRetries = 3;
87 88
88 void HandleAndDoNothing(const base::ListValue* args) { 89 void HandleAndDoNothing(const base::ListValue* args) {
89 } 90 }
90 91
91 // This callback is run if the only profile has been deleted, and a new 92 // This callback is run if the only profile has been deleted, and a new
92 // profile has been created to replace it. 93 // profile has been created to replace it.
93 void OpenNewWindowForProfile( 94 void OpenNewWindowForProfile(
94 chrome::HostDesktopType desktop_type, 95 chrome::HostDesktopType desktop_type,
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 const base::ListValue* args) { 565 const base::ListValue* args) {
565 std::string email; 566 std::string email;
566 CHECK(args->GetString(0, &email)); 567 CHECK(args->GetString(0, &email));
567 SetAuthType( 568 SetAuthType(
568 email, 569 email,
569 proximity_auth::ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD, 570 proximity_auth::ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD,
570 base::string16()); 571 base::string16());
571 HideUserPodCustomIcon(email); 572 HideUserPodCustomIcon(email);
572 } 573 }
573 574
575 void UserManagerScreenHandler::HandleRemoveUserWarningLoadStats(
576 const base::ListValue* args) {
577 const base::Value* profile_path_value;
578 if (!args->Get(0, &profile_path_value))
579 return;
580
581 base::FilePath* profile_path = new base::FilePath();
582 if (!base::GetValueAsFilePath(*profile_path_value, profile_path)) {
583 delete profile_path;
584 return;
585 }
586
587 Profile* profile = g_browser_process->profile_manager()->
588 GetProfileByPath(*profile_path);
589
590 if (!profile) {
591 delete profile_path;
592 return;
593 }
594
595 profiles::GetProfileStatistics(profile,
596 base::Bind(&UserManagerScreenHandler::RemoveUserDialogLoadStatsCallback,
597 weak_ptr_factory_.GetWeakPtr(), base::Owned(profile_path)),
598 &tracker);
599 }
600
601 void UserManagerScreenHandler::RemoveUserDialogLoadStatsCallback(
602 const base::FilePath* profile_path,
603 profiles::ProfileStatisticsValues result) {
604 // Copy result into return_value.
605 base::StringValue return_profile_path(profile_path->value());
606 base::DictionaryValue return_value;
607 for (profiles::ProfileStatisticsValues::const_iterator
608 iter = result.begin(); iter != result.end(); iter++) {
609 return_value.SetIntegerWithoutPathExpansion(iter->first, iter->second);
610 }
611 web_ui()->CallJavascriptFunction("updateRemoveWarningDialog",
612 return_profile_path, return_value);
613 }
614
574 void UserManagerScreenHandler::OnGetTokenInfoResponse( 615 void UserManagerScreenHandler::OnGetTokenInfoResponse(
575 scoped_ptr<base::DictionaryValue> token_info) { 616 scoped_ptr<base::DictionaryValue> token_info) {
576 // Password is unchanged so user just mistyped it. Ask again. 617 // Password is unchanged so user just mistyped it. Ask again.
577 ReportAuthenticationResult(false, ProfileMetrics::AUTH_FAILED); 618 ReportAuthenticationResult(false, ProfileMetrics::AUTH_FAILED);
578 } 619 }
579 620
580 void UserManagerScreenHandler::OnOAuthError() { 621 void UserManagerScreenHandler::OnOAuthError() {
581 // Password has changed. Go through online signin flow. 622 // Password has changed. Go through online signin flow.
582 // ... if we had it. Until then, use deprecated ClientLogin to validate 623 // ... if we had it. Until then, use deprecated ClientLogin to validate
583 // the password. This will have to be changed soon. (TODO: bcwhite) 624 // the password. This will have to be changed soon. (TODO: bcwhite)
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 base::Bind(&UserManagerScreenHandler::HandleLaunchUser, 699 base::Bind(&UserManagerScreenHandler::HandleLaunchUser,
659 base::Unretained(this))); 700 base::Unretained(this)));
660 web_ui()->RegisterMessageCallback(kJsApiUserManagerRemoveUser, 701 web_ui()->RegisterMessageCallback(kJsApiUserManagerRemoveUser,
661 base::Bind(&UserManagerScreenHandler::HandleRemoveUser, 702 base::Bind(&UserManagerScreenHandler::HandleRemoveUser,
662 base::Unretained(this))); 703 base::Unretained(this)));
663 web_ui()->RegisterMessageCallback(kJsApiUserManagerAttemptUnlock, 704 web_ui()->RegisterMessageCallback(kJsApiUserManagerAttemptUnlock,
664 base::Bind(&UserManagerScreenHandler::HandleAttemptUnlock, 705 base::Bind(&UserManagerScreenHandler::HandleAttemptUnlock,
665 base::Unretained(this))); 706 base::Unretained(this)));
666 web_ui()->RegisterMessageCallback(kJsApiUserManagerLogRemoveUserWarningShown, 707 web_ui()->RegisterMessageCallback(kJsApiUserManagerLogRemoveUserWarningShown,
667 base::Bind(&HandleLogRemoveUserWarningShown)); 708 base::Bind(&HandleLogRemoveUserWarningShown));
709 web_ui()->RegisterMessageCallback(kJsApiUserManagerRemoveUserWarningLoadStats,
710 base::Bind(&UserManagerScreenHandler::HandleRemoveUserWarningLoadStats,
711 base::Unretained(this)));
668 712
669 const content::WebUI::MessageCallback& kDoNothingCallback = 713 const content::WebUI::MessageCallback& kDoNothingCallback =
670 base::Bind(&HandleAndDoNothing); 714 base::Bind(&HandleAndDoNothing);
671 715
672 // Unused callbacks from screen_account_picker.js 716 // Unused callbacks from screen_account_picker.js
673 web_ui()->RegisterMessageCallback("accountPickerReady", kDoNothingCallback); 717 web_ui()->RegisterMessageCallback("accountPickerReady", kDoNothingCallback);
674 web_ui()->RegisterMessageCallback("loginUIStateChanged", kDoNothingCallback); 718 web_ui()->RegisterMessageCallback("loginUIStateChanged", kDoNothingCallback);
675 web_ui()->RegisterMessageCallback("hideCaptivePortal", kDoNothingCallback); 719 web_ui()->RegisterMessageCallback("hideCaptivePortal", kDoNothingCallback);
676 web_ui()->RegisterMessageCallback("getTouchViewState", kDoNothingCallback); 720 web_ui()->RegisterMessageCallback("getTouchViewState", kDoNothingCallback);
677 // Unused callbacks from display_manager.js 721 // Unused callbacks from display_manager.js
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_BUTTON)); 760 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_BUTTON));
717 localized_strings->SetString("passwordFieldAccessibleName", 761 localized_strings->SetString("passwordFieldAccessibleName",
718 l10n_util::GetStringUTF16(IDS_LOGIN_POD_PASSWORD_FIELD_ACCESSIBLE_NAME)); 762 l10n_util::GetStringUTF16(IDS_LOGIN_POD_PASSWORD_FIELD_ACCESSIBLE_NAME));
719 localized_strings->SetString("bootIntoWallpaper", "off"); 763 localized_strings->SetString("bootIntoWallpaper", "off");
720 764
721 // For AccountPickerScreen, the remove user warning overlay. 765 // For AccountPickerScreen, the remove user warning overlay.
722 localized_strings->SetString("removeUserWarningButtonTitle", 766 localized_strings->SetString("removeUserWarningButtonTitle",
723 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_BUTTON)); 767 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_BUTTON));
724 localized_strings->SetString("removeUserWarningText", 768 localized_strings->SetString("removeUserWarningText",
725 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING)); 769 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING));
770 localized_strings->SetString("removeUserWarningTextNonSync",
771 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_NONSYNC));
772 localized_strings->SetString("removeUserWarningTextHistory",
773 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_HISTORY));
774 localized_strings->SetString("removeUserWarningTextPasswords",
775 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_PASSWORDS));
776 localized_strings->SetString("removeUserWarningTextBookmarks",
777 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_BOOKMARKS));
778 localized_strings->SetString("removeUserWarningTextSettings",
779 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_SETTINGS));
780 localized_strings->SetString("removeUserWarningTextComputing",
781 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_COMPUTING));
782 localized_strings->SetString("removeUserWarningTextSync",
783 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_SYNC));
784 localized_strings->SetString("removeUserWarningTextSync2",
785 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_SYNC2));
726 localized_strings->SetString("removeLegacySupervisedUserWarningText", 786 localized_strings->SetString("removeLegacySupervisedUserWarningText",
727 l10n_util::GetStringFUTF16( 787 l10n_util::GetStringFUTF16(
728 IDS_LOGIN_POD_LEGACY_SUPERVISED_USER_REMOVE_WARNING, 788 IDS_LOGIN_POD_LEGACY_SUPERVISED_USER_REMOVE_WARNING,
729 base::UTF8ToUTF16(chrome::kSupervisedUserManagementDisplayURL))); 789 base::UTF8ToUTF16(chrome::kSupervisedUserManagementDisplayURL)));
730 790
731 // Strings needed for the User Manager tutorial slides. 791 // Strings needed for the User Manager tutorial slides.
732 localized_strings->SetString("tutorialNext", 792 localized_strings->SetString("tutorialNext",
733 l10n_util::GetStringUTF16(IDS_USER_MANAGER_TUTORIAL_NEXT)); 793 l10n_util::GetStringUTF16(IDS_USER_MANAGER_TUTORIAL_NEXT));
734 localized_strings->SetString("tutorialDone", 794 localized_strings->SetString("tutorialDone",
735 l10n_util::GetStringUTF16(IDS_USER_MANAGER_TUTORIAL_DONE)); 795 l10n_util::GetStringUTF16(IDS_USER_MANAGER_TUTORIAL_DONE));
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 Profile* profile, Profile::CreateStatus profile_create_status) { 976 Profile* profile, Profile::CreateStatus profile_create_status) {
917 Browser* browser = chrome::FindAnyBrowser(profile, false, desktop_type_); 977 Browser* browser = chrome::FindAnyBrowser(profile, false, desktop_type_);
918 if (browser && browser->window()) { 978 if (browser && browser->window()) {
919 OnBrowserWindowReady(browser); 979 OnBrowserWindowReady(browser);
920 } else { 980 } else {
921 registrar_.Add(this, 981 registrar_.Add(this,
922 chrome::NOTIFICATION_BROWSER_WINDOW_READY, 982 chrome::NOTIFICATION_BROWSER_WINDOW_READY,
923 content::NotificationService::AllSources()); 983 content::NotificationService::AllSources());
924 } 984 }
925 } 985 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698