| 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_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 Loading... |
| 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 | |
| 81 }; | 80 }; |
| 82 | 81 |
| 83 typedef std::vector<unsigned char> ImageData; | 82 typedef std::vector<unsigned char> ImageData; |
| 84 | 83 |
| 85 // Writes |data| to disk and takes ownership of the pointer. On completion | 84 // Writes |data| to disk and takes ownership of the pointer. On completion |
| 86 // |success| is set to true on success and false on failure. | 85 // |success| is set to true on success and false on failure. |
| 87 void SaveBitmap(ImageData* data, | 86 void SaveBitmap(ImageData* data, |
| 88 const base::FilePath& image_path, | 87 const base::FilePath& image_path, |
| 89 bool* success) { | 88 bool* success) { |
| 90 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 | 388 |
| 390 base::FilePath image_path = path.AppendASCII(file_name); | 389 base::FilePath image_path = path.AppendASCII(file_name); |
| 391 return LoadAvatarPictureFromPath(key, image_path); | 390 return LoadAvatarPictureFromPath(key, image_path); |
| 392 } | 391 } |
| 393 | 392 |
| 394 const gfx::Image* ProfileInfoCache::GetHighResAvatarOfProfileAtIndex( | 393 const gfx::Image* ProfileInfoCache::GetHighResAvatarOfProfileAtIndex( |
| 395 size_t index) const { | 394 size_t index) const { |
| 396 int avatar_index = GetAvatarIconIndexOfProfileAtIndex(index); | 395 int avatar_index = GetAvatarIconIndexOfProfileAtIndex(index); |
| 397 std::string key = profiles::GetDefaultAvatarIconFileNameAtIndex(avatar_index); | 396 std::string key = profiles::GetDefaultAvatarIconFileNameAtIndex(avatar_index); |
| 398 | 397 |
| 399 if (!strcmp(key.c_str(), profiles::GetNoHighResAvatarFileName())) | |
| 400 return NULL; | |
| 401 | |
| 402 base::FilePath user_data_dir; | 398 base::FilePath user_data_dir; |
| 403 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 399 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
| 404 base::FilePath image_path = user_data_dir. | 400 base::FilePath image_path = user_data_dir. |
| 405 AppendASCII(profiles::kHighResAvatarFolderName).AppendASCII(key); | 401 AppendASCII(profiles::kHighResAvatarFolderName).AppendASCII(key); |
| 406 return LoadAvatarPictureFromPath(key, image_path); | 402 return LoadAvatarPictureFromPath(key, image_path); |
| 407 } | 403 } |
| 408 | 404 |
| 409 const gfx::Image* ProfileInfoCache::LoadAvatarPictureFromPath( | 405 const gfx::Image* ProfileInfoCache::LoadAvatarPictureFromPath( |
| 410 const std::string& key, | 406 const std::string& key, |
| 411 const base::FilePath& image_path) const { | 407 const base::FilePath& image_path) const { |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 info->GetString(kNameKey, &name); | 941 info->GetString(kNameKey, &name); |
| 946 names.push_back(name); | 942 names.push_back(name); |
| 947 } | 943 } |
| 948 return names; | 944 return names; |
| 949 } | 945 } |
| 950 | 946 |
| 951 // static | 947 // static |
| 952 void ProfileInfoCache::RegisterPrefs(PrefRegistrySimple* registry) { | 948 void ProfileInfoCache::RegisterPrefs(PrefRegistrySimple* registry) { |
| 953 registry->RegisterDictionaryPref(prefs::kProfileInfoCache); | 949 registry->RegisterDictionaryPref(prefs::kProfileInfoCache); |
| 954 } | 950 } |
| OLD | NEW |