| 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 #ifndef CHROME_BROWSER_SEARCH_THUMBNAIL_SOURCE_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_THUMBNAIL_SOURCE_H_ |
| 6 #define CHROME_BROWSER_SEARCH_THUMBNAIL_SOURCE_H_ | 6 #define CHROME_BROWSER_SEARCH_THUMBNAIL_SOURCE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "content/public/browser/url_data_source.h" | 14 #include "content/public/browser/url_data_source.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 | 16 |
| 17 class Profile; | 17 class Profile; |
| 18 class SkBitmap; | 18 class SkBitmap; |
| 19 | 19 |
| 20 namespace base { | 20 namespace base { |
| 21 class RefCountedMemory; | 21 class RefCountedMemory; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace gfx { |
| 25 class Image; |
| 26 } |
| 27 |
| 24 namespace image_fetcher { | 28 namespace image_fetcher { |
| 25 class ImageFetcher; | 29 class ImageFetcher; |
| 26 } | 30 } |
| 27 | 31 |
| 28 namespace thumbnails { | 32 namespace thumbnails { |
| 29 class ThumbnailService; | 33 class ThumbnailService; |
| 30 } | 34 } |
| 31 | 35 |
| 32 // ThumbnailSource is the gateway between network-level chrome: requests for | 36 // ThumbnailSource is the gateway between network-level chrome: requests for |
| 33 // thumbnails and the history/top-sites backend that serves these. | 37 // thumbnails and the history/top-sites backend that serves these. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 54 void ExtractPageAndThumbnailUrls(const std::string& path, | 58 void ExtractPageAndThumbnailUrls(const std::string& path, |
| 55 GURL* page_url, | 59 GURL* page_url, |
| 56 GURL* fallback_thumbnail_url); | 60 GURL* fallback_thumbnail_url); |
| 57 | 61 |
| 58 private: | 62 private: |
| 59 // Returns a JPEG-encoded |bitmap| to the |callback| if valid, or the default | 63 // Returns a JPEG-encoded |bitmap| to the |callback| if valid, or the default |
| 60 // thumbnail. | 64 // thumbnail. |
| 61 void SendFetchedUrlImage( | 65 void SendFetchedUrlImage( |
| 62 const content::URLDataSource::GotDataCallback& callback, | 66 const content::URLDataSource::GotDataCallback& callback, |
| 63 const GURL& url, | 67 const GURL& url, |
| 64 const SkBitmap* bitmap); | 68 const gfx::Image& image); |
| 65 | 69 |
| 66 // Raw PNG representation of the thumbnail to show when the thumbnail | 70 // Raw PNG representation of the thumbnail to show when the thumbnail |
| 67 // database doesn't have a thumbnail for a webpage. | 71 // database doesn't have a thumbnail for a webpage. |
| 68 scoped_refptr<base::RefCountedMemory> default_thumbnail_; | 72 scoped_refptr<base::RefCountedMemory> default_thumbnail_; |
| 69 | 73 |
| 70 // ThumbnailService. | 74 // ThumbnailService. |
| 71 scoped_refptr<thumbnails::ThumbnailService> thumbnail_service_; | 75 scoped_refptr<thumbnails::ThumbnailService> thumbnail_service_; |
| 72 | 76 |
| 73 // ImageFetcher. | 77 // ImageFetcher. |
| 74 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher_; | 78 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher_; |
| 75 | 79 |
| 76 // Indicate that, when a URL for which we don't have a thumbnail is requested | 80 // Indicate that, when a URL for which we don't have a thumbnail is requested |
| 77 // from this source, then Chrome should capture a thumbnail next time it | 81 // from this source, then Chrome should capture a thumbnail next time it |
| 78 // navigates to this URL. This is useful when the thumbnail URLs are generated | 82 // navigates to this URL. This is useful when the thumbnail URLs are generated |
| 79 // by an external service rather than TopSites, so Chrome can learn about the | 83 // by an external service rather than TopSites, so Chrome can learn about the |
| 80 // URLs for which it should get thumbnails. Sources that capture thumbnails | 84 // URLs for which it should get thumbnails. Sources that capture thumbnails |
| 81 // are also be more lenient when matching thumbnail URLs by checking for | 85 // are also be more lenient when matching thumbnail URLs by checking for |
| 82 // existing thumbnails in the database that contain a URL matching the prefix | 86 // existing thumbnails in the database that contain a URL matching the prefix |
| 83 // of the requested URL. | 87 // of the requested URL. |
| 84 const bool capture_thumbnails_; | 88 const bool capture_thumbnails_; |
| 85 | 89 |
| 86 base::WeakPtrFactory<ThumbnailSource> weak_ptr_factory_; | 90 base::WeakPtrFactory<ThumbnailSource> weak_ptr_factory_; |
| 87 | 91 |
| 88 DISALLOW_COPY_AND_ASSIGN(ThumbnailSource); | 92 DISALLOW_COPY_AND_ASSIGN(ThumbnailSource); |
| 89 }; | 93 }; |
| 90 | 94 |
| 91 #endif // CHROME_BROWSER_SEARCH_THUMBNAIL_SOURCE_H_ | 95 #endif // CHROME_BROWSER_SEARCH_THUMBNAIL_SOURCE_H_ |
| OLD | NEW |