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

Side by Side Diff: chrome/browser/ui/webui/profile_helper.cc

Issue 2516613002: Profile deletion: prevent profile creation race in dying browser. (Closed)
Patch Set: Review fixes Created 4 years, 1 month 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
« no previous file with comments | « chrome/browser/ui/webui/profile_helper.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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" 5 #include "chrome/browser/ui/webui/profile_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/lifetime/keep_alive_types.h"
10 #include "chrome/browser/lifetime/scoped_keep_alive.h"
9 #include "chrome/browser/profiles/profile_manager.h" 11 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/browser/profiles/profile_metrics.h" 12 #include "chrome/browser/profiles/profile_metrics.h"
11 #include "chrome/browser/profiles/profile_window.h" 13 #include "chrome/browser/profiles/profile_window.h"
12 #include "chrome/browser/profiles/profiles_state.h" 14 #include "chrome/browser/profiles/profiles_state.h"
13 #include "chrome/browser/ui/browser_finder.h" 15 #include "chrome/browser/ui/browser_finder.h"
14 #include "chrome/browser/ui/user_manager.h" 16 #include "chrome/browser/ui/user_manager.h"
15 #include "chrome/browser/ui/webui/signin/signin_utils.h" 17 #include "chrome/browser/ui/webui/signin/signin_utils.h"
16 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
17 #include "content/public/browser/web_ui.h" 19 #include "content/public/browser/web_ui.h"
18 #include "extensions/browser/app_window/app_window.h" 20 #include "extensions/browser/app_window/app_window.h"
19 #include "extensions/browser/app_window/app_window_registry.h" 21 #include "extensions/browser/app_window/app_window_registry.h"
20 22
21 namespace webui { 23 namespace webui {
22 namespace { 24 namespace {
25
23 void ShowSigninDialog(base::FilePath signin_profile_path, 26 void ShowSigninDialog(base::FilePath signin_profile_path,
24 Profile* system_profile, 27 Profile* system_profile,
25 Profile::CreateStatus status) { 28 Profile::CreateStatus status) {
26 UserManager::ShowSigninDialog(system_profile, signin_profile_path); 29 UserManager::ShowSigninDialog(system_profile, signin_profile_path);
27 } 30 }
28 31
29 } // namespace 32 void DeleteProfileCallback(std::unique_ptr<ScopedKeepAlive> keep_alive,
30 void OpenNewWindowForProfile(Profile* profile, Profile::CreateStatus status) { 33 Profile* profile,
34 Profile::CreateStatus status) {
31 if (status != Profile::CREATE_STATUS_INITIALIZED) 35 if (status != Profile::CREATE_STATUS_INITIALIZED)
32 return; 36 return;
33 37
38 OpenNewWindowForProfile(profile);
39 }
40
41 } // namespace
42
43 void OpenNewWindowForProfile(Profile* profile) {
34 if (signin::IsForceSigninEnabled()) { 44 if (signin::IsForceSigninEnabled()) {
35 if (!UserManager::IsShowing()) { 45 if (!UserManager::IsShowing()) {
36 UserManager::Show(base::FilePath(), profiles::USER_MANAGER_NO_TUTORIAL, 46 UserManager::Show(base::FilePath(), profiles::USER_MANAGER_NO_TUTORIAL,
37 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); 47 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
38 } 48 }
39 49
40 g_browser_process->profile_manager()->CreateProfileAsync( 50 g_browser_process->profile_manager()->CreateProfileAsync(
41 ProfileManager::GetSystemProfilePath(), 51 ProfileManager::GetSystemProfilePath(),
42 base::Bind(&ShowSigninDialog, profile->GetPath()), base::string16(), 52 base::Bind(&ShowSigninDialog, profile->GetPath()), base::string16(),
43 std::string(), std::string()); 53 std::string(), std::string());
44 54
45 } else { 55 } else {
46 profiles::FindOrCreateNewWindowForProfile( 56 profiles::FindOrCreateNewWindowForProfile(
47 profile, chrome::startup::IS_PROCESS_STARTUP, 57 profile, chrome::startup::IS_PROCESS_STARTUP,
48 chrome::startup::IS_FIRST_RUN, false); 58 chrome::startup::IS_FIRST_RUN, false);
49 } 59 }
50 } 60 }
51 61
52 void DeleteProfileAtPath(base::FilePath file_path, 62 void DeleteProfileAtPath(base::FilePath file_path,
53 content::WebUI* web_ui, 63 content::WebUI* web_ui,
54 ProfileMetrics::ProfileDelete deletion_source) { 64 ProfileMetrics::ProfileDelete deletion_source) {
55 DCHECK(web_ui); 65 DCHECK(web_ui);
56 66
57 if (!profiles::IsMultipleProfilesEnabled()) 67 if (!profiles::IsMultipleProfilesEnabled())
58 return; 68 return;
59 g_browser_process->profile_manager()->MaybeScheduleProfileForDeletion( 69 g_browser_process->profile_manager()->MaybeScheduleProfileForDeletion(
60 file_path, base::Bind(&OpenNewWindowForProfile), deletion_source); 70 file_path, base::Bind(&DeleteProfileCallback,
71 base::Passed(base::MakeUnique<ScopedKeepAlive>(
72 KeepAliveOrigin::PROFILE_HELPER,
73 KeepAliveRestartOption::DISABLED))),
74 deletion_source);
61 } 75 }
62 76
63 } // namespace webui 77 } // namespace webui
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/profile_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698