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

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

Issue 212603011: Newly created profiles should have the grey silhouette as avatar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase reviewed Created 6 years, 8 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_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/i18n/case_conversion.h" 9 #include "base/i18n/case_conversion.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 IDS_DEFAULT_AVATAR_NAME_15, 69 IDS_DEFAULT_AVATAR_NAME_15,
70 IDS_DEFAULT_AVATAR_NAME_16, 70 IDS_DEFAULT_AVATAR_NAME_16,
71 IDS_DEFAULT_AVATAR_NAME_17, 71 IDS_DEFAULT_AVATAR_NAME_17,
72 IDS_DEFAULT_AVATAR_NAME_18, 72 IDS_DEFAULT_AVATAR_NAME_18,
73 IDS_DEFAULT_AVATAR_NAME_19, 73 IDS_DEFAULT_AVATAR_NAME_19,
74 IDS_DEFAULT_AVATAR_NAME_20, 74 IDS_DEFAULT_AVATAR_NAME_20,
75 IDS_DEFAULT_AVATAR_NAME_21, 75 IDS_DEFAULT_AVATAR_NAME_21,
76 IDS_DEFAULT_AVATAR_NAME_22, 76 IDS_DEFAULT_AVATAR_NAME_22,
77 IDS_DEFAULT_AVATAR_NAME_23, 77 IDS_DEFAULT_AVATAR_NAME_23,
78 IDS_DEFAULT_AVATAR_NAME_24, 78 IDS_DEFAULT_AVATAR_NAME_24,
79 IDS_DEFAULT_AVATAR_NAME_25 79 IDS_DEFAULT_AVATAR_NAME_25,
80 IDS_DEFAULT_AVATAR_NAME_26
80 }; 81 };
81 82
82 typedef std::vector<unsigned char> ImageData; 83 typedef std::vector<unsigned char> ImageData;
83 84
84 // Writes |data| to disk and takes ownership of the pointer. On completion 85 // Writes |data| to disk and takes ownership of the pointer. On completion
85 // |success| is set to true on success and false on failure. 86 // |success| is set to true on success and false on failure.
86 void SaveBitmap(ImageData* data, 87 void SaveBitmap(ImageData* data,
87 const base::FilePath& image_path, 88 const base::FilePath& image_path,
88 bool* success) { 89 bool* success) {
89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 90 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 389
389 base::FilePath image_path = path.AppendASCII(file_name); 390 base::FilePath image_path = path.AppendASCII(file_name);
390 return LoadAvatarPictureFromPath(key, image_path); 391 return LoadAvatarPictureFromPath(key, image_path);
391 } 392 }
392 393
393 const gfx::Image* ProfileInfoCache::GetHighResAvatarOfProfileAtIndex( 394 const gfx::Image* ProfileInfoCache::GetHighResAvatarOfProfileAtIndex(
394 size_t index) const { 395 size_t index) const {
395 int avatar_index = GetAvatarIconIndexOfProfileAtIndex(index); 396 int avatar_index = GetAvatarIconIndexOfProfileAtIndex(index);
396 std::string key = profiles::GetDefaultAvatarIconFileNameAtIndex(avatar_index); 397 std::string key = profiles::GetDefaultAvatarIconFileNameAtIndex(avatar_index);
397 398
399 if (!strcmp(key.c_str(), profiles::GetNoHighResAvatarFileName()))
400 return NULL;
401
398 base::FilePath user_data_dir; 402 base::FilePath user_data_dir;
399 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); 403 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
400 base::FilePath image_path = user_data_dir. 404 base::FilePath image_path = user_data_dir.
401 AppendASCII(profiles::kHighResAvatarFolderName).AppendASCII(key); 405 AppendASCII(profiles::kHighResAvatarFolderName).AppendASCII(key);
402 return LoadAvatarPictureFromPath(key, image_path); 406 return LoadAvatarPictureFromPath(key, image_path);
403 } 407 }
404 408
405 const gfx::Image* ProfileInfoCache::LoadAvatarPictureFromPath( 409 const gfx::Image* ProfileInfoCache::LoadAvatarPictureFromPath(
406 const std::string& key, 410 const std::string& key,
407 const base::FilePath& image_path) const { 411 const base::FilePath& image_path) const {
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 info->GetString(kNameKey, &name); 945 info->GetString(kNameKey, &name);
942 names.push_back(name); 946 names.push_back(name);
943 } 947 }
944 return names; 948 return names;
945 } 949 }
946 950
947 // static 951 // static
948 void ProfileInfoCache::RegisterPrefs(PrefRegistrySimple* registry) { 952 void ProfileInfoCache::RegisterPrefs(PrefRegistrySimple* registry) {
949 registry->RegisterDictionaryPref(prefs::kProfileInfoCache); 953 registry->RegisterDictionaryPref(prefs::kProfileInfoCache);
950 } 954 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_avatar_icon_util.cc ('k') | chrome/browser/profiles/profile_list_desktop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698