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/search/thumbnail_source.h" | 5 #include "chrome/browser/search/thumbnail_source.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 fallback_thumbnail_url_str = path.substr(pos + strlen(kUrlDelimiter)); | 112 fallback_thumbnail_url_str = path.substr(pos + strlen(kUrlDelimiter)); |
113 } | 113 } |
114 | 114 |
115 *page_url = GURL(page_url_str); | 115 *page_url = GURL(page_url_str); |
116 *fallback_thumbnail_url = GURL(fallback_thumbnail_url_str); | 116 *fallback_thumbnail_url = GURL(fallback_thumbnail_url_str); |
117 } | 117 } |
118 | 118 |
119 void ThumbnailSource::SendFetchedUrlImage( | 119 void ThumbnailSource::SendFetchedUrlImage( |
120 const content::URLDataSource::GotDataCallback& callback, | 120 const content::URLDataSource::GotDataCallback& callback, |
121 const std::string& url, | 121 const std::string& url, |
122 const gfx::Image& image) { | 122 const gfx::Image& image, |
| 123 const image_fetcher::RequestMetadata& metadata) { |
123 // In case the image could not be retrieved an empty image is returned. | 124 // In case the image could not be retrieved an empty image is returned. |
124 if (image.IsEmpty()) { | 125 if (image.IsEmpty()) { |
125 callback.Run(default_thumbnail_.get()); | 126 callback.Run(default_thumbnail_.get()); |
126 return; | 127 return; |
127 } | 128 } |
128 | 129 |
129 const SkBitmap* bitmap = image.ToSkBitmap(); | 130 const SkBitmap* bitmap = image.ToSkBitmap(); |
130 scoped_refptr<base::RefCountedBytes> encoded_data( | 131 scoped_refptr<base::RefCountedBytes> encoded_data( |
131 new base::RefCountedBytes()); | 132 new base::RefCountedBytes()); |
132 if (!suggestions::EncodeSkBitmapToJPEG(*bitmap, &encoded_data->data())) { | 133 if (!suggestions::EncodeSkBitmapToJPEG(*bitmap, &encoded_data->data())) { |
133 callback.Run(default_thumbnail_.get()); | 134 callback.Run(default_thumbnail_.get()); |
134 return; | 135 return; |
135 } | 136 } |
136 | 137 |
137 callback.Run(encoded_data.get()); | 138 callback.Run(encoded_data.get()); |
138 } | 139 } |
OLD | NEW |