| 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/extensions/image_loader.h" | 5 #include "chrome/browser/extensions/image_loader.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 *bitmap = *image.bitmap(); | 76 *bitmap = *image.bitmap(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void LoadImageOnBlockingPool(const ImageLoader::ImageRepresentation& image_info, | 79 void LoadImageOnBlockingPool(const ImageLoader::ImageRepresentation& image_info, |
| 80 SkBitmap* bitmap) { | 80 SkBitmap* bitmap) { |
| 81 DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | 81 DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
| 82 | 82 |
| 83 // Read the file from disk. | 83 // Read the file from disk. |
| 84 std::string file_contents; | 84 std::string file_contents; |
| 85 base::FilePath path = image_info.resource.GetFilePath(); | 85 base::FilePath path = image_info.resource.GetFilePath(); |
| 86 if (path.empty() || !file_util::ReadFileToString(path, &file_contents)) { | 86 if (path.empty() || !base::ReadFileToString(path, &file_contents)) { |
| 87 return; | 87 return; |
| 88 } | 88 } |
| 89 | 89 |
| 90 const unsigned char* data = | 90 const unsigned char* data = |
| 91 reinterpret_cast<const unsigned char*>(file_contents.data()); | 91 reinterpret_cast<const unsigned char*>(file_contents.data()); |
| 92 // Note: This class only decodes bitmaps from extension resources. Chrome | 92 // Note: This class only decodes bitmaps from extension resources. Chrome |
| 93 // doesn't (for security reasons) directly load extension resources provided | 93 // doesn't (for security reasons) directly load extension resources provided |
| 94 // by the extension author, but instead decodes them in a separate | 94 // by the extension author, but instead decodes them in a separate |
| 95 // locked-down utility process. Only if the decoding succeeds is the image | 95 // locked-down utility process. Only if the decoding succeeds is the image |
| 96 // saved from memory to disk and subsequently used in the Chrome UI. | 96 // saved from memory to disk and subsequently used in the Chrome UI. |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 gfx::Image image; | 340 gfx::Image image; |
| 341 if (!image_skia.isNull()) { | 341 if (!image_skia.isNull()) { |
| 342 image_skia.MakeThreadSafe(); | 342 image_skia.MakeThreadSafe(); |
| 343 image = gfx::Image(image_skia); | 343 image = gfx::Image(image_skia); |
| 344 } | 344 } |
| 345 | 345 |
| 346 callback.Run(image); | 346 callback.Run(image); |
| 347 } | 347 } |
| 348 | 348 |
| 349 } // namespace extensions | 349 } // namespace extensions |
| OLD | NEW |