| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 scoped_ptr<ImageData> data_owner(data); | 127 scoped_ptr<ImageData> data_owner(data); |
| 128 *success = false; | 128 *success = false; |
| 129 | 129 |
| 130 // Make sure the destination directory exists. | 130 // Make sure the destination directory exists. |
| 131 base::FilePath dir = image_path.DirName(); | 131 base::FilePath dir = image_path.DirName(); |
| 132 if (!base::DirectoryExists(dir) && !base::CreateDirectory(dir)) { | 132 if (!base::DirectoryExists(dir) && !base::CreateDirectory(dir)) { |
| 133 LOG(ERROR) << "Failed to create parent directory."; | 133 LOG(ERROR) << "Failed to create parent directory."; |
| 134 return; | 134 return; |
| 135 } | 135 } |
| 136 | 136 |
| 137 if (file_util::WriteFile(image_path, | 137 if (base::WriteFile(image_path, reinterpret_cast<char*>(&(*data)[0]), |
| 138 reinterpret_cast<char*>(&(*data)[0]), | 138 data->size()) == -1) { |
| 139 data->size()) == -1) { | |
| 140 LOG(ERROR) << "Failed to save image to file."; | 139 LOG(ERROR) << "Failed to save image to file."; |
| 141 return; | 140 return; |
| 142 } | 141 } |
| 143 | 142 |
| 144 *success = true; | 143 *success = true; |
| 145 } | 144 } |
| 146 | 145 |
| 147 // Reads a PNG from disk and decodes it. If the bitmap was successfully read | 146 // Reads a PNG from disk and decodes it. If the bitmap was successfully read |
| 148 // from disk the then |out_image| will contain the bitmap image, otherwise it | 147 // from disk the then |out_image| will contain the bitmap image, otherwise it |
| 149 // will be NULL. | 148 // will be NULL. |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 info->GetString(kNameKey, &name); | 988 info->GetString(kNameKey, &name); |
| 990 names.push_back(name); | 989 names.push_back(name); |
| 991 } | 990 } |
| 992 return names; | 991 return names; |
| 993 } | 992 } |
| 994 | 993 |
| 995 // static | 994 // static |
| 996 void ProfileInfoCache::RegisterPrefs(PrefRegistrySimple* registry) { | 995 void ProfileInfoCache::RegisterPrefs(PrefRegistrySimple* registry) { |
| 997 registry->RegisterDictionaryPref(prefs::kProfileInfoCache); | 996 registry->RegisterDictionaryPref(prefs::kProfileInfoCache); |
| 998 } | 997 } |
| OLD | NEW |