| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/profile_helper.h" |
| 6 |
| 5 #include "base/bind.h" | 7 #include "base/bind.h" |
| 6 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 7 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
| 8 #include "chrome/browser/profiles/profile_metrics.h" | 10 #include "chrome/browser/profiles/profile_metrics.h" |
| 9 #include "chrome/browser/profiles/profile_window.h" | 11 #include "chrome/browser/profiles/profile_window.h" |
| 10 #include "chrome/browser/profiles/profiles_state.h" | 12 #include "chrome/browser/profiles/profiles_state.h" |
| 11 #include "chrome/browser/ui/browser_finder.h" | 13 #include "chrome/browser/ui/browser_finder.h" |
| 12 #include "chrome/browser/ui/webui/profile_helper.h" | 14 #include "chrome/browser/ui/user_manager.h" |
| 15 #include "chrome/browser/ui/webui/signin/signin_utils.h" |
| 13 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 14 #include "content/public/browser/web_ui.h" | 17 #include "content/public/browser/web_ui.h" |
| 15 #include "extensions/browser/app_window/app_window.h" | 18 #include "extensions/browser/app_window/app_window.h" |
| 16 #include "extensions/browser/app_window/app_window_registry.h" | 19 #include "extensions/browser/app_window/app_window_registry.h" |
| 17 | 20 |
| 18 namespace webui { | 21 namespace webui { |
| 19 | 22 |
| 20 void OpenNewWindowForProfile(Profile* profile, Profile::CreateStatus status) { | 23 void OpenNewWindowForProfile(Profile* profile, Profile::CreateStatus status) { |
| 21 if (status != Profile::CREATE_STATUS_INITIALIZED) | 24 if (status != Profile::CREATE_STATUS_INITIALIZED) |
| 22 return; | 25 return; |
| 23 | 26 |
| 24 profiles::FindOrCreateNewWindowForProfile( | 27 if (signin::IsForceSigninEnabled()) { |
| 25 profile, chrome::startup::IS_PROCESS_STARTUP, | 28 // TODO(zmin): Remove the switcher once the UserManager API is finished on Mac. |
| 26 chrome::startup::IS_FIRST_RUN, false); | 29 #if !defined(OS_MACOSX) |
| 30 if (!UserManager::IsShowing()) { |
| 31 UserManager::Show(base::FilePath(), profiles::USER_MANAGER_NO_TUTORIAL, |
| 32 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
| 33 } |
| 34 UserManager::ShowSigninDialog(nullptr, profile->GetPath()); |
| 35 #endif |
| 36 } else { |
| 37 profiles::FindOrCreateNewWindowForProfile( |
| 38 profile, chrome::startup::IS_PROCESS_STARTUP, |
| 39 chrome::startup::IS_FIRST_RUN, false); |
| 40 } |
| 27 } | 41 } |
| 28 | 42 |
| 29 void DeleteProfileAtPath(base::FilePath file_path, | 43 void DeleteProfileAtPath(base::FilePath file_path, |
| 30 content::WebUI* web_ui, | 44 content::WebUI* web_ui, |
| 31 ProfileMetrics::ProfileDelete deletion_source) { | 45 ProfileMetrics::ProfileDelete deletion_source) { |
| 32 DCHECK(web_ui); | 46 DCHECK(web_ui); |
| 33 | 47 |
| 34 if (!profiles::IsMultipleProfilesEnabled()) | 48 if (!profiles::IsMultipleProfilesEnabled()) |
| 35 return; | 49 return; |
| 36 g_browser_process->profile_manager()->MaybeScheduleProfileForDeletion( | 50 g_browser_process->profile_manager()->MaybeScheduleProfileForDeletion( |
| 37 file_path, base::Bind(&OpenNewWindowForProfile), deletion_source); | 51 file_path, base::Bind(&OpenNewWindowForProfile), deletion_source); |
| 38 } | 52 } |
| 39 | 53 |
| 40 } // namespace webui | 54 } // namespace webui |
| OLD | NEW |