| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "chrome/browser/browser_process.h" | 6 #include "chrome/browser/browser_process.h" |
| 7 #include "chrome/browser/profiles/profile_manager.h" | 7 #include "chrome/browser/profiles/profile_manager.h" |
| 8 #include "chrome/browser/profiles/profile_metrics.h" | 8 #include "chrome/browser/profiles/profile_metrics.h" |
| 9 #include "chrome/browser/profiles/profile_window.h" | 9 #include "chrome/browser/profiles/profile_window.h" |
| 10 #include "chrome/browser/profiles/profiles_state.h" | 10 #include "chrome/browser/profiles/profiles_state.h" |
| 11 #include "chrome/browser/ui/browser_finder.h" | 11 #include "chrome/browser/ui/browser_finder.h" |
| 12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
| 13 #include "content/public/browser/web_ui.h" | 13 #include "content/public/browser/web_ui.h" |
| 14 #include "extensions/browser/app_window/app_window.h" | 14 #include "extensions/browser/app_window/app_window.h" |
| 15 #include "extensions/browser/app_window/app_window_registry.h" | 15 #include "extensions/browser/app_window/app_window_registry.h" |
| 16 | 16 |
| 17 namespace options { | 17 namespace options { |
| 18 namespace helper { | 18 namespace helper { |
| 19 | 19 |
| 20 chrome::HostDesktopType GetDesktopType(content::WebUI* web_ui) { | 20 void OpenNewWindowForProfile(Profile* profile, Profile::CreateStatus status) { |
| 21 DCHECK(web_ui); | |
| 22 content::WebContents* web_contents = web_ui->GetWebContents(); | |
| 23 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | |
| 24 if (browser) | |
| 25 return browser->host_desktop_type(); | |
| 26 | |
| 27 extensions::AppWindow* app_window = | |
| 28 extensions::AppWindowRegistry::Get(Profile::FromWebUI(web_ui)) | |
| 29 ->GetAppWindowForWebContents(web_contents); | |
| 30 if (app_window) { | |
| 31 return chrome::GetHostDesktopTypeForNativeWindow( | |
| 32 app_window->GetNativeWindow()); | |
| 33 } | |
| 34 | |
| 35 return chrome::GetActiveDesktop(); | |
| 36 } | |
| 37 | |
| 38 void OpenNewWindowForProfile(chrome::HostDesktopType desktop_type, | |
| 39 Profile* profile, | |
| 40 Profile::CreateStatus status) { | |
| 41 if (status != Profile::CREATE_STATUS_INITIALIZED) | 21 if (status != Profile::CREATE_STATUS_INITIALIZED) |
| 42 return; | 22 return; |
| 43 | 23 |
| 44 profiles::FindOrCreateNewWindowForProfile( | 24 profiles::FindOrCreateNewWindowForProfile( |
| 45 profile, | 25 profile, chrome::startup::IS_PROCESS_STARTUP, |
| 46 chrome::startup::IS_PROCESS_STARTUP, | 26 chrome::startup::IS_FIRST_RUN, false); |
| 47 chrome::startup::IS_FIRST_RUN, | |
| 48 desktop_type, | |
| 49 false); | |
| 50 } | 27 } |
| 51 | 28 |
| 52 void DeleteProfileAtPath(base::FilePath file_path, content::WebUI* web_ui) { | 29 void DeleteProfileAtPath(base::FilePath file_path, content::WebUI* web_ui) { |
| 53 DCHECK(web_ui); | 30 DCHECK(web_ui); |
| 54 | 31 |
| 55 if (!profiles::IsMultipleProfilesEnabled()) | 32 if (!profiles::IsMultipleProfilesEnabled()) |
| 56 return; | 33 return; |
| 57 | 34 |
| 58 ProfileMetrics::LogProfileDeleteUser(ProfileMetrics::DELETE_PROFILE_SETTINGS); | 35 ProfileMetrics::LogProfileDeleteUser(ProfileMetrics::DELETE_PROFILE_SETTINGS); |
| 59 | 36 |
| 60 g_browser_process->profile_manager()->ScheduleProfileForDeletion( | 37 g_browser_process->profile_manager()->ScheduleProfileForDeletion( |
| 61 file_path, | 38 file_path, base::Bind(&OpenNewWindowForProfile)); |
| 62 base::Bind(&OpenNewWindowForProfile, GetDesktopType(web_ui))); | |
| 63 } | 39 } |
| 64 | 40 |
| 65 } // namespace helper | 41 } // namespace helper |
| 66 } // namespace options | 42 } // namespace options |
| OLD | NEW |