| 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 21 matching lines...) Expand all Loading... |
| 32 #include "chrome/browser/signin/local_auth.h" | 32 #include "chrome/browser/signin/local_auth.h" |
| 33 #include "chrome/browser/ui/app_list/app_list_service.h" | 33 #include "chrome/browser/ui/app_list/app_list_service.h" |
| 34 #include "chrome/browser/ui/browser_commands.h" | 34 #include "chrome/browser/ui/browser_commands.h" |
| 35 #include "chrome/browser/ui/browser_dialogs.h" | 35 #include "chrome/browser/ui/browser_dialogs.h" |
| 36 #include "chrome/browser/ui/browser_finder.h" | 36 #include "chrome/browser/ui/browser_finder.h" |
| 37 #include "chrome/browser/ui/browser_list.h" | 37 #include "chrome/browser/ui/browser_list.h" |
| 38 #include "chrome/browser/ui/browser_list_observer.h" | 38 #include "chrome/browser/ui/browser_list_observer.h" |
| 39 #include "chrome/browser/ui/chrome_pages.h" | 39 #include "chrome/browser/ui/chrome_pages.h" |
| 40 #include "chrome/browser/ui/singleton_tabs.h" | 40 #include "chrome/browser/ui/singleton_tabs.h" |
| 41 #include "chrome/browser/ui/user_manager.h" | 41 #include "chrome/browser/ui/user_manager.h" |
| 42 #include "chrome/browser/ui/webui/profile_helper.h" |
| 42 #include "chrome/common/pref_names.h" | 43 #include "chrome/common/pref_names.h" |
| 43 #include "chrome/common/url_constants.h" | 44 #include "chrome/common/url_constants.h" |
| 44 #include "chrome/grit/chromium_strings.h" | 45 #include "chrome/grit/chromium_strings.h" |
| 45 #include "chrome/grit/generated_resources.h" | 46 #include "chrome/grit/generated_resources.h" |
| 46 #include "components/prefs/pref_service.h" | 47 #include "components/prefs/pref_service.h" |
| 47 #include "components/proximity_auth/screenlock_bridge.h" | 48 #include "components/proximity_auth/screenlock_bridge.h" |
| 48 #include "components/signin/core/account_id/account_id.h" | 49 #include "components/signin/core/account_id/account_id.h" |
| 49 #include "content/public/browser/notification_service.h" | 50 #include "content/public/browser/notification_service.h" |
| 50 #include "content/public/browser/web_contents.h" | 51 #include "content/public/browser/web_contents.h" |
| 51 #include "content/public/browser/web_ui.h" | 52 #include "content/public/browser/web_ui.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 const char kJsApiUserManagerRemoveUserWarningLoadStats[] = | 96 const char kJsApiUserManagerRemoveUserWarningLoadStats[] = |
| 96 "removeUserWarningLoadStats"; | 97 "removeUserWarningLoadStats"; |
| 97 const char kJsApiUserManagerGetRemoveWarningDialogMessage[] = | 98 const char kJsApiUserManagerGetRemoveWarningDialogMessage[] = |
| 98 "getRemoveWarningDialogMessage"; | 99 "getRemoveWarningDialogMessage"; |
| 99 const size_t kAvatarIconSize = 180; | 100 const size_t kAvatarIconSize = 180; |
| 100 const int kMaxOAuthRetries = 3; | 101 const int kMaxOAuthRetries = 3; |
| 101 | 102 |
| 102 void HandleAndDoNothing(const base::ListValue* args) { | 103 void HandleAndDoNothing(const base::ListValue* args) { |
| 103 } | 104 } |
| 104 | 105 |
| 105 // This callback is run if the only profile has been deleted, and a new | |
| 106 // profile has been created to replace it. | |
| 107 void OpenNewWindowForProfile(Profile* profile, Profile::CreateStatus status) { | |
| 108 if (status != Profile::CREATE_STATUS_INITIALIZED) | |
| 109 return; | |
| 110 profiles::FindOrCreateNewWindowForProfile( | |
| 111 profile, chrome::startup::IS_PROCESS_STARTUP, | |
| 112 chrome::startup::IS_FIRST_RUN, false); | |
| 113 } | |
| 114 | |
| 115 std::string GetAvatarImage(const ProfileAttributesEntry* entry) { | 106 std::string GetAvatarImage(const ProfileAttributesEntry* entry) { |
| 116 bool is_gaia_picture = entry->IsUsingGAIAPicture() && | 107 bool is_gaia_picture = entry->IsUsingGAIAPicture() && |
| 117 entry->GetGAIAPicture() != nullptr; | 108 entry->GetGAIAPicture() != nullptr; |
| 118 | 109 |
| 119 // If the avatar is too small (i.e. the old-style low resolution avatar), | 110 // If the avatar is too small (i.e. the old-style low resolution avatar), |
| 120 // it will be pixelated when displayed in the User Manager, so we should | 111 // it will be pixelated when displayed in the User Manager, so we should |
| 121 // return the placeholder avatar instead. | 112 // return the placeholder avatar instead. |
| 122 gfx::Image avatar_image = entry->GetAvatarIcon(); | 113 gfx::Image avatar_image = entry->GetAvatarIcon(); |
| 123 if (avatar_image.Width() <= profiles::kAvatarIconWidth || | 114 if (avatar_image.Width() <= profiles::kAvatarIconWidth || |
| 124 avatar_image.Height() <= profiles::kAvatarIconHeight ) { | 115 avatar_image.Height() <= profiles::kAvatarIconHeight ) { |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 if (!base::GetValueAsFilePath(*profile_path_value, &profile_path)) { | 459 if (!base::GetValueAsFilePath(*profile_path_value, &profile_path)) { |
| 469 NOTREACHED(); | 460 NOTREACHED(); |
| 470 return; | 461 return; |
| 471 } | 462 } |
| 472 | 463 |
| 473 if (!profiles::IsMultipleProfilesEnabled()) { | 464 if (!profiles::IsMultipleProfilesEnabled()) { |
| 474 NOTREACHED(); | 465 NOTREACHED(); |
| 475 return; | 466 return; |
| 476 } | 467 } |
| 477 | 468 |
| 469 // The callback is run if the only profile has been deleted, and a new |
| 470 // profile has been created to replace it. |
| 478 g_browser_process->profile_manager()->ScheduleProfileForDeletion( | 471 g_browser_process->profile_manager()->ScheduleProfileForDeletion( |
| 479 profile_path, base::Bind(&OpenNewWindowForProfile)); | 472 profile_path, base::Bind(&webui::OpenNewWindowForProfile)); |
| 480 ProfileMetrics::LogProfileDeleteUser( | 473 ProfileMetrics::LogProfileDeleteUser( |
| 481 ProfileMetrics::DELETE_PROFILE_USER_MANAGER); | 474 ProfileMetrics::DELETE_PROFILE_USER_MANAGER); |
| 482 } | 475 } |
| 483 | 476 |
| 484 void UserManagerScreenHandler::HandleLaunchGuest(const base::ListValue* args) { | 477 void UserManagerScreenHandler::HandleLaunchGuest(const base::ListValue* args) { |
| 485 if (IsGuestModeEnabled()) { | 478 if (IsGuestModeEnabled()) { |
| 486 profiles::SwitchToGuestProfile( | 479 profiles::SwitchToGuestProfile( |
| 487 base::Bind(&UserManagerScreenHandler::OnSwitchToProfileComplete, | 480 base::Bind(&UserManagerScreenHandler::OnSwitchToProfileComplete, |
| 488 weak_ptr_factory_.GetWeakPtr())); | 481 weak_ptr_factory_.GetWeakPtr())); |
| 489 } else { | 482 } else { |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 Profile* profile, Profile::CreateStatus profile_create_status) { | 978 Profile* profile, Profile::CreateStatus profile_create_status) { |
| 986 Browser* browser = chrome::FindAnyBrowser(profile, false); | 979 Browser* browser = chrome::FindAnyBrowser(profile, false); |
| 987 if (browser && browser->window()) { | 980 if (browser && browser->window()) { |
| 988 OnBrowserWindowReady(browser); | 981 OnBrowserWindowReady(browser); |
| 989 } else { | 982 } else { |
| 990 registrar_.Add(this, | 983 registrar_.Add(this, |
| 991 chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 984 chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
| 992 content::NotificationService::AllSources()); | 985 content::NotificationService::AllSources()); |
| 993 } | 986 } |
| 994 } | 987 } |
| OLD | NEW |