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 20 matching lines...) Expand all Loading... |
31 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | 31 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
32 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" | 32 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" |
33 #include "chrome/browser/password_manager/password_manager_setting_migrator_serv
ice_factory.h" | 33 #include "chrome/browser/password_manager/password_manager_setting_migrator_serv
ice_factory.h" |
34 #include "chrome/browser/password_manager/password_store_factory.h" | 34 #include "chrome/browser/password_manager/password_store_factory.h" |
35 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 35 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
36 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h" | 36 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h" |
37 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 37 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
38 #include "chrome/browser/profiles/profile_destroyer.h" | 38 #include "chrome/browser/profiles/profile_destroyer.h" |
39 #include "chrome/browser/profiles/profile_info_cache.h" | 39 #include "chrome/browser/profiles/profile_info_cache.h" |
40 #include "chrome/browser/profiles/profile_metrics.h" | 40 #include "chrome/browser/profiles/profile_metrics.h" |
| 41 #include "chrome/browser/profiles/profile_statistics.h" |
41 #include "chrome/browser/profiles/profiles_state.h" | 42 #include "chrome/browser/profiles/profiles_state.h" |
42 #include "chrome/browser/signin/account_fetcher_service_factory.h" | 43 #include "chrome/browser/signin/account_fetcher_service_factory.h" |
43 #include "chrome/browser/signin/account_reconcilor_factory.h" | 44 #include "chrome/browser/signin/account_reconcilor_factory.h" |
44 #include "chrome/browser/signin/account_tracker_service_factory.h" | 45 #include "chrome/browser/signin/account_tracker_service_factory.h" |
45 #include "chrome/browser/signin/cross_device_promo.h" | 46 #include "chrome/browser/signin/cross_device_promo.h" |
46 #include "chrome/browser/signin/cross_device_promo_factory.h" | 47 #include "chrome/browser/signin/cross_device_promo_factory.h" |
47 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h" | 48 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h" |
48 #include "chrome/browser/signin/signin_manager_factory.h" | 49 #include "chrome/browser/signin/signin_manager_factory.h" |
49 #include "chrome/browser/sync/profile_sync_service_factory.h" | 50 #include "chrome/browser/sync/profile_sync_service_factory.h" |
50 #include "chrome/browser/ui/browser.h" | 51 #include "chrome/browser/ui/browser.h" |
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 | 1049 |
1049 DoFinalInitForServices(profile, go_off_the_record); | 1050 DoFinalInitForServices(profile, go_off_the_record); |
1050 AddProfileToCache(profile); | 1051 AddProfileToCache(profile); |
1051 DoFinalInitLogging(profile); | 1052 DoFinalInitLogging(profile); |
1052 | 1053 |
1053 ProfileMetrics::LogNumberOfProfiles(this); | 1054 ProfileMetrics::LogNumberOfProfiles(this); |
1054 content::NotificationService::current()->Notify( | 1055 content::NotificationService::current()->Notify( |
1055 chrome::NOTIFICATION_PROFILE_ADDED, | 1056 chrome::NOTIFICATION_PROFILE_ADDED, |
1056 content::Source<Profile>(profile), | 1057 content::Source<Profile>(profile), |
1057 content::NotificationService::NoDetails()); | 1058 content::NotificationService::NoDetails()); |
| 1059 |
| 1060 // Record statistics to ProfileInfoCache if statistics were not recorded |
| 1061 // during shutdown, i.e. the last shutdown was a system shutdown or a crash. |
| 1062 if (!profile->IsGuestSession() && !profile->IsSystemProfile() && |
| 1063 !profile->IsNewProfile() && !go_off_the_record && |
| 1064 profile->GetLastSessionExitType() != Profile::EXIT_NORMAL) { |
| 1065 profiles::GatherProfileStatistics( |
| 1066 profile, profiles::ProfileStatisticsCallback(), nullptr); |
| 1067 } |
1058 } | 1068 } |
1059 | 1069 |
1060 void ProfileManager::DoFinalInitForServices(Profile* profile, | 1070 void ProfileManager::DoFinalInitForServices(Profile* profile, |
1061 bool go_off_the_record) { | 1071 bool go_off_the_record) { |
1062 TRACE_EVENT0("browser", "ProfileManager::DoFinalInitForServices"); | 1072 TRACE_EVENT0("browser", "ProfileManager::DoFinalInitForServices"); |
1063 TRACK_SCOPED_REGION("Startup", "ProfileManager::DoFinalInitForServices"); | 1073 TRACK_SCOPED_REGION("Startup", "ProfileManager::DoFinalInitForServices"); |
1064 | 1074 |
1065 #if defined(ENABLE_EXTENSIONS) | 1075 #if defined(ENABLE_EXTENSIONS) |
1066 ProfileInfoCache& cache = GetProfileInfoCache(); | 1076 ProfileInfoCache& cache = GetProfileInfoCache(); |
1067 | 1077 |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1454 | 1464 |
1455 void ProfileManager::BrowserListObserver::OnBrowserRemoved( | 1465 void ProfileManager::BrowserListObserver::OnBrowserRemoved( |
1456 Browser* browser) { | 1466 Browser* browser) { |
1457 Profile* profile = browser->profile(); | 1467 Profile* profile = browser->profile(); |
1458 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 1468 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
1459 if (it->profile()->GetOriginalProfile() == profile->GetOriginalProfile()) | 1469 if (it->profile()->GetOriginalProfile() == profile->GetOriginalProfile()) |
1460 // Not the last window for this profile. | 1470 // Not the last window for this profile. |
1461 return; | 1471 return; |
1462 } | 1472 } |
1463 | 1473 |
| 1474 // Store statistics into ProfileInfoCache. |
| 1475 profiles::GatherProfileStatistics( |
| 1476 profile, profiles::ProfileStatisticsCallback(), nullptr); |
| 1477 |
1464 // If the last browser of a profile that is scheduled for deletion is closed | 1478 // If the last browser of a profile that is scheduled for deletion is closed |
1465 // do that now. | 1479 // do that now. |
1466 base::FilePath path = profile->GetPath(); | 1480 base::FilePath path = profile->GetPath(); |
1467 if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles) && | 1481 if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles) && |
1468 !IsProfileMarkedForDeletion(path)) { | 1482 !IsProfileMarkedForDeletion(path)) { |
1469 g_browser_process->profile_manager()->ScheduleProfileForDeletion( | 1483 g_browser_process->profile_manager()->ScheduleProfileForDeletion( |
1470 path, ProfileManager::CreateCallback()); | 1484 path, ProfileManager::CreateCallback()); |
1471 } | 1485 } |
1472 } | 1486 } |
1473 | 1487 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1513 | 1527 |
1514 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); | 1528 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); |
1515 if (!original_callback.is_null()) | 1529 if (!original_callback.is_null()) |
1516 original_callback.Run(loaded_profile, status); | 1530 original_callback.Run(loaded_profile, status); |
1517 } | 1531 } |
1518 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 1532 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
1519 | 1533 |
1520 ProfileManagerWithoutInit::ProfileManagerWithoutInit( | 1534 ProfileManagerWithoutInit::ProfileManagerWithoutInit( |
1521 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { | 1535 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { |
1522 } | 1536 } |
OLD | NEW |