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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 | 495 |
496 void ProfileImpl::DoFinalInit() { | 496 void ProfileImpl::DoFinalInit() { |
497 TRACE_EVENT0("browser", "ProfileImpl::DoFinalInit") | 497 TRACE_EVENT0("browser", "ProfileImpl::DoFinalInit") |
498 PrefService* prefs = GetPrefs(); | 498 PrefService* prefs = GetPrefs(); |
499 pref_change_registrar_.Init(prefs); | 499 pref_change_registrar_.Init(prefs); |
500 pref_change_registrar_.Add( | 500 pref_change_registrar_.Add( |
501 prefs::kGoogleServicesUsername, | 501 prefs::kGoogleServicesUsername, |
502 base::Bind(&ProfileImpl::UpdateProfileUserNameCache, | 502 base::Bind(&ProfileImpl::UpdateProfileUserNameCache, |
503 base::Unretained(this))); | 503 base::Unretained(this))); |
504 pref_change_registrar_.Add( | 504 pref_change_registrar_.Add( |
| 505 prefs::kManagedUserId, |
| 506 base::Bind(&ProfileImpl::UpdateProfileManagedUserIdCache, |
| 507 base::Unretained(this))); |
| 508 pref_change_registrar_.Add( |
505 prefs::kDefaultZoomLevel, | 509 prefs::kDefaultZoomLevel, |
506 base::Bind(&ProfileImpl::OnDefaultZoomLevelChanged, | 510 base::Bind(&ProfileImpl::OnDefaultZoomLevelChanged, |
507 base::Unretained(this))); | 511 base::Unretained(this))); |
508 pref_change_registrar_.Add( | 512 pref_change_registrar_.Add( |
509 prefs::kProfileAvatarIndex, | 513 prefs::kProfileAvatarIndex, |
510 base::Bind(&ProfileImpl::UpdateProfileAvatarCache, | 514 base::Bind(&ProfileImpl::UpdateProfileAvatarCache, |
511 base::Unretained(this))); | 515 base::Unretained(this))); |
512 pref_change_registrar_.Add( | 516 pref_change_registrar_.Add( |
513 prefs::kProfileName, | 517 prefs::kProfileName, |
514 base::Bind(&ProfileImpl::UpdateProfileNameCache, | 518 base::Bind(&ProfileImpl::UpdateProfileNameCache, |
(...skipping 10 matching lines...) Expand all Loading... |
525 // Always create the cache directory asynchronously. | 529 // Always create the cache directory asynchronously. |
526 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner = | 530 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner = |
527 JsonPrefStore::GetTaskRunnerForFile(base_cache_path_, | 531 JsonPrefStore::GetTaskRunnerForFile(base_cache_path_, |
528 BrowserThread::GetBlockingPool()); | 532 BrowserThread::GetBlockingPool()); |
529 CreateProfileDirectory(sequenced_task_runner.get(), base_cache_path_); | 533 CreateProfileDirectory(sequenced_task_runner.get(), base_cache_path_); |
530 | 534 |
531 // Now that the profile is hooked up to receive pref change notifications to | 535 // Now that the profile is hooked up to receive pref change notifications to |
532 // kGoogleServicesUsername, initialize components that depend on it to reflect | 536 // kGoogleServicesUsername, initialize components that depend on it to reflect |
533 // the current value. | 537 // the current value. |
534 UpdateProfileUserNameCache(); | 538 UpdateProfileUserNameCache(); |
| 539 UpdateProfileManagedUserIdCache(); |
535 UpdateProfileIsEphemeralCache(); | 540 UpdateProfileIsEphemeralCache(); |
536 GAIAInfoUpdateServiceFactory::GetForProfile(this); | 541 GAIAInfoUpdateServiceFactory::GetForProfile(this); |
537 | 542 |
538 PrefService* local_state = g_browser_process->local_state(); | 543 PrefService* local_state = g_browser_process->local_state(); |
539 ssl_config_service_manager_.reset( | 544 ssl_config_service_manager_.reset( |
540 SSLConfigServiceManager::CreateDefaultManager(local_state)); | 545 SSLConfigServiceManager::CreateDefaultManager(local_state)); |
541 | 546 |
542 // Initialize the BackgroundModeManager - this has to be done here before | 547 // Initialize the BackgroundModeManager - this has to be done here before |
543 // InitExtensions() is called because it relies on receiving notifications | 548 // InitExtensions() is called because it relies on receiving notifications |
544 // when extensions are loaded. BackgroundModeManager is not needed under | 549 // when extensions are loaded. BackgroundModeManager is not needed under |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 1249 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
1245 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); | 1250 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); |
1246 if (index != std::string::npos) { | 1251 if (index != std::string::npos) { |
1247 std::string user_name = | 1252 std::string user_name = |
1248 GetPrefs()->GetString(prefs::kGoogleServicesUsername); | 1253 GetPrefs()->GetString(prefs::kGoogleServicesUsername); |
1249 cache.SetUserNameOfProfileAtIndex(index, base::UTF8ToUTF16(user_name)); | 1254 cache.SetUserNameOfProfileAtIndex(index, base::UTF8ToUTF16(user_name)); |
1250 ProfileMetrics::UpdateReportedProfilesStatistics(profile_manager); | 1255 ProfileMetrics::UpdateReportedProfilesStatistics(profile_manager); |
1251 } | 1256 } |
1252 } | 1257 } |
1253 | 1258 |
| 1259 void ProfileImpl::UpdateProfileManagedUserIdCache() { |
| 1260 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 1261 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
| 1262 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); |
| 1263 if (index != std::string::npos) { |
| 1264 std::string managed_user_id = GetPrefs()->GetString(prefs::kManagedUserId); |
| 1265 cache.SetManagedUserIdOfProfileAtIndex(index, managed_user_id); |
| 1266 ProfileMetrics::UpdateReportedProfilesStatistics(profile_manager); |
| 1267 } |
| 1268 } |
| 1269 |
1254 void ProfileImpl::UpdateProfileNameCache() { | 1270 void ProfileImpl::UpdateProfileNameCache() { |
1255 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1271 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
1256 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 1272 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
1257 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); | 1273 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); |
1258 if (index != std::string::npos) { | 1274 if (index != std::string::npos) { |
1259 std::string profile_name = | 1275 std::string profile_name = |
1260 GetPrefs()->GetString(prefs::kProfileName); | 1276 GetPrefs()->GetString(prefs::kProfileName); |
1261 cache.SetNameOfProfileAtIndex(index, base::UTF8ToUTF16(profile_name)); | 1277 cache.SetNameOfProfileAtIndex(index, base::UTF8ToUTF16(profile_name)); |
1262 } | 1278 } |
1263 } | 1279 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1303 PrefProxyConfigTracker* ProfileImpl::CreateProxyConfigTracker() { | 1319 PrefProxyConfigTracker* ProfileImpl::CreateProxyConfigTracker() { |
1304 #if defined(OS_CHROMEOS) | 1320 #if defined(OS_CHROMEOS) |
1305 if (chromeos::ProfileHelper::IsSigninProfile(this)) { | 1321 if (chromeos::ProfileHelper::IsSigninProfile(this)) { |
1306 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( | 1322 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( |
1307 g_browser_process->local_state()); | 1323 g_browser_process->local_state()); |
1308 } | 1324 } |
1309 #endif // defined(OS_CHROMEOS) | 1325 #endif // defined(OS_CHROMEOS) |
1310 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( | 1326 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( |
1311 GetPrefs(), g_browser_process->local_state()); | 1327 GetPrefs(), g_browser_process->local_state()); |
1312 } | 1328 } |
OLD | NEW |