| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/renderer/image_loading_helper.h" | 5 #include "content/renderer/image_loading_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "content/child/image_decoder.h" | 9 #include "content/child/image_decoder.h" |
| 10 #include "content/common/image_messages.h" | 10 #include "content/common/image_messages.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 ImageLoadingHelper::~ImageLoadingHelper() { | 104 ImageLoadingHelper::~ImageLoadingHelper() { |
| 105 } | 105 } |
| 106 | 106 |
| 107 void ImageLoadingHelper::OnDownloadImage(int id, | 107 void ImageLoadingHelper::OnDownloadImage(int id, |
| 108 const GURL& image_url, | 108 const GURL& image_url, |
| 109 bool is_favicon, | 109 bool is_favicon, |
| 110 uint32_t max_image_size) { | 110 uint32_t max_image_size) { |
| 111 std::vector<SkBitmap> result_images; | 111 std::vector<SkBitmap> result_images; |
| 112 std::vector<gfx::Size> result_original_image_sizes; | 112 std::vector<gfx::Size> result_original_image_sizes; |
| 113 if (image_url.SchemeIs(kDataScheme)) { | 113 if (image_url.SchemeIs(url::kDataScheme)) { |
| 114 SkBitmap data_image = ImageFromDataUrl(image_url); | 114 SkBitmap data_image = ImageFromDataUrl(image_url); |
| 115 if (!data_image.empty()) { | 115 if (!data_image.empty()) { |
| 116 result_images.push_back(ResizeImage(data_image, max_image_size)); | 116 result_images.push_back(ResizeImage(data_image, max_image_size)); |
| 117 result_original_image_sizes.push_back( | 117 result_original_image_sizes.push_back( |
| 118 gfx::Size(data_image.width(), data_image.height())); | 118 gfx::Size(data_image.width(), data_image.height())); |
| 119 } | 119 } |
| 120 } else { | 120 } else { |
| 121 if (DownloadImage(id, image_url, is_favicon, max_image_size)) { | 121 if (DownloadImage(id, image_url, is_favicon, max_image_size)) { |
| 122 // Will complete asynchronously via ImageLoadingHelper::DidDownloadImage | 122 // Will complete asynchronously via ImageLoadingHelper::DidDownloadImage |
| 123 return; | 123 return; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 bool handled = true; | 194 bool handled = true; |
| 195 IPC_BEGIN_MESSAGE_MAP(ImageLoadingHelper, message) | 195 IPC_BEGIN_MESSAGE_MAP(ImageLoadingHelper, message) |
| 196 IPC_MESSAGE_HANDLER(ImageMsg_DownloadImage, OnDownloadImage) | 196 IPC_MESSAGE_HANDLER(ImageMsg_DownloadImage, OnDownloadImage) |
| 197 IPC_MESSAGE_UNHANDLED(handled = false) | 197 IPC_MESSAGE_UNHANDLED(handled = false) |
| 198 IPC_END_MESSAGE_MAP() | 198 IPC_END_MESSAGE_MAP() |
| 199 | 199 |
| 200 return handled; | 200 return handled; |
| 201 } | 201 } |
| 202 | 202 |
| 203 } // namespace content | 203 } // namespace content |
| OLD | NEW |