OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/profiles/profile_manager.h" | 5 #include "chrome/browser/profiles/profile_manager.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h" | 32 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h" |
33 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 33 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
34 #include "chrome/browser/profiles/profile_destroyer.h" | 34 #include "chrome/browser/profiles/profile_destroyer.h" |
35 #include "chrome/browser/profiles/profile_info_cache.h" | 35 #include "chrome/browser/profiles/profile_info_cache.h" |
36 #include "chrome/browser/profiles/profile_metrics.h" | 36 #include "chrome/browser/profiles/profile_metrics.h" |
37 #include "chrome/browser/profiles/profiles_state.h" | 37 #include "chrome/browser/profiles/profiles_state.h" |
38 #include "chrome/browser/profiles/startup_task_runner_service.h" | 38 #include "chrome/browser/profiles/startup_task_runner_service.h" |
39 #include "chrome/browser/profiles/startup_task_runner_service_factory.h" | 39 #include "chrome/browser/profiles/startup_task_runner_service_factory.h" |
40 #include "chrome/browser/signin/account_reconcilor_factory.h" | 40 #include "chrome/browser/signin/account_reconcilor_factory.h" |
41 #include "chrome/browser/signin/account_tracker_service_factory.h" | 41 #include "chrome/browser/signin/account_tracker_service_factory.h" |
| 42 #include "chrome/browser/signin/cross_device_promo.h" |
| 43 #include "chrome/browser/signin/cross_device_promo_factory.h" |
42 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h" | 44 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h" |
43 #include "chrome/browser/signin/signin_manager_factory.h" | 45 #include "chrome/browser/signin/signin_manager_factory.h" |
44 #include "chrome/browser/sync/profile_sync_service.h" | 46 #include "chrome/browser/sync/profile_sync_service.h" |
45 #include "chrome/browser/sync/profile_sync_service_factory.h" | 47 #include "chrome/browser/sync/profile_sync_service_factory.h" |
46 #include "chrome/browser/ui/browser.h" | 48 #include "chrome/browser/ui/browser.h" |
47 #include "chrome/browser/ui/browser_iterator.h" | 49 #include "chrome/browser/ui/browser_iterator.h" |
48 #include "chrome/browser/ui/sync/sync_promo_ui.h" | 50 #include "chrome/browser/ui/sync/sync_promo_ui.h" |
49 #include "chrome/common/chrome_constants.h" | 51 #include "chrome/common/chrome_constants.h" |
50 #include "chrome/common/chrome_paths_internal.h" | 52 #include "chrome/common/chrome_paths_internal.h" |
51 #include "chrome/common/chrome_switches.h" | 53 #include "chrome/common/chrome_switches.h" |
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1239 profile, ServiceAccessType::EXPLICIT_ACCESS).get(); | 1241 profile, ServiceAccessType::EXPLICIT_ACCESS).get(); |
1240 if (password_store.get()) { | 1242 if (password_store.get()) { |
1241 password_store->RemoveLoginsCreatedBetween(base::Time(), | 1243 password_store->RemoveLoginsCreatedBetween(base::Time(), |
1242 base::Time::Max()); | 1244 base::Time::Max()); |
1243 } | 1245 } |
1244 | 1246 |
1245 // The Profile Data doesn't get wiped until Chrome closes. Since we promised | 1247 // The Profile Data doesn't get wiped until Chrome closes. Since we promised |
1246 // that the user's data would be removed, do so immediately. | 1248 // that the user's data would be removed, do so immediately. |
1247 profiles::RemoveBrowsingDataForProfile(profile_dir); | 1249 profiles::RemoveBrowsingDataForProfile(profile_dir); |
1248 } else { | 1250 } else { |
| 1251 // It is safe to delete a not yet loaded Profile from disk. |
1249 BrowserThread::PostTask( | 1252 BrowserThread::PostTask( |
1250 BrowserThread::FILE, FROM_HERE, | 1253 BrowserThread::FILE, FROM_HERE, |
1251 base::Bind(&NukeProfileFromDisk, profile_dir)); | 1254 base::Bind(&NukeProfileFromDisk, profile_dir)); |
1252 } | 1255 } |
1253 | 1256 |
1254 // Queue even a profile that was Nuked so it will be MarkedForDeletion and so | 1257 // Queue even a profile that was nuked so it will be MarkedForDeletion and so |
1255 // CreateProfileAsync can't create it. | 1258 // CreateProfileAsync can't create it. |
1256 QueueProfileDirectoryForDeletion(profile_dir); | 1259 QueueProfileDirectoryForDeletion(profile_dir); |
1257 cache.DeleteProfileFromCache(profile_dir); | 1260 cache.DeleteProfileFromCache(profile_dir); |
1258 ProfileMetrics::UpdateReportedProfilesStatistics(this); | 1261 ProfileMetrics::UpdateReportedProfilesStatistics(this); |
1259 } | 1262 } |
1260 | 1263 |
1261 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile( | 1264 ProfileManager::ProfileInfo* ProfileManager::RegisterProfile( |
1262 Profile* profile, | 1265 Profile* profile, |
1263 bool created) { | 1266 bool created) { |
1264 TRACE_EVENT0("browser", "ProfileManager::RegisterProfile"); | 1267 TRACE_EVENT0("browser", "ProfileManager::RegisterProfile"); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1369 // Only keep track of profiles that we are managing; tests may create others. | 1372 // Only keep track of profiles that we are managing; tests may create others. |
1370 if (profiles_info_.find(last_active->GetPath()) != profiles_info_.end()) { | 1373 if (profiles_info_.find(last_active->GetPath()) != profiles_info_.end()) { |
1371 std::string profile_path_base = | 1374 std::string profile_path_base = |
1372 last_active->GetPath().BaseName().MaybeAsASCII(); | 1375 last_active->GetPath().BaseName().MaybeAsASCII(); |
1373 if (profile_path_base != GetLastUsedProfileName()) | 1376 if (profile_path_base != GetLastUsedProfileName()) |
1374 local_state->SetString(prefs::kProfileLastUsed, profile_path_base); | 1377 local_state->SetString(prefs::kProfileLastUsed, profile_path_base); |
1375 | 1378 |
1376 ProfileInfoCache& cache = GetProfileInfoCache(); | 1379 ProfileInfoCache& cache = GetProfileInfoCache(); |
1377 size_t profile_index = | 1380 size_t profile_index = |
1378 cache.GetIndexOfProfileWithPath(last_active->GetPath()); | 1381 cache.GetIndexOfProfileWithPath(last_active->GetPath()); |
1379 if (profile_index != std::string::npos) | 1382 if (profile_index != std::string::npos) { |
| 1383 #if !defined(OS_CHROMEOS) |
| 1384 // Incognito Profiles don't have ProfileKeyedServices. |
| 1385 if (!last_active->IsOffTheRecord()) { |
| 1386 CrossDevicePromoFactory::GetForProfile(last_active) |
| 1387 ->MaybeBrowsingSessionStarted( |
| 1388 cache.GetProfileActiveTimeAtIndex(profile_index)); |
| 1389 } |
| 1390 #endif |
1380 cache.SetProfileActiveTimeAtIndex(profile_index); | 1391 cache.SetProfileActiveTimeAtIndex(profile_index); |
| 1392 } |
1381 } | 1393 } |
1382 } | 1394 } |
1383 | 1395 |
1384 ProfileManager::BrowserListObserver::BrowserListObserver( | 1396 ProfileManager::BrowserListObserver::BrowserListObserver( |
1385 ProfileManager* manager) | 1397 ProfileManager* manager) |
1386 : profile_manager_(manager) { | 1398 : profile_manager_(manager) { |
1387 BrowserList::AddObserver(this); | 1399 BrowserList::AddObserver(this); |
1388 } | 1400 } |
1389 | 1401 |
1390 ProfileManager::BrowserListObserver::~BrowserListObserver() { | 1402 ProfileManager::BrowserListObserver::~BrowserListObserver() { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1455 } | 1467 } |
1456 | 1468 |
1457 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); | 1469 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); |
1458 if (!original_callback.is_null()) | 1470 if (!original_callback.is_null()) |
1459 original_callback.Run(loaded_profile, status); | 1471 original_callback.Run(loaded_profile, status); |
1460 } | 1472 } |
1461 | 1473 |
1462 ProfileManagerWithoutInit::ProfileManagerWithoutInit( | 1474 ProfileManagerWithoutInit::ProfileManagerWithoutInit( |
1463 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { | 1475 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { |
1464 } | 1476 } |
OLD | NEW |