| 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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 true, | 329 true, |
| 330 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 330 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 331 registry->RegisterBooleanPref( | 331 registry->RegisterBooleanPref( |
| 332 prefs::kForceSafeSearch, | 332 prefs::kForceSafeSearch, |
| 333 false, | 333 false, |
| 334 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 334 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 335 registry->RegisterIntegerPref( | 335 registry->RegisterIntegerPref( |
| 336 prefs::kProfileAvatarIndex, | 336 prefs::kProfileAvatarIndex, |
| 337 -1, | 337 -1, |
| 338 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 338 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 339 registry->RegisterStringPref(prefs::kManagedUserId, | 339 registry->RegisterStringPref(prefs::kSupervisedUserId, |
| 340 std::string(), | 340 std::string(), |
| 341 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 341 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 342 registry->RegisterStringPref(prefs::kProfileName, | 342 registry->RegisterStringPref(prefs::kProfileName, |
| 343 std::string(), | 343 std::string(), |
| 344 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 344 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 345 registry->RegisterBooleanPref( | 345 registry->RegisterBooleanPref( |
| 346 prefs::kProfileIsManaged, | 346 prefs::kProfileIsSupervised, |
| 347 false, | 347 false, |
| 348 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 348 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 349 registry->RegisterStringPref(prefs::kHomePage, | 349 registry->RegisterStringPref(prefs::kHomePage, |
| 350 std::string(), | 350 std::string(), |
| 351 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 351 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 352 #if defined(ENABLE_PRINTING) | 352 #if defined(ENABLE_PRINTING) |
| 353 registry->RegisterBooleanPref( | 353 registry->RegisterBooleanPref( |
| 354 prefs::kPrintingEnabled, | 354 prefs::kPrintingEnabled, |
| 355 true, | 355 true, |
| 356 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 356 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 | 501 |
| 502 void ProfileImpl::DoFinalInit() { | 502 void ProfileImpl::DoFinalInit() { |
| 503 TRACE_EVENT0("browser", "ProfileImpl::DoFinalInit") | 503 TRACE_EVENT0("browser", "ProfileImpl::DoFinalInit") |
| 504 PrefService* prefs = GetPrefs(); | 504 PrefService* prefs = GetPrefs(); |
| 505 pref_change_registrar_.Init(prefs); | 505 pref_change_registrar_.Init(prefs); |
| 506 pref_change_registrar_.Add( | 506 pref_change_registrar_.Add( |
| 507 prefs::kGoogleServicesUsername, | 507 prefs::kGoogleServicesUsername, |
| 508 base::Bind(&ProfileImpl::UpdateProfileUserNameCache, | 508 base::Bind(&ProfileImpl::UpdateProfileUserNameCache, |
| 509 base::Unretained(this))); | 509 base::Unretained(this))); |
| 510 pref_change_registrar_.Add( | 510 pref_change_registrar_.Add( |
| 511 prefs::kManagedUserId, | 511 prefs::kSupervisedUserId, |
| 512 base::Bind(&ProfileImpl::UpdateProfileManagedUserIdCache, | 512 base::Bind(&ProfileImpl::UpdateProfileSupervisedUserIdCache, |
| 513 base::Unretained(this))); | 513 base::Unretained(this))); |
| 514 pref_change_registrar_.Add( | 514 pref_change_registrar_.Add( |
| 515 prefs::kDefaultZoomLevel, | 515 prefs::kDefaultZoomLevel, |
| 516 base::Bind(&ProfileImpl::OnDefaultZoomLevelChanged, | 516 base::Bind(&ProfileImpl::OnDefaultZoomLevelChanged, |
| 517 base::Unretained(this))); | 517 base::Unretained(this))); |
| 518 pref_change_registrar_.Add( | 518 pref_change_registrar_.Add( |
| 519 prefs::kProfileAvatarIndex, | 519 prefs::kProfileAvatarIndex, |
| 520 base::Bind(&ProfileImpl::UpdateProfileAvatarCache, | 520 base::Bind(&ProfileImpl::UpdateProfileAvatarCache, |
| 521 base::Unretained(this))); | 521 base::Unretained(this))); |
| 522 pref_change_registrar_.Add( | 522 pref_change_registrar_.Add( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 535 // Always create the cache directory asynchronously. | 535 // Always create the cache directory asynchronously. |
| 536 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner = | 536 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner = |
| 537 JsonPrefStore::GetTaskRunnerForFile(base_cache_path_, | 537 JsonPrefStore::GetTaskRunnerForFile(base_cache_path_, |
| 538 BrowserThread::GetBlockingPool()); | 538 BrowserThread::GetBlockingPool()); |
| 539 CreateProfileDirectory(sequenced_task_runner.get(), base_cache_path_); | 539 CreateProfileDirectory(sequenced_task_runner.get(), base_cache_path_); |
| 540 | 540 |
| 541 // Now that the profile is hooked up to receive pref change notifications to | 541 // Now that the profile is hooked up to receive pref change notifications to |
| 542 // kGoogleServicesUsername, initialize components that depend on it to reflect | 542 // kGoogleServicesUsername, initialize components that depend on it to reflect |
| 543 // the current value. | 543 // the current value. |
| 544 UpdateProfileUserNameCache(); | 544 UpdateProfileUserNameCache(); |
| 545 UpdateProfileManagedUserIdCache(); | 545 UpdateProfileSupervisedUserIdCache(); |
| 546 UpdateProfileIsEphemeralCache(); | 546 UpdateProfileIsEphemeralCache(); |
| 547 GAIAInfoUpdateServiceFactory::GetForProfile(this); | 547 GAIAInfoUpdateServiceFactory::GetForProfile(this); |
| 548 | 548 |
| 549 PrefService* local_state = g_browser_process->local_state(); | 549 PrefService* local_state = g_browser_process->local_state(); |
| 550 ssl_config_service_manager_.reset( | 550 ssl_config_service_manager_.reset( |
| 551 SSLConfigServiceManager::CreateDefaultManager(local_state)); | 551 SSLConfigServiceManager::CreateDefaultManager(local_state)); |
| 552 | 552 |
| 553 // Initialize the BackgroundModeManager - this has to be done here before | 553 // Initialize the BackgroundModeManager - this has to be done here before |
| 554 // InitExtensions() is called because it relies on receiving notifications | 554 // InitExtensions() is called because it relies on receiving notifications |
| 555 // when extensions are loaded. BackgroundModeManager is not needed under | 555 // when extensions are loaded. BackgroundModeManager is not needed under |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 } | 794 } |
| 795 | 795 |
| 796 bool ProfileImpl::HasOffTheRecordProfile() { | 796 bool ProfileImpl::HasOffTheRecordProfile() { |
| 797 return off_the_record_profile_.get() != NULL; | 797 return off_the_record_profile_.get() != NULL; |
| 798 } | 798 } |
| 799 | 799 |
| 800 Profile* ProfileImpl::GetOriginalProfile() { | 800 Profile* ProfileImpl::GetOriginalProfile() { |
| 801 return this; | 801 return this; |
| 802 } | 802 } |
| 803 | 803 |
| 804 bool ProfileImpl::IsManaged() { | 804 bool ProfileImpl::IsSupervised() { |
| 805 return !GetPrefs()->GetString(prefs::kManagedUserId).empty(); | 805 return !GetPrefs()->GetString(prefs::kSupervisedUserId).empty(); |
| 806 } | 806 } |
| 807 | 807 |
| 808 ExtensionService* ProfileImpl::GetExtensionService() { | 808 ExtensionService* ProfileImpl::GetExtensionService() { |
| 809 return extensions::ExtensionSystem::Get(this)->extension_service(); | 809 return extensions::ExtensionSystem::Get(this)->extension_service(); |
| 810 } | 810 } |
| 811 | 811 |
| 812 ExtensionSpecialStoragePolicy* | 812 ExtensionSpecialStoragePolicy* |
| 813 ProfileImpl::GetExtensionSpecialStoragePolicy() { | 813 ProfileImpl::GetExtensionSpecialStoragePolicy() { |
| 814 if (!extension_special_storage_policy_.get()) { | 814 if (!extension_special_storage_policy_.get()) { |
| 815 TRACE_EVENT0("browser", "ProfileImpl::GetExtensionSpecialStoragePolicy") | 815 TRACE_EVENT0("browser", "ProfileImpl::GetExtensionSpecialStoragePolicy") |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1296 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 1296 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
| 1297 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); | 1297 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); |
| 1298 if (index != std::string::npos) { | 1298 if (index != std::string::npos) { |
| 1299 std::string user_name = | 1299 std::string user_name = |
| 1300 GetPrefs()->GetString(prefs::kGoogleServicesUsername); | 1300 GetPrefs()->GetString(prefs::kGoogleServicesUsername); |
| 1301 cache.SetUserNameOfProfileAtIndex(index, base::UTF8ToUTF16(user_name)); | 1301 cache.SetUserNameOfProfileAtIndex(index, base::UTF8ToUTF16(user_name)); |
| 1302 ProfileMetrics::UpdateReportedProfilesStatistics(profile_manager); | 1302 ProfileMetrics::UpdateReportedProfilesStatistics(profile_manager); |
| 1303 } | 1303 } |
| 1304 } | 1304 } |
| 1305 | 1305 |
| 1306 void ProfileImpl::UpdateProfileManagedUserIdCache() { | 1306 void ProfileImpl::UpdateProfileSupervisedUserIdCache() { |
| 1307 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1307 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 1308 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 1308 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
| 1309 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); | 1309 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); |
| 1310 if (index != std::string::npos) { | 1310 if (index != std::string::npos) { |
| 1311 std::string managed_user_id = GetPrefs()->GetString(prefs::kManagedUserId); | 1311 std::string supervised_user_id = |
| 1312 cache.SetManagedUserIdOfProfileAtIndex(index, managed_user_id); | 1312 GetPrefs()->GetString(prefs::kSupervisedUserId); |
| 1313 cache.SetSupervisedUserIdOfProfileAtIndex(index, supervised_user_id); |
| 1313 ProfileMetrics::UpdateReportedProfilesStatistics(profile_manager); | 1314 ProfileMetrics::UpdateReportedProfilesStatistics(profile_manager); |
| 1314 } | 1315 } |
| 1315 } | 1316 } |
| 1316 | 1317 |
| 1317 void ProfileImpl::UpdateProfileNameCache() { | 1318 void ProfileImpl::UpdateProfileNameCache() { |
| 1318 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1319 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 1319 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 1320 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
| 1320 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); | 1321 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); |
| 1321 if (index != std::string::npos) { | 1322 if (index != std::string::npos) { |
| 1322 std::string profile_name = | 1323 std::string profile_name = |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 PrefProxyConfigTracker* ProfileImpl::CreateProxyConfigTracker() { | 1367 PrefProxyConfigTracker* ProfileImpl::CreateProxyConfigTracker() { |
| 1367 #if defined(OS_CHROMEOS) | 1368 #if defined(OS_CHROMEOS) |
| 1368 if (chromeos::ProfileHelper::IsSigninProfile(this)) { | 1369 if (chromeos::ProfileHelper::IsSigninProfile(this)) { |
| 1369 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( | 1370 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( |
| 1370 g_browser_process->local_state()); | 1371 g_browser_process->local_state()); |
| 1371 } | 1372 } |
| 1372 #endif // defined(OS_CHROMEOS) | 1373 #endif // defined(OS_CHROMEOS) |
| 1373 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( | 1374 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( |
| 1374 GetPrefs(), g_browser_process->local_state()); | 1375 GetPrefs(), g_browser_process->local_state()); |
| 1375 } | 1376 } |
| OLD | NEW |