| 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" |
| 11 #include "base/memory/ref_counted_memory.h" | 11 #include "base/memory/ref_counted_memory.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/search/instant_io_context.h" | 14 #include "chrome/browser/search/instant_io_context.h" |
| 15 #include "chrome/browser/search/suggestions/image_decoder_impl.h" | 15 #include "chrome/browser/search/suggestions/image_decoder_impl.h" |
| 16 #include "chrome/browser/thumbnails/thumbnail_service.h" | 16 #include "chrome/browser/thumbnails/thumbnail_service.h" |
| 17 #include "chrome/browser/thumbnails/thumbnail_service_factory.h" | 17 #include "chrome/browser/thumbnails/thumbnail_service_factory.h" |
| 18 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| 19 #include "components/image_fetcher/image_fetcher_impl.h" | 19 #include "components/image_fetcher/core/image_fetcher_impl.h" |
| 20 #include "components/suggestions/image_encoder.h" | 20 #include "components/suggestions/image_encoder.h" |
| 21 #include "net/url_request/url_request.h" | 21 #include "net/url_request/url_request.h" |
| 22 #include "ui/gfx/image/image.h" | 22 #include "ui/gfx/image/image.h" |
| 23 #include "ui/gfx/image/image_skia.h" | 23 #include "ui/gfx/image/image_skia.h" |
| 24 | 24 |
| 25 // The delimiter between the first url and the fallback url passed to | 25 // The delimiter between the first url and the fallback url passed to |
| 26 // StartDataRequest. | 26 // StartDataRequest. |
| 27 const char kUrlDelimiter[] = "?fb="; | 27 const char kUrlDelimiter[] = "?fb="; |
| 28 | 28 |
| 29 // Set ThumbnailService now as Profile isn't thread safe. | 29 // Set ThumbnailService now as Profile isn't thread safe. |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 const SkBitmap* bitmap = image.ToSkBitmap(); | 130 const SkBitmap* bitmap = image.ToSkBitmap(); |
| 131 scoped_refptr<base::RefCountedBytes> encoded_data( | 131 scoped_refptr<base::RefCountedBytes> encoded_data( |
| 132 new base::RefCountedBytes()); | 132 new base::RefCountedBytes()); |
| 133 if (!suggestions::EncodeSkBitmapToJPEG(*bitmap, &encoded_data->data())) { | 133 if (!suggestions::EncodeSkBitmapToJPEG(*bitmap, &encoded_data->data())) { |
| 134 callback.Run(default_thumbnail_.get()); | 134 callback.Run(default_thumbnail_.get()); |
| 135 return; | 135 return; |
| 136 } | 136 } |
| 137 | 137 |
| 138 callback.Run(encoded_data.get()); | 138 callback.Run(encoded_data.get()); |
| 139 } | 139 } |
| OLD | NEW |