OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <set> | 5 #include <set> |
6 | 6 |
7 #include "chrome/browser/profiles/profile_manager.h" | 7 #include "chrome/browser/profiles/profile_manager.h" |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 23 matching lines...) Expand all Loading... | |
34 #include "net/url_request/url_request_context.h" | 34 #include "net/url_request/url_request_context.h" |
35 #include "net/url_request/url_request_context_getter.h" | 35 #include "net/url_request/url_request_context_getter.h" |
36 #include "net/url_request/url_request_job.h" | 36 #include "net/url_request/url_request_job.h" |
37 #include "ui/base/l10n/l10n_util.h" | 37 #include "ui/base/l10n/l10n_util.h" |
38 | 38 |
39 #if defined(OS_CHROMEOS) | 39 #if defined(OS_CHROMEOS) |
40 #include "chrome/browser/chromeos/cros/cros_library.h" | 40 #include "chrome/browser/chromeos/cros/cros_library.h" |
41 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | 41 #include "chrome/browser/chromeos/cros/cryptohome_library.h" |
42 #endif | 42 #endif |
43 | 43 |
44 namespace { | |
45 | |
46 void DeleteProfileDirectories(std::vector<FilePath> paths) { | |
willchan no longer on Chromium
2011/07/07 17:36:27
const std::vector<FilePath>&
sail
2011/07/07 18:00:19
To make it thread safe I want this to be a copy of
willchan no longer on Chromium
2011/07/08 08:33:17
NewRunnableFunction() will take the parameters and
sail
2011/07/08 16:04:33
Thanks for the explanation! Sent out fix in a sepa
| |
47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | |
48 for (std::vector<FilePath>::iterator it = paths.begin(); | |
49 it != paths.end(); ++it) { | |
50 file_util::Delete(*it, true); | |
51 } | |
52 } | |
53 | |
54 } // namespace | |
55 | |
44 bool ProfileManagerObserver::DeleteAfterCreation() { | 56 bool ProfileManagerObserver::DeleteAfterCreation() { |
45 return false; | 57 return false; |
46 } | 58 } |
47 | 59 |
48 // The NewProfileLauncher class is created when to wait for a multi-profile | 60 // The NewProfileLauncher class is created when to wait for a multi-profile |
49 // to be created asynchronously. Upon completion of profile creation, the | 61 // to be created asynchronously. Upon completion of profile creation, the |
50 // NPL takes care of launching a new browser window and signing the user | 62 // NPL takes care of launching a new browser window and signing the user |
51 // in to their Google account. | 63 // in to their Google account. |
52 class NewProfileLauncher : public ProfileManagerObserver { | 64 class NewProfileLauncher : public ProfileManagerObserver { |
53 public: | 65 public: |
54 virtual void OnProfileCreated(Profile* profile) { | 66 virtual void OnProfileCreated(Profile* profile) { |
55 Browser* browser = Browser::Create(profile); | 67 Browser* browser = Browser::Create(profile); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 #if defined(OS_CHROMEOS) | 104 #if defined(OS_CHROMEOS) |
93 registrar_.Add( | 105 registrar_.Add( |
94 this, | 106 this, |
95 NotificationType::LOGIN_USER_CHANGED, | 107 NotificationType::LOGIN_USER_CHANGED, |
96 NotificationService::AllSources()); | 108 NotificationService::AllSources()); |
97 #endif | 109 #endif |
98 } | 110 } |
99 | 111 |
100 ProfileManager::~ProfileManager() { | 112 ProfileManager::~ProfileManager() { |
101 BrowserList::RemoveObserver(this); | 113 BrowserList::RemoveObserver(this); |
114 | |
115 if (profiles_to_delete_.size()) { | |
willchan no longer on Chromium
2011/07/07 17:36:27
Perhaps we should tag this with TODO: fix crbug.co
Miranda Callahan
2011/07/07 17:45:55
Agreed wholeheartedly about tagging; another reaso
sail
2011/07/07 18:00:19
Done.
| |
116 BrowserThread::PostTask( | |
117 BrowserThread::FILE, FROM_HERE, | |
118 NewRunnableFunction(&DeleteProfileDirectories, profiles_to_delete_)); | |
119 profiles_to_delete_.clear(); | |
120 } | |
102 } | 121 } |
103 | 122 |
104 FilePath ProfileManager::GetDefaultProfileDir( | 123 FilePath ProfileManager::GetDefaultProfileDir( |
105 const FilePath& user_data_dir) { | 124 const FilePath& user_data_dir) { |
106 FilePath default_profile_dir(user_data_dir); | 125 FilePath default_profile_dir(user_data_dir); |
107 default_profile_dir = | 126 default_profile_dir = |
108 default_profile_dir.AppendASCII(chrome::kNotSignedInProfile); | 127 default_profile_dir.AppendASCII(chrome::kNotSignedInProfile); |
109 return default_profile_dir; | 128 return default_profile_dir; |
110 } | 129 } |
111 | 130 |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
528 cache.AddProfileToCache( | 547 cache.AddProfileToCache( |
529 profile->GetPath(), | 548 profile->GetPath(), |
530 l10n_util::GetStringUTF16(IDS_DEFAULT_PROFILE_NAME), 0); | 549 l10n_util::GetStringUTF16(IDS_DEFAULT_PROFILE_NAME), 0); |
531 } else { | 550 } else { |
532 cache.AddProfileToCache( | 551 cache.AddProfileToCache( |
533 profile->GetPath(), | 552 profile->GetPath(), |
534 cache.ChooseNameForNewProfile(), | 553 cache.ChooseNameForNewProfile(), |
535 cache.ChooseAvatarIconIndexForNewProfile()); | 554 cache.ChooseAvatarIconIndexForNewProfile()); |
536 } | 555 } |
537 } | 556 } |
557 | |
558 void ProfileManager::ScheduleProfileForDeletion(const FilePath& profile_dir) { | |
559 Profile* profile = GetProfileByPath(profile_dir); | |
560 if (profile) | |
561 BrowserList::CloseAllBrowsersWithProfile(profile); | |
Miranda Callahan
2011/07/07 17:43:02
Is there any issue with BackgroundApps that we hav
sail
2011/07/07 18:00:19
No idea. Would rachel know?
Miranda Callahan
2011/07/07 18:24:16
I can imagine that she would -- adding her in.
rpetterson
2011/07/07 18:24:30
This particular call shouldn't affect BackgroundAp
| |
562 profiles_to_delete_.push_back(profile_dir); | |
563 GetProfileInfoCache().DeleteProfileFromCache(profile_dir); | |
564 } | |
OLD | NEW |