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

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: updated chromeos empty "localized" strings in signin_screen_handler.cc 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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 const base::ListValue* args) { 542 const base::ListValue* args) {
542 std::string email; 543 std::string email;
543 CHECK(args->GetString(0, &email)); 544 CHECK(args->GetString(0, &email));
544 SetAuthType( 545 SetAuthType(
545 email, 546 email,
546 proximity_auth::ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD, 547 proximity_auth::ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD,
547 base::string16()); 548 base::string16());
548 HideUserPodCustomIcon(email); 549 HideUserPodCustomIcon(email);
549 } 550 }
550 551
552 void UserManagerScreenHandler::HandleRemoveUserWarningLoadStats(
553 const base::ListValue* args) {
554 const base::Value* profile_path_value;
555
556 if (args->Get(0, &profile_path_value)) {
557 base::FilePath* profile_path = new base::FilePath();
Mike Lerman 2015/08/05 19:26:09 Please create this on the stack rather the using n
lwchkg 2015/08/06 04:32:59 Acknowledged. I was worrying too much about copy a
558
559 if (base::GetValueAsFilePath(*profile_path_value, profile_path)) {
560 base::StringValue return_profile_path(profile_path->value());
561 Profile* profile = g_browser_process->profile_manager()->
562 GetProfileByPath(*profile_path);
563
564 if (profile) {
565 profiles::GetProfileStatistics(
566 profile,
567 base::Bind(
568 &UserManagerScreenHandler::RemoveUserDialogLoadStatsCallback,
569 weak_ptr_factory_.GetWeakPtr(), base::Owned(profile_path)),
570 &tracker);
571 web_ui()->CallJavascriptFunction("updateRemoveWarningDialogHasNoStats",
572 return_profile_path, base::FundamentalValue(false));
573 return;
574 }
575 web_ui()->CallJavascriptFunction("updateRemoveWarningDialogHasNoStats",
576 return_profile_path, base::FundamentalValue(true));
577 }
578 delete profile_path;
579 }
580 }
581
582 void UserManagerScreenHandler::RemoveUserDialogLoadStatsCallback(
583 const base::FilePath* profile_path,
584 profiles::ProfileStatisticsValues result) {
585 // Copy result into return_value.
586 base::StringValue return_profile_path(profile_path->value());
587 base::DictionaryValue return_value;
588 for (profiles::ProfileStatisticsValues::const_iterator
589 iter = result.begin(); iter != result.end(); iter++) {
590 return_value.SetIntegerWithoutPathExpansion(iter->first, iter->second);
591 }
592 web_ui()->CallJavascriptFunction("updateRemoveWarningDialog",
593 return_profile_path, return_value);
594 }
595
551 void UserManagerScreenHandler::OnGetTokenInfoResponse( 596 void UserManagerScreenHandler::OnGetTokenInfoResponse(
552 scoped_ptr<base::DictionaryValue> token_info) { 597 scoped_ptr<base::DictionaryValue> token_info) {
553 // Password is unchanged so user just mistyped it. Ask again. 598 // Password is unchanged so user just mistyped it. Ask again.
554 ReportAuthenticationResult(false, ProfileMetrics::AUTH_FAILED); 599 ReportAuthenticationResult(false, ProfileMetrics::AUTH_FAILED);
555 } 600 }
556 601
557 void UserManagerScreenHandler::OnOAuthError() { 602 void UserManagerScreenHandler::OnOAuthError() {
558 // Password has changed. Go through online signin flow. 603 // Password has changed. Go through online signin flow.
559 DCHECK(!email_address_.empty()); 604 DCHECK(!email_address_.empty());
560 oauth_client_.reset(); 605 oauth_client_.reset();
(...skipping 24 matching lines...) Expand all
585 base::Bind(&UserManagerScreenHandler::HandleLaunchUser, 630 base::Bind(&UserManagerScreenHandler::HandleLaunchUser,
586 base::Unretained(this))); 631 base::Unretained(this)));
587 web_ui()->RegisterMessageCallback(kJsApiUserManagerRemoveUser, 632 web_ui()->RegisterMessageCallback(kJsApiUserManagerRemoveUser,
588 base::Bind(&UserManagerScreenHandler::HandleRemoveUser, 633 base::Bind(&UserManagerScreenHandler::HandleRemoveUser,
589 base::Unretained(this))); 634 base::Unretained(this)));
590 web_ui()->RegisterMessageCallback(kJsApiUserManagerAttemptUnlock, 635 web_ui()->RegisterMessageCallback(kJsApiUserManagerAttemptUnlock,
591 base::Bind(&UserManagerScreenHandler::HandleAttemptUnlock, 636 base::Bind(&UserManagerScreenHandler::HandleAttemptUnlock,
592 base::Unretained(this))); 637 base::Unretained(this)));
593 web_ui()->RegisterMessageCallback(kJsApiUserManagerLogRemoveUserWarningShown, 638 web_ui()->RegisterMessageCallback(kJsApiUserManagerLogRemoveUserWarningShown,
594 base::Bind(&HandleLogRemoveUserWarningShown)); 639 base::Bind(&HandleLogRemoveUserWarningShown));
640 web_ui()->RegisterMessageCallback(kJsApiUserManagerRemoveUserWarningLoadStats,
641 base::Bind(&UserManagerScreenHandler::HandleRemoveUserWarningLoadStats,
642 base::Unretained(this)));
595 643
596 const content::WebUI::MessageCallback& kDoNothingCallback = 644 const content::WebUI::MessageCallback& kDoNothingCallback =
597 base::Bind(&HandleAndDoNothing); 645 base::Bind(&HandleAndDoNothing);
598 646
599 // Unused callbacks from screen_account_picker.js 647 // Unused callbacks from screen_account_picker.js
600 web_ui()->RegisterMessageCallback("accountPickerReady", kDoNothingCallback); 648 web_ui()->RegisterMessageCallback("accountPickerReady", kDoNothingCallback);
601 web_ui()->RegisterMessageCallback("loginUIStateChanged", kDoNothingCallback); 649 web_ui()->RegisterMessageCallback("loginUIStateChanged", kDoNothingCallback);
602 web_ui()->RegisterMessageCallback("hideCaptivePortal", kDoNothingCallback); 650 web_ui()->RegisterMessageCallback("hideCaptivePortal", kDoNothingCallback);
603 web_ui()->RegisterMessageCallback("getTouchViewState", kDoNothingCallback); 651 web_ui()->RegisterMessageCallback("getTouchViewState", kDoNothingCallback);
604 // Unused callbacks from display_manager.js 652 // Unused callbacks from display_manager.js
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 IDS_LOGIN_POD_MENU_REMOVE_ITEM_ACCESSIBLE_NAME)); 689 IDS_LOGIN_POD_MENU_REMOVE_ITEM_ACCESSIBLE_NAME));
642 localized_strings->SetString("removeUser", 690 localized_strings->SetString("removeUser",
643 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_BUTTON)); 691 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_BUTTON));
644 localized_strings->SetString("passwordFieldAccessibleName", 692 localized_strings->SetString("passwordFieldAccessibleName",
645 l10n_util::GetStringUTF16(IDS_LOGIN_POD_PASSWORD_FIELD_ACCESSIBLE_NAME)); 693 l10n_util::GetStringUTF16(IDS_LOGIN_POD_PASSWORD_FIELD_ACCESSIBLE_NAME));
646 localized_strings->SetString("bootIntoWallpaper", "off"); 694 localized_strings->SetString("bootIntoWallpaper", "off");
647 695
648 // For AccountPickerScreen, the remove user warning overlay. 696 // For AccountPickerScreen, the remove user warning overlay.
649 localized_strings->SetString("removeUserWarningButtonTitle", 697 localized_strings->SetString("removeUserWarningButtonTitle",
650 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_BUTTON)); 698 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_BUTTON));
651 localized_strings->SetString("removeUserWarningText", 699 localized_strings->SetString("removeUserWarningTextNonSync",
652 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING)); 700 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_NONSYNC));
701 localized_strings->SetString("removeUserWarningTextNonSyncNoStats",
702 l10n_util::GetStringUTF16(
703 IDS_LOGIN_POD_USER_REMOVE_WARNING_NONSYNC_NOSTATS));
704 localized_strings->SetString("removeUserWarningTextHistory",
705 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_HISTORY));
706 localized_strings->SetString("removeUserWarningTextPasswords",
707 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_PASSWORDS));
708 localized_strings->SetString("removeUserWarningTextBookmarks",
709 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_BOOKMARKS));
710 localized_strings->SetString("removeUserWarningTextSettings",
711 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_SETTINGS));
712 localized_strings->SetString("removeUserWarningTextCalculating",
713 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_CALCULATING));
714 localized_strings->SetString("removeUserWarningTextSync",
715 l10n_util::GetStringUTF16(IDS_LOGIN_POD_USER_REMOVE_WARNING_SYNC));
716 localized_strings->SetString("removeUserWarningTextSyncNoStats",
717 l10n_util::GetStringUTF16(
718 IDS_LOGIN_POD_USER_REMOVE_WARNING_SYNC_NOSTATS));
719 localized_strings->SetString("removeUserWarningManageLinkSync",
720 l10n_util::GetStringUTF16(
721 IDS_LOGIN_POD_USER_REMOVE_WARNING_MANAGE_LINK_SYNC));
653 localized_strings->SetString("removeLegacySupervisedUserWarningText", 722 localized_strings->SetString("removeLegacySupervisedUserWarningText",
654 l10n_util::GetStringFUTF16( 723 l10n_util::GetStringFUTF16(
655 IDS_LOGIN_POD_LEGACY_SUPERVISED_USER_REMOVE_WARNING, 724 IDS_LOGIN_POD_LEGACY_SUPERVISED_USER_REMOVE_WARNING,
656 base::UTF8ToUTF16(chrome::kSupervisedUserManagementDisplayURL))); 725 base::UTF8ToUTF16(chrome::kSupervisedUserManagementDisplayURL)));
657 726
658 // Strings needed for the User Manager tutorial slides. 727 // Strings needed for the User Manager tutorial slides.
659 localized_strings->SetString("tutorialNext", 728 localized_strings->SetString("tutorialNext",
660 l10n_util::GetStringUTF16(IDS_USER_MANAGER_TUTORIAL_NEXT)); 729 l10n_util::GetStringUTF16(IDS_USER_MANAGER_TUTORIAL_NEXT));
661 localized_strings->SetString("tutorialDone", 730 localized_strings->SetString("tutorialDone",
662 l10n_util::GetStringUTF16(IDS_USER_MANAGER_TUTORIAL_DONE)); 731 l10n_util::GetStringUTF16(IDS_USER_MANAGER_TUTORIAL_DONE));
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 Profile* profile, Profile::CreateStatus profile_create_status) { 908 Profile* profile, Profile::CreateStatus profile_create_status) {
840 Browser* browser = chrome::FindAnyBrowser(profile, false, desktop_type_); 909 Browser* browser = chrome::FindAnyBrowser(profile, false, desktop_type_);
841 if (browser && browser->window()) { 910 if (browser && browser->window()) {
842 OnBrowserWindowReady(browser); 911 OnBrowserWindowReady(browser);
843 } else { 912 } else {
844 registrar_.Add(this, 913 registrar_.Add(this,
845 chrome::NOTIFICATION_BROWSER_WINDOW_READY, 914 chrome::NOTIFICATION_BROWSER_WINDOW_READY,
846 content::NotificationService::AllSources()); 915 content::NotificationService::AllSources());
847 } 916 }
848 } 917 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698