Chromium Code Reviews| 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 351 true, | 351 true, |
| 352 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 352 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 353 registry->RegisterBooleanPref( | 353 registry->RegisterBooleanPref( |
| 354 prefs::kForceSafeSearch, | 354 prefs::kForceSafeSearch, |
| 355 false, | 355 false, |
| 356 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 356 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 357 registry->RegisterIntegerPref( | 357 registry->RegisterIntegerPref( |
| 358 prefs::kProfileAvatarIndex, | 358 prefs::kProfileAvatarIndex, |
| 359 -1, | 359 -1, |
| 360 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 360 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 361 // Whether a profile is using an avatar without having explicitely chosen it | |
| 362 // (i.e. was assigned by default by legacy profile creation). | |
| 363 registry->RegisterBooleanPref( | |
| 364 prefs::kProfileUsingDefaultAvatar, | |
| 365 true, | |
| 366 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | |
| 367 registry->RegisterBooleanPref( | |
| 368 prefs::kProfileUsingGAIAAvatar, | |
| 369 false, | |
| 370 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | |
| 371 // Whether a profile is using a default avatar name (eg. Pickles or Person 1). | |
| 372 registry->RegisterIntegerPref( | |
| 373 prefs::kProfileUsingDefaultName, | |
| 374 -1, | |
| 375 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | |
|
Roger Tawa OOO till Jul 10th
2014/08/15 14:46:40
Should use enum for -1, 0, 1 values. However, the
noms (inactive)
2014/08/15 16:22:47
Done.
| |
| 361 registry->RegisterStringPref( | 376 registry->RegisterStringPref( |
| 362 prefs::kSupervisedUserId, | 377 prefs::kSupervisedUserId, |
| 363 std::string(), | 378 std::string(), |
| 364 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 379 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 365 registry->RegisterStringPref(prefs::kProfileName, | 380 registry->RegisterStringPref(prefs::kProfileName, |
| 366 std::string(), | 381 std::string(), |
| 367 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 382 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 368 registry->RegisterStringPref(prefs::kHomePage, | 383 registry->RegisterStringPref(prefs::kHomePage, |
| 369 std::string(), | 384 std::string(), |
| 370 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 385 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 533 base::Bind(&ProfileImpl::UpdateProfileUserNameCache, | 548 base::Bind(&ProfileImpl::UpdateProfileUserNameCache, |
| 534 base::Unretained(this))); | 549 base::Unretained(this))); |
| 535 pref_change_registrar_.Add( | 550 pref_change_registrar_.Add( |
| 536 prefs::kSupervisedUserId, | 551 prefs::kSupervisedUserId, |
| 537 base::Bind(&ProfileImpl::UpdateProfileSupervisedUserIdCache, | 552 base::Bind(&ProfileImpl::UpdateProfileSupervisedUserIdCache, |
| 538 base::Unretained(this))); | 553 base::Unretained(this))); |
| 539 pref_change_registrar_.Add( | 554 pref_change_registrar_.Add( |
| 540 prefs::kDefaultZoomLevel, | 555 prefs::kDefaultZoomLevel, |
| 541 base::Bind(&ProfileImpl::OnDefaultZoomLevelChanged, | 556 base::Bind(&ProfileImpl::OnDefaultZoomLevelChanged, |
| 542 base::Unretained(this))); | 557 base::Unretained(this))); |
| 558 | |
| 559 // Changes in the profile avatar. | |
| 543 pref_change_registrar_.Add( | 560 pref_change_registrar_.Add( |
| 544 prefs::kProfileAvatarIndex, | 561 prefs::kProfileAvatarIndex, |
| 545 base::Bind(&ProfileImpl::UpdateProfileAvatarCache, | 562 base::Bind(&ProfileImpl::UpdateProfileAvatarCache, |
| 546 base::Unretained(this))); | 563 base::Unretained(this))); |
| 547 pref_change_registrar_.Add( | 564 pref_change_registrar_.Add( |
| 565 prefs::kProfileUsingDefaultAvatar, | |
| 566 base::Bind(&ProfileImpl::UpdateProfileAvatarCache, | |
| 567 base::Unretained(this))); | |
| 568 pref_change_registrar_.Add( | |
| 569 prefs::kProfileUsingGAIAAvatar, | |
| 570 base::Bind(&ProfileImpl::UpdateProfileAvatarCache, | |
| 571 base::Unretained(this))); | |
| 572 | |
| 573 // Changes in the profile name. | |
| 574 pref_change_registrar_.Add( | |
| 575 prefs::kProfileUsingDefaultName, | |
| 576 base::Bind(&ProfileImpl::UpdateProfileNameCache, | |
| 577 base::Unretained(this))); | |
| 578 pref_change_registrar_.Add( | |
| 548 prefs::kProfileName, | 579 prefs::kProfileName, |
| 549 base::Bind(&ProfileImpl::UpdateProfileNameCache, | 580 base::Bind(&ProfileImpl::UpdateProfileNameCache, |
| 550 base::Unretained(this))); | 581 base::Unretained(this))); |
| 582 | |
| 551 pref_change_registrar_.Add( | 583 pref_change_registrar_.Add( |
| 552 prefs::kForceEphemeralProfiles, | 584 prefs::kForceEphemeralProfiles, |
| 553 base::Bind(&ProfileImpl::UpdateProfileIsEphemeralCache, | 585 base::Bind(&ProfileImpl::UpdateProfileIsEphemeralCache, |
| 554 base::Unretained(this))); | 586 base::Unretained(this))); |
| 555 | 587 |
| 556 // It would be nice to use PathService for fetching this directory, but | 588 // It would be nice to use PathService for fetching this directory, but |
| 557 // the cache directory depends on the profile directory, which isn't available | 589 // the cache directory depends on the profile directory, which isn't available |
| 558 // to PathService. | 590 // to PathService. |
| 559 chrome::GetUserCacheDirectory(path_, &base_cache_path_); | 591 chrome::GetUserCacheDirectory(path_, &base_cache_path_); |
| 560 // Always create the cache directory asynchronously. | 592 // Always create the cache directory asynchronously. |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1350 } | 1382 } |
| 1351 | 1383 |
| 1352 void ProfileImpl::UpdateProfileNameCache() { | 1384 void ProfileImpl::UpdateProfileNameCache() { |
| 1353 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1385 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 1354 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 1386 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
| 1355 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); | 1387 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); |
| 1356 if (index != std::string::npos) { | 1388 if (index != std::string::npos) { |
| 1357 std::string profile_name = | 1389 std::string profile_name = |
| 1358 GetPrefs()->GetString(prefs::kProfileName); | 1390 GetPrefs()->GetString(prefs::kProfileName); |
| 1359 cache.SetNameOfProfileAtIndex(index, base::UTF8ToUTF16(profile_name)); | 1391 cache.SetNameOfProfileAtIndex(index, base::UTF8ToUTF16(profile_name)); |
| 1392 int default_name = | |
| 1393 GetPrefs()->GetInteger(prefs::kProfileUsingDefaultName); | |
| 1394 // A value of -1 means that the user has not specifically chosen to | |
| 1395 // use one of the default names (i.e. hasn't renamed the profile to | |
| 1396 // Pickles on purpose). | |
| 1397 cache.SetProfileIsUsingDefaultNameAtIndex(index, (default_name == -1)); | |
| 1360 } | 1398 } |
| 1361 } | 1399 } |
| 1362 | 1400 |
| 1363 void ProfileImpl::UpdateProfileAvatarCache() { | 1401 void ProfileImpl::UpdateProfileAvatarCache() { |
| 1364 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1402 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 1365 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 1403 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
| 1366 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); | 1404 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); |
| 1367 if (index != std::string::npos) { | 1405 if (index != std::string::npos) { |
| 1368 size_t avatar_index = | 1406 size_t avatar_index = |
| 1369 GetPrefs()->GetInteger(prefs::kProfileAvatarIndex); | 1407 GetPrefs()->GetInteger(prefs::kProfileAvatarIndex); |
| 1370 cache.SetAvatarIconOfProfileAtIndex(index, avatar_index); | 1408 cache.SetAvatarIconOfProfileAtIndex(index, avatar_index); |
| 1409 bool default_avatar = | |
| 1410 GetPrefs()->GetBoolean(prefs::kProfileUsingDefaultAvatar); | |
| 1411 cache.SetProfileIsUsingDefaultAvatarAtIndex(index, default_avatar); | |
| 1412 bool gaia_avatar = | |
| 1413 GetPrefs()->GetBoolean(prefs::kProfileUsingGAIAAvatar); | |
| 1414 cache.SetIsUsingGAIAPictureOfProfileAtIndex(index, gaia_avatar); | |
| 1371 } | 1415 } |
| 1372 } | 1416 } |
| 1373 | 1417 |
| 1374 void ProfileImpl::UpdateProfileIsEphemeralCache() { | 1418 void ProfileImpl::UpdateProfileIsEphemeralCache() { |
| 1375 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1419 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 1376 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 1420 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
| 1377 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); | 1421 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); |
| 1378 if (index != std::string::npos) { | 1422 if (index != std::string::npos) { |
| 1379 bool is_ephemeral = GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles); | 1423 bool is_ephemeral = GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles); |
| 1380 cache.SetProfileIsEphemeralAtIndex(index, is_ephemeral); | 1424 cache.SetProfileIsEphemeralAtIndex(index, is_ephemeral); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1413 ProfileImpl::CreateDomainReliabilityMonitor() { | 1457 ProfileImpl::CreateDomainReliabilityMonitor() { |
| 1414 domain_reliability::DomainReliabilityService* service = | 1458 domain_reliability::DomainReliabilityService* service = |
| 1415 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> | 1459 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> |
| 1416 GetForBrowserContext(this); | 1460 GetForBrowserContext(this); |
| 1417 if (!service) | 1461 if (!service) |
| 1418 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>(); | 1462 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>(); |
| 1419 | 1463 |
| 1420 return service->CreateMonitor( | 1464 return service->CreateMonitor( |
| 1421 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 1465 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
| 1422 } | 1466 } |
| OLD | NEW |