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) { |
| 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 // TODO(sail): fix http://crbug.com/88586 |
| 116 if (profiles_to_delete_.size()) { |
| 117 BrowserThread::PostTask( |
| 118 BrowserThread::FILE, FROM_HERE, |
| 119 NewRunnableFunction(&DeleteProfileDirectories, profiles_to_delete_)); |
| 120 profiles_to_delete_.clear(); |
| 121 } |
102 } | 122 } |
103 | 123 |
104 FilePath ProfileManager::GetDefaultProfileDir( | 124 FilePath ProfileManager::GetDefaultProfileDir( |
105 const FilePath& user_data_dir) { | 125 const FilePath& user_data_dir) { |
106 FilePath default_profile_dir(user_data_dir); | 126 FilePath default_profile_dir(user_data_dir); |
107 default_profile_dir = | 127 default_profile_dir = |
108 default_profile_dir.AppendASCII(chrome::kNotSignedInProfile); | 128 default_profile_dir.AppendASCII(chrome::kNotSignedInProfile); |
109 return default_profile_dir; | 129 return default_profile_dir; |
110 } | 130 } |
111 | 131 |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 cache.AddProfileToCache( | 548 cache.AddProfileToCache( |
529 profile->GetPath(), | 549 profile->GetPath(), |
530 l10n_util::GetStringUTF16(IDS_DEFAULT_PROFILE_NAME), 0); | 550 l10n_util::GetStringUTF16(IDS_DEFAULT_PROFILE_NAME), 0); |
531 } else { | 551 } else { |
532 cache.AddProfileToCache( | 552 cache.AddProfileToCache( |
533 profile->GetPath(), | 553 profile->GetPath(), |
534 cache.ChooseNameForNewProfile(), | 554 cache.ChooseNameForNewProfile(), |
535 cache.ChooseAvatarIconIndexForNewProfile()); | 555 cache.ChooseAvatarIconIndexForNewProfile()); |
536 } | 556 } |
537 } | 557 } |
| 558 |
| 559 void ProfileManager::ScheduleProfileForDeletion(const FilePath& profile_dir) { |
| 560 // TODO(sail): Due to bug 88586 we don't delete the profile instance. Once we |
| 561 // start deleting the profile instance we need to close background apps too. |
| 562 Profile* profile = GetProfileByPath(profile_dir); |
| 563 if (profile) |
| 564 BrowserList::CloseAllBrowsersWithProfile(profile); |
| 565 profiles_to_delete_.push_back(profile_dir); |
| 566 ProfileInfoCache& cache = GetProfileInfoCache(); |
| 567 cache.DeleteProfileFromCache(profile_dir); |
| 568 } |
OLD | NEW |