| 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/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 140 |
| 141 // Reads a PNG from disk and decodes it. If the bitmap was successfully read | 141 // Reads a PNG from disk and decodes it. If the bitmap was successfully read |
| 142 // from disk the then |out_image| will contain the bitmap image, otherwise it | 142 // from disk the then |out_image| will contain the bitmap image, otherwise it |
| 143 // will be NULL. | 143 // will be NULL. |
| 144 void ReadBitmap(const base::FilePath& image_path, | 144 void ReadBitmap(const base::FilePath& image_path, |
| 145 gfx::Image** out_image) { | 145 gfx::Image** out_image) { |
| 146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 147 *out_image = NULL; | 147 *out_image = NULL; |
| 148 | 148 |
| 149 std::string image_data; | 149 std::string image_data; |
| 150 if (!file_util::ReadFileToString(image_path, &image_data)) { | 150 if (!base::ReadFileToString(image_path, &image_data)) { |
| 151 LOG(ERROR) << "Failed to read PNG file from disk."; | 151 LOG(ERROR) << "Failed to read PNG file from disk."; |
| 152 return; | 152 return; |
| 153 } | 153 } |
| 154 | 154 |
| 155 const unsigned char* data = | 155 const unsigned char* data = |
| 156 reinterpret_cast<const unsigned char*>(image_data.data()); | 156 reinterpret_cast<const unsigned char*>(image_data.data()); |
| 157 gfx::Image image = | 157 gfx::Image image = |
| 158 gfx::Image::CreateFrom1xPNGBytes(data, image_data.length()); | 158 gfx::Image::CreateFrom1xPNGBytes(data, image_data.length()); |
| 159 if (image.IsEmpty()) { | 159 if (image.IsEmpty()) { |
| 160 LOG(ERROR) << "Failed to decode PNG file."; | 160 LOG(ERROR) << "Failed to decode PNG file."; |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 info->GetString(kNameKey, &name); | 856 info->GetString(kNameKey, &name); |
| 857 names.push_back(name); | 857 names.push_back(name); |
| 858 } | 858 } |
| 859 return names; | 859 return names; |
| 860 } | 860 } |
| 861 | 861 |
| 862 // static | 862 // static |
| 863 void ProfileInfoCache::RegisterPrefs(PrefRegistrySimple* registry) { | 863 void ProfileInfoCache::RegisterPrefs(PrefRegistrySimple* registry) { |
| 864 registry->RegisterDictionaryPref(prefs::kProfileInfoCache); | 864 registry->RegisterDictionaryPref(prefs::kProfileInfoCache); |
| 865 } | 865 } |
| OLD | NEW |