Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: chrome/browser/profiles/profile_impl.cc

Issue 476993002: [Profiles] Fix the usage of custom/default names and avatars (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: all rebase all the time Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 true, 352 true,
353 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 353 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
354 registry->RegisterBooleanPref( 354 registry->RegisterBooleanPref(
355 prefs::kForceSafeSearch, 355 prefs::kForceSafeSearch,
356 false, 356 false,
357 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 357 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
358 registry->RegisterIntegerPref( 358 registry->RegisterIntegerPref(
359 prefs::kProfileAvatarIndex, 359 prefs::kProfileAvatarIndex,
360 -1, 360 -1,
361 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 361 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
362 // Whether a profile is using an avatar without having explicitely chosen it
363 // (i.e. was assigned by default by legacy profile creation).
364 registry->RegisterBooleanPref(
365 prefs::kProfileUsingDefaultAvatar,
366 true,
367 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
368 registry->RegisterBooleanPref(
369 prefs::kProfileUsingGAIAAvatar,
370 false,
371 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
372 // Whether a profile is using a default avatar name (eg. Pickles or Person 1).
373 registry->RegisterBooleanPref(
374 prefs::kProfileUsingDefaultName,
375 true,
376 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
362 registry->RegisterStringPref( 377 registry->RegisterStringPref(
363 prefs::kSupervisedUserId, 378 prefs::kSupervisedUserId,
364 std::string(), 379 std::string(),
365 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); 380 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
366 registry->RegisterStringPref(prefs::kProfileName, 381 registry->RegisterStringPref(prefs::kProfileName,
367 std::string(), 382 std::string(),
368 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 383 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
369 registry->RegisterStringPref(prefs::kHomePage, 384 registry->RegisterStringPref(prefs::kHomePage,
370 std::string(), 385 std::string(),
371 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 386 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 base::Bind(&ProfileImpl::UpdateProfileUserNameCache, 549 base::Bind(&ProfileImpl::UpdateProfileUserNameCache,
535 base::Unretained(this))); 550 base::Unretained(this)));
536 pref_change_registrar_.Add( 551 pref_change_registrar_.Add(
537 prefs::kSupervisedUserId, 552 prefs::kSupervisedUserId,
538 base::Bind(&ProfileImpl::UpdateProfileSupervisedUserIdCache, 553 base::Bind(&ProfileImpl::UpdateProfileSupervisedUserIdCache,
539 base::Unretained(this))); 554 base::Unretained(this)));
540 pref_change_registrar_.Add( 555 pref_change_registrar_.Add(
541 prefs::kDefaultZoomLevel, 556 prefs::kDefaultZoomLevel,
542 base::Bind(&ProfileImpl::OnDefaultZoomLevelChanged, 557 base::Bind(&ProfileImpl::OnDefaultZoomLevelChanged,
543 base::Unretained(this))); 558 base::Unretained(this)));
559
560 // Changes in the profile avatar.
544 pref_change_registrar_.Add( 561 pref_change_registrar_.Add(
545 prefs::kProfileAvatarIndex, 562 prefs::kProfileAvatarIndex,
546 base::Bind(&ProfileImpl::UpdateProfileAvatarCache, 563 base::Bind(&ProfileImpl::UpdateProfileAvatarCache,
547 base::Unretained(this))); 564 base::Unretained(this)));
548 pref_change_registrar_.Add( 565 pref_change_registrar_.Add(
566 prefs::kProfileUsingDefaultAvatar,
567 base::Bind(&ProfileImpl::UpdateProfileAvatarCache,
568 base::Unretained(this)));
569 pref_change_registrar_.Add(
570 prefs::kProfileUsingGAIAAvatar,
571 base::Bind(&ProfileImpl::UpdateProfileAvatarCache,
572 base::Unretained(this)));
573
574 // Changes in the profile name.
575 pref_change_registrar_.Add(
576 prefs::kProfileUsingDefaultName,
577 base::Bind(&ProfileImpl::UpdateProfileNameCache,
578 base::Unretained(this)));
579 pref_change_registrar_.Add(
549 prefs::kProfileName, 580 prefs::kProfileName,
550 base::Bind(&ProfileImpl::UpdateProfileNameCache, 581 base::Bind(&ProfileImpl::UpdateProfileNameCache,
551 base::Unretained(this))); 582 base::Unretained(this)));
583
552 pref_change_registrar_.Add( 584 pref_change_registrar_.Add(
553 prefs::kForceEphemeralProfiles, 585 prefs::kForceEphemeralProfiles,
554 base::Bind(&ProfileImpl::UpdateProfileIsEphemeralCache, 586 base::Bind(&ProfileImpl::UpdateProfileIsEphemeralCache,
555 base::Unretained(this))); 587 base::Unretained(this)));
556 588
557 // It would be nice to use PathService for fetching this directory, but 589 // It would be nice to use PathService for fetching this directory, but
558 // the cache directory depends on the profile directory, which isn't available 590 // the cache directory depends on the profile directory, which isn't available
559 // to PathService. 591 // to PathService.
560 chrome::GetUserCacheDirectory(path_, &base_cache_path_); 592 chrome::GetUserCacheDirectory(path_, &base_cache_path_);
561 // Always create the cache directory asynchronously. 593 // Always create the cache directory asynchronously.
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
1355 } 1387 }
1356 1388
1357 void ProfileImpl::UpdateProfileNameCache() { 1389 void ProfileImpl::UpdateProfileNameCache() {
1358 ProfileManager* profile_manager = g_browser_process->profile_manager(); 1390 ProfileManager* profile_manager = g_browser_process->profile_manager();
1359 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); 1391 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
1360 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); 1392 size_t index = cache.GetIndexOfProfileWithPath(GetPath());
1361 if (index != std::string::npos) { 1393 if (index != std::string::npos) {
1362 std::string profile_name = 1394 std::string profile_name =
1363 GetPrefs()->GetString(prefs::kProfileName); 1395 GetPrefs()->GetString(prefs::kProfileName);
1364 cache.SetNameOfProfileAtIndex(index, base::UTF8ToUTF16(profile_name)); 1396 cache.SetNameOfProfileAtIndex(index, base::UTF8ToUTF16(profile_name));
1397 bool default_name =
1398 GetPrefs()->GetBoolean(prefs::kProfileUsingDefaultName);
1399 cache.SetProfileIsUsingDefaultNameAtIndex(index, default_name);
1365 } 1400 }
1366 } 1401 }
1367 1402
1368 void ProfileImpl::UpdateProfileAvatarCache() { 1403 void ProfileImpl::UpdateProfileAvatarCache() {
1369 ProfileManager* profile_manager = g_browser_process->profile_manager(); 1404 ProfileManager* profile_manager = g_browser_process->profile_manager();
1370 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); 1405 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
1371 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); 1406 size_t index = cache.GetIndexOfProfileWithPath(GetPath());
1372 if (index != std::string::npos) { 1407 if (index != std::string::npos) {
1373 size_t avatar_index = 1408 size_t avatar_index =
1374 GetPrefs()->GetInteger(prefs::kProfileAvatarIndex); 1409 GetPrefs()->GetInteger(prefs::kProfileAvatarIndex);
1375 cache.SetAvatarIconOfProfileAtIndex(index, avatar_index); 1410 cache.SetAvatarIconOfProfileAtIndex(index, avatar_index);
1411 bool default_avatar =
1412 GetPrefs()->GetBoolean(prefs::kProfileUsingDefaultAvatar);
1413 cache.SetProfileIsUsingDefaultAvatarAtIndex(index, default_avatar);
1414 bool gaia_avatar =
1415 GetPrefs()->GetBoolean(prefs::kProfileUsingGAIAAvatar);
1416 cache.SetIsUsingGAIAPictureOfProfileAtIndex(index, gaia_avatar);
1376 } 1417 }
1377 } 1418 }
1378 1419
1379 void ProfileImpl::UpdateProfileIsEphemeralCache() { 1420 void ProfileImpl::UpdateProfileIsEphemeralCache() {
1380 ProfileManager* profile_manager = g_browser_process->profile_manager(); 1421 ProfileManager* profile_manager = g_browser_process->profile_manager();
1381 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); 1422 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
1382 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); 1423 size_t index = cache.GetIndexOfProfileWithPath(GetPath());
1383 if (index != std::string::npos) { 1424 if (index != std::string::npos) {
1384 bool is_ephemeral = GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles); 1425 bool is_ephemeral = GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles);
1385 cache.SetProfileIsEphemeralAtIndex(index, is_ephemeral); 1426 cache.SetProfileIsEphemeralAtIndex(index, is_ephemeral);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 ProfileImpl::CreateDomainReliabilityMonitor() { 1459 ProfileImpl::CreateDomainReliabilityMonitor() {
1419 domain_reliability::DomainReliabilityService* service = 1460 domain_reliability::DomainReliabilityService* service =
1420 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> 1461 domain_reliability::DomainReliabilityServiceFactory::GetInstance()->
1421 GetForBrowserContext(this); 1462 GetForBrowserContext(this);
1422 if (!service) 1463 if (!service)
1423 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>(); 1464 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>();
1424 1465
1425 return service->CreateMonitor( 1466 return service->CreateMonitor(
1426 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); 1467 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
1427 } 1468 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/gaia_info_update_service_unittest.cc ('k') | chrome/browser/profiles/profile_info_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698