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

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

Issue 210043005: [Profiles] Use high resolution avatars if they exist (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: roger comments Created 6 years, 9 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
« no previous file with comments | « chrome/browser/profiles/profile_info_cache.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_info_cache.h" 5 #include "chrome/browser/profiles/profile_info_cache.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/i18n/case_conversion.h" 10 #include "base/i18n/case_conversion.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/path_service.h"
13 #include "base/prefs/pref_registry_simple.h" 14 #include "base/prefs/pref_registry_simple.h"
14 #include "base/prefs/pref_service.h" 15 #include "base/prefs/pref_service.h"
15 #include "base/prefs/scoped_user_pref_update.h" 16 #include "base/prefs/scoped_user_pref_update.h"
16 #include "base/rand_util.h" 17 #include "base/rand_util.h"
17 #include "base/stl_util.h" 18 #include "base/stl_util.h"
18 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_piece.h" 20 #include "base/strings/string_piece.h"
20 #include "base/strings/stringprintf.h" 21 #include "base/strings/stringprintf.h"
21 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
22 #include "base/values.h" 23 #include "base/values.h"
23 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
24 #include "chrome/browser/chrome_notification_types.h" 25 #include "chrome/browser/chrome_notification_types.h"
26 #include "chrome/common/chrome_paths.h"
25 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
26 #include "chrome/common/profile_management_switches.h" 28 #include "chrome/common/profile_management_switches.h"
27 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/notification_service.h" 30 #include "content/public/browser/notification_service.h"
29 #include "grit/generated_resources.h" 31 #include "grit/generated_resources.h"
30 #include "grit/theme_resources.h" 32 #include "grit/theme_resources.h"
31 #include "third_party/skia/include/core/SkBitmap.h" 33 #include "third_party/skia/include/core/SkBitmap.h"
32 #include "ui/base/l10n/l10n_util.h" 34 #include "ui/base/l10n/l10n_util.h"
33 #include "ui/base/resource/resource_bundle.h" 35 #include "ui/base/resource/resource_bundle.h"
34 #include "ui/gfx/image/image.h" 36 #include "ui/gfx/image/image.h"
(...skipping 16 matching lines...) Expand all
51 const char kGAIAPictureFileNameKey[] = "gaia_picture_file_name"; 53 const char kGAIAPictureFileNameKey[] = "gaia_picture_file_name";
52 const char kIsManagedKey[] = "is_managed"; 54 const char kIsManagedKey[] = "is_managed";
53 const char kIsOmittedFromProfileListKey[] = "is_omitted_from_profile_list"; 55 const char kIsOmittedFromProfileListKey[] = "is_omitted_from_profile_list";
54 const char kSigninRequiredKey[] = "signin_required"; 56 const char kSigninRequiredKey[] = "signin_required";
55 const char kManagedUserId[] = "managed_user_id"; 57 const char kManagedUserId[] = "managed_user_id";
56 const char kProfileIsEphemeral[] = "is_ephemeral"; 58 const char kProfileIsEphemeral[] = "is_ephemeral";
57 const char kActiveTimeKey[] = "active_time"; 59 const char kActiveTimeKey[] = "active_time";
58 60
59 const char kDefaultUrlPrefix[] = "chrome://theme/IDR_PROFILE_AVATAR_"; 61 const char kDefaultUrlPrefix[] = "chrome://theme/IDR_PROFILE_AVATAR_";
60 const char kGAIAPictureFileName[] = "Google Profile Picture.png"; 62 const char kGAIAPictureFileName[] = "Google Profile Picture.png";
63 const char kHighResAvatarFolderName[] = "Avatars";
61 64
62 const int kDefaultAvatarIconResources[] = { 65 const int kDefaultAvatarIconResources[] = {
63 IDR_PROFILE_AVATAR_0, 66 IDR_PROFILE_AVATAR_0,
64 IDR_PROFILE_AVATAR_1, 67 IDR_PROFILE_AVATAR_1,
65 IDR_PROFILE_AVATAR_2, 68 IDR_PROFILE_AVATAR_2,
66 IDR_PROFILE_AVATAR_3, 69 IDR_PROFILE_AVATAR_3,
67 IDR_PROFILE_AVATAR_4, 70 IDR_PROFILE_AVATAR_4,
68 IDR_PROFILE_AVATAR_5, 71 IDR_PROFILE_AVATAR_5,
69 IDR_PROFILE_AVATAR_6, 72 IDR_PROFILE_AVATAR_6,
70 IDR_PROFILE_AVATAR_7, 73 IDR_PROFILE_AVATAR_7,
(...skipping 10 matching lines...) Expand all
81 IDR_PROFILE_AVATAR_18, 84 IDR_PROFILE_AVATAR_18,
82 IDR_PROFILE_AVATAR_19, 85 IDR_PROFILE_AVATAR_19,
83 IDR_PROFILE_AVATAR_20, 86 IDR_PROFILE_AVATAR_20,
84 IDR_PROFILE_AVATAR_21, 87 IDR_PROFILE_AVATAR_21,
85 IDR_PROFILE_AVATAR_22, 88 IDR_PROFILE_AVATAR_22,
86 IDR_PROFILE_AVATAR_23, 89 IDR_PROFILE_AVATAR_23,
87 IDR_PROFILE_AVATAR_24, 90 IDR_PROFILE_AVATAR_24,
88 IDR_PROFILE_AVATAR_25, 91 IDR_PROFILE_AVATAR_25,
89 }; 92 };
90 93
94 // File names for the high-res avatar icon resources. In the same order as
95 // the avatars in kDefaultAvatarIconResources.
96 const char* kDefaultAvatarIconResourceFileNames[] = {
97 "avatar_generic.png",
98 "avatar_generic_aqua.png",
99 "avatar_generic_blue.png",
100 "avatar_generic_green.png",
101 "avatar_generic_orange.png",
102 "avatar_generic_purple.png",
103 "avatar_generic_red.png",
104 "avatar_generic_yellow.png",
105 "avatar_secret_agent.png",
106 "avatar_superhero.png",
107 "avatar_volley_ball.png",
108 "avatar_businessman.png",
109 "avatar_ninja.png",
110 "avatar_alien.png",
111 "avatar_smiley.png",
112 "avatar_flower.png",
113 "avatar_pizza.png",
114 "avatar_soccer.png",
115 "avatar_burger.png",
116 "avatar_cat.png",
117 "avatar_cupcake.png",
118 "avatar_dog.png",
119 "avatar_horse.png",
120 "avatar_margarita.png",
121 "avatar_note.png",
122 "avatar_sun_cloud.png",
123 };
124
91 const size_t kDefaultAvatarIconsCount = arraysize(kDefaultAvatarIconResources); 125 const size_t kDefaultAvatarIconsCount = arraysize(kDefaultAvatarIconResources);
92 126
93 // The first 8 icons are generic. 127 // The first 8 icons are generic.
94 const size_t kGenericIconCount = 8; 128 const size_t kGenericIconCount = 8;
95 129
96 // First eight are generic icons, which use IDS_NUMBERED_PROFILE_NAME. 130 // First eight are generic icons, which use IDS_NUMBERED_PROFILE_NAME.
97 const int kDefaultNames[] = { 131 const int kDefaultNames[] = {
98 IDS_DEFAULT_AVATAR_NAME_8, 132 IDS_DEFAULT_AVATAR_NAME_8,
99 IDS_DEFAULT_AVATAR_NAME_9, 133 IDS_DEFAULT_AVATAR_NAME_9,
100 IDS_DEFAULT_AVATAR_NAME_10, 134 IDS_DEFAULT_AVATAR_NAME_10,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 } 177 }
144 178
145 // Reads a PNG from disk and decodes it. If the bitmap was successfully read 179 // Reads a PNG from disk and decodes it. If the bitmap was successfully read
146 // from disk the then |out_image| will contain the bitmap image, otherwise it 180 // from disk the then |out_image| will contain the bitmap image, otherwise it
147 // will be NULL. 181 // will be NULL.
148 void ReadBitmap(const base::FilePath& image_path, 182 void ReadBitmap(const base::FilePath& image_path,
149 gfx::Image** out_image) { 183 gfx::Image** out_image) {
150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 184 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
151 *out_image = NULL; 185 *out_image = NULL;
152 186
187 // If the path doesn't exist, don't even try reading it.
188 if (!base::PathExists(image_path))
189 return;
190
153 std::string image_data; 191 std::string image_data;
154 if (!base::ReadFileToString(image_path, &image_data)) { 192 if (!base::ReadFileToString(image_path, &image_data)) {
155 LOG(ERROR) << "Failed to read PNG file from disk."; 193 LOG(ERROR) << "Failed to read PNG file from disk.";
156 return; 194 return;
157 } 195 }
158 196
159 gfx::Image image = gfx::Image::CreateFrom1xPNGBytes( 197 gfx::Image image = gfx::Image::CreateFrom1xPNGBytes(
160 base::RefCountedString::TakeString(&image_data)); 198 base::RefCountedString::TakeString(&image_data));
161 if (image.IsEmpty()) { 199 if (image.IsEmpty()) {
162 LOG(ERROR) << "Failed to decode PNG file."; 200 LOG(ERROR) << "Failed to decode PNG file.";
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 if (info->GetBoolean(kIsManagedKey, &is_managed)) { 254 if (info->GetBoolean(kIsManagedKey, &is_managed)) {
217 info->Remove(kIsManagedKey, NULL); 255 info->Remove(kIsManagedKey, NULL);
218 info->SetString(kManagedUserId, is_managed ? "DUMMY_ID" : std::string()); 256 info->SetString(kManagedUserId, is_managed ? "DUMMY_ID" : std::string());
219 } 257 }
220 info->SetBoolean(kIsUsingDefaultName, IsDefaultName(name)); 258 info->SetBoolean(kIsUsingDefaultName, IsDefaultName(name));
221 } 259 }
222 } 260 }
223 261
224 ProfileInfoCache::~ProfileInfoCache() { 262 ProfileInfoCache::~ProfileInfoCache() {
225 STLDeleteContainerPairSecondPointers( 263 STLDeleteContainerPairSecondPointers(
226 gaia_pictures_.begin(), gaia_pictures_.end()); 264 cached_avatar_images_.begin(), cached_avatar_images_.end());
227 } 265 }
228 266
229 void ProfileInfoCache::AddProfileToCache(const base::FilePath& profile_path, 267 void ProfileInfoCache::AddProfileToCache(const base::FilePath& profile_path,
230 const base::string16& name, 268 const base::string16& name,
231 const base::string16& username, 269 const base::string16& username,
232 size_t icon_index, 270 size_t icon_index,
233 const std::string& managed_user_id) { 271 const std::string& managed_user_id) {
234 std::string key = CacheKeyFromProfilePath(profile_path); 272 std::string key = CacheKeyFromProfilePath(profile_path);
235 DictionaryPrefUpdate update(prefs_, prefs::kProfileInfoCache); 273 DictionaryPrefUpdate update(prefs_, prefs::kProfileInfoCache);
236 base::DictionaryValue* cache = update.Get(); 274 base::DictionaryValue* cache = update.Get();
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 } 392 }
355 393
356 const gfx::Image& ProfileInfoCache::GetAvatarIconOfProfileAtIndex( 394 const gfx::Image& ProfileInfoCache::GetAvatarIconOfProfileAtIndex(
357 size_t index) const { 395 size_t index) const {
358 if (IsUsingGAIAPictureOfProfileAtIndex(index)) { 396 if (IsUsingGAIAPictureOfProfileAtIndex(index)) {
359 const gfx::Image* image = GetGAIAPictureOfProfileAtIndex(index); 397 const gfx::Image* image = GetGAIAPictureOfProfileAtIndex(index);
360 if (image) 398 if (image)
361 return *image; 399 return *image;
362 } 400 }
363 401
402 // Use the high resolution version of the avatar if it exists.
403 if (switches::IsNewProfileManagement()) {
404 const gfx::Image* image = GetHighResAvatarOfProfileAtIndex(index);
405 if (image)
406 return *image;
407 }
408
364 int resource_id = GetDefaultAvatarIconResourceIDAtIndex( 409 int resource_id = GetDefaultAvatarIconResourceIDAtIndex(
365 GetAvatarIconIndexOfProfileAtIndex(index)); 410 GetAvatarIconIndexOfProfileAtIndex(index));
366 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); 411 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id);
367 } 412 }
368 413
369 std::string ProfileInfoCache::GetLocalAuthCredentialsOfProfileAtIndex( 414 std::string ProfileInfoCache::GetLocalAuthCredentialsOfProfileAtIndex(
370 size_t index) const { 415 size_t index) const {
371 std::string credentials; 416 std::string credentials;
372 GetInfoForProfileAtIndex(index)->GetString(kAuthCredentialsKey, &credentials); 417 GetInfoForProfileAtIndex(index)->GetString(kAuthCredentialsKey, &credentials);
373 return credentials; 418 return credentials;
(...skipping 21 matching lines...) Expand all
395 base::string16 name; 440 base::string16 name;
396 GetInfoForProfileAtIndex(index)->GetString(kGAIAGivenNameKey, &name); 441 GetInfoForProfileAtIndex(index)->GetString(kGAIAGivenNameKey, &name);
397 return name; 442 return name;
398 } 443 }
399 444
400 const gfx::Image* ProfileInfoCache::GetGAIAPictureOfProfileAtIndex( 445 const gfx::Image* ProfileInfoCache::GetGAIAPictureOfProfileAtIndex(
401 size_t index) const { 446 size_t index) const {
402 base::FilePath path = GetPathOfProfileAtIndex(index); 447 base::FilePath path = GetPathOfProfileAtIndex(index);
403 std::string key = CacheKeyFromProfilePath(path); 448 std::string key = CacheKeyFromProfilePath(path);
404 449
405 // If the picture is already loaded then use it.
406 if (gaia_pictures_.count(key)) {
407 if (gaia_pictures_[key]->IsEmpty())
408 return NULL;
409 return gaia_pictures_[key];
410 }
411
412 std::string file_name; 450 std::string file_name;
413 GetInfoForProfileAtIndex(index)->GetString( 451 GetInfoForProfileAtIndex(index)->GetString(
414 kGAIAPictureFileNameKey, &file_name); 452 kGAIAPictureFileNameKey, &file_name);
415 453
416 // If the picture is not on disk or it is already being loaded then return 454 // If the picture is not on disk then return NULL.
417 // NULL. 455 if (file_name.empty())
418 if (file_name.empty() || gaia_pictures_loading_[key])
419 return NULL; 456 return NULL;
420 457
421 gaia_pictures_loading_[key] = true;
422 base::FilePath image_path = path.AppendASCII(file_name); 458 base::FilePath image_path = path.AppendASCII(file_name);
459 return LoadAvatarPictureFromPath(key, image_path);
460 }
461
462 const gfx::Image* ProfileInfoCache::GetHighResAvatarOfProfileAtIndex(
463 size_t index) const {
464 int avatar_index = GetAvatarIconIndexOfProfileAtIndex(index);
465 std::string key = kDefaultAvatarIconResourceFileNames[avatar_index];
466
467 base::FilePath user_data_dir;
468 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
469 base::FilePath image_path =
470 user_data_dir.AppendASCII(kHighResAvatarFolderName).AppendASCII(key);
471 return LoadAvatarPictureFromPath(key, image_path);
472 }
473
474 const gfx::Image* ProfileInfoCache::LoadAvatarPictureFromPath(
475 const std::string& key,
476 const base::FilePath& image_path) const {
477 // If the picture is already loaded then use it.
478 if (cached_avatar_images_.count(key)) {
479 if (cached_avatar_images_[key]->IsEmpty())
480 return NULL;
481 return cached_avatar_images_[key];
482 }
483
484 // If the picture is already being loaded then don't try loading it again.
485 if (cached_avatar_images_loading_[key])
486 return NULL;
487 cached_avatar_images_loading_[key] = true;
488
423 gfx::Image** image = new gfx::Image*; 489 gfx::Image** image = new gfx::Image*;
424 BrowserThread::PostTaskAndReply(BrowserThread::FILE, FROM_HERE, 490 BrowserThread::PostTaskAndReply(BrowserThread::FILE, FROM_HERE,
425 base::Bind(&ReadBitmap, image_path, image), 491 base::Bind(&ReadBitmap, image_path, image),
426 base::Bind(&ProfileInfoCache::OnGAIAPictureLoaded, 492 base::Bind(&ProfileInfoCache::OnAvatarPictureLoaded,
427 const_cast<ProfileInfoCache*>(this)->AsWeakPtr(), path, image)); 493 const_cast<ProfileInfoCache*>(this)->AsWeakPtr(), key, image));
428
429 return NULL; 494 return NULL;
430 } 495 }
431 496
432 bool ProfileInfoCache::ProfileIsManagedAtIndex(size_t index) const { 497 bool ProfileInfoCache::ProfileIsManagedAtIndex(size_t index) const {
433 return !GetManagedUserIdOfProfileAtIndex(index).empty(); 498 return !GetManagedUserIdOfProfileAtIndex(index).empty();
434 } 499 }
435 500
436 bool ProfileInfoCache::IsOmittedProfileAtIndex(size_t index) const { 501 bool ProfileInfoCache::IsOmittedProfileAtIndex(size_t index) const {
437 bool value = false; 502 bool value = false;
438 GetInfoForProfileAtIndex(index)->GetBoolean(kIsOmittedFromProfileListKey, 503 GetInfoForProfileAtIndex(index)->GetBoolean(kIsOmittedFromProfileListKey,
(...skipping 19 matching lines...) Expand all
458 GetInfoForProfileAtIndex(index)->GetBoolean(kProfileIsEphemeral, &value); 523 GetInfoForProfileAtIndex(index)->GetBoolean(kProfileIsEphemeral, &value);
459 return value; 524 return value;
460 } 525 }
461 526
462 bool ProfileInfoCache::ProfileIsUsingDefaultNameAtIndex(size_t index) const { 527 bool ProfileInfoCache::ProfileIsUsingDefaultNameAtIndex(size_t index) const {
463 bool value = false; 528 bool value = false;
464 GetInfoForProfileAtIndex(index)->GetBoolean(kIsUsingDefaultName, &value); 529 GetInfoForProfileAtIndex(index)->GetBoolean(kIsUsingDefaultName, &value);
465 return value; 530 return value;
466 } 531 }
467 532
468 void ProfileInfoCache::OnGAIAPictureLoaded(const base::FilePath& path, 533 void ProfileInfoCache::OnAvatarPictureLoaded(const std::string& key,
469 gfx::Image** image) const { 534 gfx::Image** image) const {
470 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 535 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
471 536
472 std::string key = CacheKeyFromProfilePath(path); 537 cached_avatar_images_loading_[key] = false;
473 gaia_pictures_loading_[key] = false;
474 538
539 delete cached_avatar_images_[key];
475 if (*image) { 540 if (*image) {
476 delete gaia_pictures_[key]; 541 cached_avatar_images_[key] = *image;
477 gaia_pictures_[key] = *image;
478 } else { 542 } else {
479 // Place an empty image in the cache to avoid reloading it again. 543 // Place an empty image in the cache to avoid reloading it again.
480 gaia_pictures_[key] = new gfx::Image(); 544 cached_avatar_images_[key] = new gfx::Image();
481 } 545 }
482 delete image; 546 delete image;
483 547
484 content::NotificationService::current()->Notify( 548 content::NotificationService::current()->Notify(
485 chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, 549 chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
486 content::NotificationService::AllSources(), 550 content::NotificationService::AllSources(),
487 content::NotificationService::NoDetails()); 551 content::NotificationService::NoDetails());
488 } 552 }
489 553
490 void ProfileInfoCache::OnGAIAPictureSaved(const base::FilePath& path, 554 void ProfileInfoCache::OnGAIAPictureSaved(const base::FilePath& path,
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 // This takes ownership of |info|. 731 // This takes ownership of |info|.
668 SetInfoForProfileAtIndex(index, info.release()); 732 SetInfoForProfileAtIndex(index, info.release());
669 } 733 }
670 734
671 void ProfileInfoCache::SetGAIAPictureOfProfileAtIndex(size_t index, 735 void ProfileInfoCache::SetGAIAPictureOfProfileAtIndex(size_t index,
672 const gfx::Image* image) { 736 const gfx::Image* image) {
673 base::FilePath path = GetPathOfProfileAtIndex(index); 737 base::FilePath path = GetPathOfProfileAtIndex(index);
674 std::string key = CacheKeyFromProfilePath(path); 738 std::string key = CacheKeyFromProfilePath(path);
675 739
676 // Delete the old bitmap from cache. 740 // Delete the old bitmap from cache.
677 std::map<std::string, gfx::Image*>::iterator it = gaia_pictures_.find(key); 741 std::map<std::string, gfx::Image*>::iterator it =
678 if (it != gaia_pictures_.end()) { 742 cached_avatar_images_.find(key);
743 if (it != cached_avatar_images_.end()) {
679 delete it->second; 744 delete it->second;
680 gaia_pictures_.erase(it); 745 cached_avatar_images_.erase(it);
681 } 746 }
682 747
683 std::string old_file_name; 748 std::string old_file_name;
684 GetInfoForProfileAtIndex(index)->GetString( 749 GetInfoForProfileAtIndex(index)->GetString(
685 kGAIAPictureFileNameKey, &old_file_name); 750 kGAIAPictureFileNameKey, &old_file_name);
686 std::string new_file_name; 751 std::string new_file_name;
687 752
688 if (!image) { 753 if (!image) {
689 // Delete the old bitmap from disk. 754 // Delete the old bitmap from disk.
690 if (!old_file_name.empty()) { 755 if (!old_file_name.empty()) {
691 base::FilePath image_path = path.AppendASCII(old_file_name); 756 base::FilePath image_path = path.AppendASCII(old_file_name);
692 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 757 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
693 base::Bind(&DeleteBitmap, image_path)); 758 base::Bind(&DeleteBitmap, image_path));
694 } 759 }
695 } else { 760 } else {
696 // Save the new bitmap to disk. 761 // Save the new bitmap to disk.
697 gaia_pictures_[key] = new gfx::Image(*image); 762 cached_avatar_images_[key] = new gfx::Image(*image);
698 scoped_ptr<ImageData> data(new ImageData); 763 scoped_ptr<ImageData> data(new ImageData);
699 scoped_refptr<base::RefCountedMemory> png_data = image->As1xPNGBytes(); 764 scoped_refptr<base::RefCountedMemory> png_data = image->As1xPNGBytes();
700 data->assign(png_data->front(), png_data->front() + png_data->size()); 765 data->assign(png_data->front(), png_data->front() + png_data->size());
701 if (!data->size()) { 766 if (!data->size()) {
702 LOG(ERROR) << "Failed to PNG encode the image."; 767 LOG(ERROR) << "Failed to PNG encode the image.";
703 } else { 768 } else {
704 new_file_name = 769 new_file_name =
705 old_file_name.empty() ? kGAIAPictureFileName : old_file_name; 770 old_file_name.empty() ? kGAIAPictureFileName : old_file_name;
706 base::FilePath image_path = path.AppendASCII(new_file_name); 771 base::FilePath image_path = path.AppendASCII(new_file_name);
707 bool* success = new bool; 772 bool* success = new bool;
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 info->GetString(kNameKey, &name); 1053 info->GetString(kNameKey, &name);
989 names.push_back(name); 1054 names.push_back(name);
990 } 1055 }
991 return names; 1056 return names;
992 } 1057 }
993 1058
994 // static 1059 // static
995 void ProfileInfoCache::RegisterPrefs(PrefRegistrySimple* registry) { 1060 void ProfileInfoCache::RegisterPrefs(PrefRegistrySimple* registry) {
996 registry->RegisterDictionaryPref(prefs::kProfileInfoCache); 1061 registry->RegisterDictionaryPref(prefs::kProfileInfoCache);
997 } 1062 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_info_cache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698