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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 |
1464 // If the last browser of a profile that is scheduled for deletion is closed | 1474 // If the last browser of a profile that is scheduled for deletion is closed |
1465 // do that now. | 1475 // do that now. |
lwchkg
2015/12/29 04:51:42
I don't really understand the comment above. The c
| |
1466 base::FilePath path = profile->GetPath(); | 1476 base::FilePath path = profile->GetPath(); |
1467 if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles) && | 1477 if (profile->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles) && |
1468 !IsProfileMarkedForDeletion(path)) { | 1478 !IsProfileMarkedForDeletion(path)) { |
1469 g_browser_process->profile_manager()->ScheduleProfileForDeletion( | 1479 g_browser_process->profile_manager()->ScheduleProfileForDeletion( |
1470 path, ProfileManager::CreateCallback()); | 1480 path, ProfileManager::CreateCallback()); |
1481 return; | |
1482 } | |
1483 | |
1484 // Otherwise store statistics into ProfileInfoCache. | |
1485 if (!profile->IsOffTheRecord()) { | |
lwchkg
2015/12/22 13:26:00
Mike said that this function handles incognito pro
Mike Lerman
2015/12/23 20:25:50
This, uh, really should handle incognito (and gues
lwchkg
2015/12/24 07:14:32
Thanks. This is likely a bug behind. Maybe someone
lwchkg
2015/12/29 04:51:43
(1) Investigated the code about the BrowserListObs
| |
1486 profiles::GatherProfileStatistics( | |
1487 profile, profiles::ProfileStatisticsCallback(), nullptr); | |
1471 } | 1488 } |
1472 } | 1489 } |
1473 | 1490 |
1474 void ProfileManager::BrowserListObserver::OnBrowserSetLastActive( | 1491 void ProfileManager::BrowserListObserver::OnBrowserSetLastActive( |
1475 Browser* browser) { | 1492 Browser* browser) { |
1476 // If all browsers are being closed (e.g. the user is in the process of | 1493 // If all browsers are being closed (e.g. the user is in the process of |
1477 // shutting down), this event will be fired after each browser is | 1494 // shutting down), this event will be fired after each browser is |
1478 // closed. This does not represent a user intention to change the active | 1495 // closed. This does not represent a user intention to change the active |
1479 // browser so is not handled here. | 1496 // browser so is not handled here. |
1480 if (profile_manager_->closing_all_browsers_) | 1497 if (profile_manager_->closing_all_browsers_) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1513 | 1530 |
1514 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); | 1531 FinishDeletingProfile(profile_to_delete_path, new_active_profile_path); |
1515 if (!original_callback.is_null()) | 1532 if (!original_callback.is_null()) |
1516 original_callback.Run(loaded_profile, status); | 1533 original_callback.Run(loaded_profile, status); |
1517 } | 1534 } |
1518 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 1535 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
1519 | 1536 |
1520 ProfileManagerWithoutInit::ProfileManagerWithoutInit( | 1537 ProfileManagerWithoutInit::ProfileManagerWithoutInit( |
1521 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { | 1538 const base::FilePath& user_data_dir) : ProfileManager(user_data_dir) { |
1522 } | 1539 } |
OLD | NEW |