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