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_impl.h" | 5 #include "chrome/browser/profiles/profile_impl.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 #include "chrome/browser/profiles/gaia_info_update_service_factory.h" | 62 #include "chrome/browser/profiles/gaia_info_update_service_factory.h" |
63 #include "chrome/browser/profiles/profile_destroyer.h" | 63 #include "chrome/browser/profiles/profile_destroyer.h" |
64 #include "chrome/browser/profiles/profile_info_cache.h" | 64 #include "chrome/browser/profiles/profile_info_cache.h" |
65 #include "chrome/browser/profiles/profile_manager.h" | 65 #include "chrome/browser/profiles/profile_manager.h" |
66 #include "chrome/browser/profiles/profile_metrics.h" | 66 #include "chrome/browser/profiles/profile_metrics.h" |
67 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 67 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
68 #include "chrome/browser/services/gcm/gcm_profile_service.h" | 68 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
69 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 69 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
70 #include "chrome/browser/services/gcm/push_messaging_service_impl.h" | 70 #include "chrome/browser/services/gcm/push_messaging_service_impl.h" |
71 #include "chrome/browser/sessions/session_service_factory.h" | 71 #include "chrome/browser/sessions/session_service_factory.h" |
| 72 #include "chrome/browser/signin/signin_manager_factory.h" |
72 #include "chrome/browser/signin/signin_ui_util.h" | 73 #include "chrome/browser/signin/signin_ui_util.h" |
73 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" | 74 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" |
74 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h" | 75 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h" |
75 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 76 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
76 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" | 77 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" |
77 #include "chrome/browser/ui/zoom/zoom_event_manager.h" | 78 #include "chrome/browser/ui/zoom/zoom_event_manager.h" |
78 #include "chrome/common/chrome_constants.h" | 79 #include "chrome/common/chrome_constants.h" |
79 #include "chrome/common/chrome_paths_internal.h" | 80 #include "chrome/common/chrome_paths_internal.h" |
80 #include "chrome/common/chrome_switches.h" | 81 #include "chrome/common/chrome_switches.h" |
81 #include "chrome/common/chrome_version_info.h" | 82 #include "chrome/common/chrome_version_info.h" |
82 #include "chrome/common/pref_names.h" | 83 #include "chrome/common/pref_names.h" |
83 #include "chrome/common/url_constants.h" | 84 #include "chrome/common/url_constants.h" |
84 #include "chrome/grit/chromium_strings.h" | 85 #include "chrome/grit/chromium_strings.h" |
85 #include "components/bookmarks/browser/bookmark_model.h" | 86 #include "components/bookmarks/browser/bookmark_model.h" |
86 #include "components/content_settings/core/browser/host_content_settings_map.h" | 87 #include "components/content_settings/core/browser/host_content_settings_map.h" |
87 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref
s.h" | 88 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref
s.h" |
88 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" | 89 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" |
89 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat
istics_prefs.h" | 90 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat
istics_prefs.h" |
90 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" | 91 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" |
91 #include "components/domain_reliability/monitor.h" | 92 #include "components/domain_reliability/monitor.h" |
92 #include "components/domain_reliability/service.h" | 93 #include "components/domain_reliability/service.h" |
93 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 94 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
94 #include "components/metrics/metrics_service.h" | 95 #include "components/metrics/metrics_service.h" |
95 #include "components/pref_registry/pref_registry_syncable.h" | 96 #include "components/pref_registry/pref_registry_syncable.h" |
| 97 #include "components/signin/core/browser/signin_manager.h" |
96 #include "components/startup_metric_utils/startup_metric_utils.h" | 98 #include "components/startup_metric_utils/startup_metric_utils.h" |
97 #include "components/url_fixer/url_fixer.h" | 99 #include "components/url_fixer/url_fixer.h" |
98 #include "components/user_prefs/user_prefs.h" | 100 #include "components/user_prefs/user_prefs.h" |
99 #include "content/public/browser/browser_thread.h" | 101 #include "content/public/browser/browser_thread.h" |
100 #include "content/public/browser/dom_storage_context.h" | 102 #include "content/public/browser/dom_storage_context.h" |
101 #include "content/public/browser/notification_service.h" | 103 #include "content/public/browser/notification_service.h" |
102 #include "content/public/browser/render_process_host.h" | 104 #include "content/public/browser/render_process_host.h" |
103 #include "content/public/browser/storage_partition.h" | 105 #include "content/public/browser/storage_partition.h" |
104 #include "content/public/browser/url_data_source.h" | 106 #include "content/public/browser/url_data_source.h" |
105 #include "content/public/browser/user_metrics.h" | 107 #include "content/public/browser/user_metrics.h" |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 // Prefs were loaded synchronously so we can continue directly. | 523 // Prefs were loaded synchronously so we can continue directly. |
522 OnPrefsLoaded(true); | 524 OnPrefsLoaded(true); |
523 } | 525 } |
524 } | 526 } |
525 | 527 |
526 void ProfileImpl::DoFinalInit() { | 528 void ProfileImpl::DoFinalInit() { |
527 TRACE_EVENT0("browser", "ProfileImpl::DoFinalInit") | 529 TRACE_EVENT0("browser", "ProfileImpl::DoFinalInit") |
528 PrefService* prefs = GetPrefs(); | 530 PrefService* prefs = GetPrefs(); |
529 pref_change_registrar_.Init(prefs); | 531 pref_change_registrar_.Init(prefs); |
530 pref_change_registrar_.Add( | 532 pref_change_registrar_.Add( |
531 prefs::kGoogleServicesUsername, | |
532 base::Bind(&ProfileImpl::UpdateProfileUserNameCache, | |
533 base::Unretained(this))); | |
534 pref_change_registrar_.Add( | |
535 prefs::kSupervisedUserId, | 533 prefs::kSupervisedUserId, |
536 base::Bind(&ProfileImpl::UpdateProfileSupervisedUserIdCache, | 534 base::Bind(&ProfileImpl::UpdateProfileSupervisedUserIdCache, |
537 base::Unretained(this))); | 535 base::Unretained(this))); |
538 | 536 |
539 // Changes in the profile avatar. | 537 // Changes in the profile avatar. |
540 pref_change_registrar_.Add( | 538 pref_change_registrar_.Add( |
541 prefs::kProfileAvatarIndex, | 539 prefs::kProfileAvatarIndex, |
542 base::Bind(&ProfileImpl::UpdateProfileAvatarCache, | 540 base::Bind(&ProfileImpl::UpdateProfileAvatarCache, |
543 base::Unretained(this))); | 541 base::Unretained(this))); |
544 pref_change_registrar_.Add( | 542 pref_change_registrar_.Add( |
(...skipping 23 matching lines...) Expand all Loading... |
568 // It would be nice to use PathService for fetching this directory, but | 566 // It would be nice to use PathService for fetching this directory, but |
569 // the cache directory depends on the profile directory, which isn't available | 567 // the cache directory depends on the profile directory, which isn't available |
570 // to PathService. | 568 // to PathService. |
571 chrome::GetUserCacheDirectory(path_, &base_cache_path_); | 569 chrome::GetUserCacheDirectory(path_, &base_cache_path_); |
572 // Always create the cache directory asynchronously. | 570 // Always create the cache directory asynchronously. |
573 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner = | 571 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner = |
574 JsonPrefStore::GetTaskRunnerForFile(base_cache_path_, | 572 JsonPrefStore::GetTaskRunnerForFile(base_cache_path_, |
575 BrowserThread::GetBlockingPool()); | 573 BrowserThread::GetBlockingPool()); |
576 CreateProfileDirectory(sequenced_task_runner.get(), base_cache_path_); | 574 CreateProfileDirectory(sequenced_task_runner.get(), base_cache_path_); |
577 | 575 |
578 // Now that the profile is hooked up to receive pref change notifications to | 576 // Initialize components that depend on the current value. |
579 // kGoogleServicesUsername, initialize components that depend on it to reflect | |
580 // the current value. | |
581 UpdateProfileUserNameCache(); | |
582 UpdateProfileSupervisedUserIdCache(); | 577 UpdateProfileSupervisedUserIdCache(); |
583 UpdateProfileIsEphemeralCache(); | 578 UpdateProfileIsEphemeralCache(); |
584 GAIAInfoUpdateServiceFactory::GetForProfile(this); | 579 GAIAInfoUpdateServiceFactory::GetForProfile(this); |
585 | 580 |
586 PrefService* local_state = g_browser_process->local_state(); | 581 PrefService* local_state = g_browser_process->local_state(); |
587 ssl_config_service_manager_.reset( | 582 ssl_config_service_manager_.reset( |
588 SSLConfigServiceManager::CreateDefaultManager(local_state)); | 583 SSLConfigServiceManager::CreateDefaultManager(local_state)); |
589 | 584 |
590 #if defined(ENABLE_BACKGROUND) | 585 #if defined(ENABLE_BACKGROUND) |
591 // Initialize the BackgroundModeManager - this has to be done here before | 586 // Initialize the BackgroundModeManager - this has to be done here before |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 | 829 |
835 if (host_content_settings_map_.get()) | 830 if (host_content_settings_map_.get()) |
836 host_content_settings_map_->ShutdownOnUIThread(); | 831 host_content_settings_map_->ShutdownOnUIThread(); |
837 | 832 |
838 // This causes the Preferences file to be written to disk. | 833 // This causes the Preferences file to be written to disk. |
839 if (prefs_loaded) | 834 if (prefs_loaded) |
840 SetExitType(EXIT_NORMAL); | 835 SetExitType(EXIT_NORMAL); |
841 } | 836 } |
842 | 837 |
843 std::string ProfileImpl::GetProfileName() { | 838 std::string ProfileImpl::GetProfileName() { |
844 return GetPrefs()->GetString(prefs::kGoogleServicesUsername); | 839 SigninManagerBase* signin_manager = |
| 840 SigninManagerFactory::GetForProfile(this); |
| 841 if (signin_manager) |
| 842 return signin_manager->GetAuthenticatedUsername(); |
| 843 |
| 844 return std::string(); |
845 } | 845 } |
846 | 846 |
847 Profile::ProfileType ProfileImpl::GetProfileType() const { | 847 Profile::ProfileType ProfileImpl::GetProfileType() const { |
848 return REGULAR_PROFILE; | 848 return REGULAR_PROFILE; |
849 } | 849 } |
850 | 850 |
851 scoped_ptr<content::ZoomLevelDelegate> | 851 scoped_ptr<content::ZoomLevelDelegate> |
852 ProfileImpl::CreateZoomLevelDelegate(const base::FilePath& partition_path) { | 852 ProfileImpl::CreateZoomLevelDelegate(const base::FilePath& partition_path) { |
853 return make_scoped_ptr(new chrome::ChromeZoomLevelPrefs( | 853 return make_scoped_ptr(new chrome::ChromeZoomLevelPrefs( |
854 GetPrefs(), GetPath(), partition_path, | 854 GetPrefs(), GetPath(), partition_path, |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 | 1319 |
1320 if (GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage)) | 1320 if (GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage)) |
1321 return GURL(chrome::kChromeUINewTabURL); | 1321 return GURL(chrome::kChromeUINewTabURL); |
1322 GURL home_page(url_fixer::FixupURL(GetPrefs()->GetString(prefs::kHomePage), | 1322 GURL home_page(url_fixer::FixupURL(GetPrefs()->GetString(prefs::kHomePage), |
1323 std::string())); | 1323 std::string())); |
1324 if (!home_page.is_valid()) | 1324 if (!home_page.is_valid()) |
1325 return GURL(chrome::kChromeUINewTabURL); | 1325 return GURL(chrome::kChromeUINewTabURL); |
1326 return home_page; | 1326 return home_page; |
1327 } | 1327 } |
1328 | 1328 |
1329 void ProfileImpl::UpdateProfileUserNameCache() { | |
1330 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
1331 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | |
1332 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); | |
1333 if (index != std::string::npos) { | |
1334 std::string user_name = | |
1335 GetPrefs()->GetString(prefs::kGoogleServicesUsername); | |
1336 cache.SetUserNameOfProfileAtIndex(index, base::UTF8ToUTF16(user_name)); | |
1337 ProfileMetrics::UpdateReportedProfilesStatistics(profile_manager); | |
1338 } | |
1339 } | |
1340 | |
1341 void ProfileImpl::UpdateProfileSupervisedUserIdCache() { | 1329 void ProfileImpl::UpdateProfileSupervisedUserIdCache() { |
1342 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1330 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
1343 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 1331 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
1344 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); | 1332 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); |
1345 if (index != std::string::npos) { | 1333 if (index != std::string::npos) { |
1346 std::string supervised_user_id = | 1334 std::string supervised_user_id = |
1347 GetPrefs()->GetString(prefs::kSupervisedUserId); | 1335 GetPrefs()->GetString(prefs::kSupervisedUserId); |
1348 cache.SetSupervisedUserIdOfProfileAtIndex(index, supervised_user_id); | 1336 cache.SetSupervisedUserIdOfProfileAtIndex(index, supervised_user_id); |
1349 ProfileMetrics::UpdateReportedProfilesStatistics(profile_manager); | 1337 ProfileMetrics::UpdateReportedProfilesStatistics(profile_manager); |
1350 } | 1338 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1423 ProfileImpl::CreateDomainReliabilityMonitor(PrefService* local_state) { | 1411 ProfileImpl::CreateDomainReliabilityMonitor(PrefService* local_state) { |
1424 domain_reliability::DomainReliabilityService* service = | 1412 domain_reliability::DomainReliabilityService* service = |
1425 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> | 1413 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> |
1426 GetForBrowserContext(this); | 1414 GetForBrowserContext(this); |
1427 if (!service) | 1415 if (!service) |
1428 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>(); | 1416 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>(); |
1429 | 1417 |
1430 return service->CreateMonitor( | 1418 return service->CreateMonitor( |
1431 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 1419 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
1432 } | 1420 } |
OLD | NEW |