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_UI_WEBUI_NTP_THUMBNAIL_SOURCE_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_THUMBNAIL_SOURCE_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_NTP_THUMBNAIL_SOURCE_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_NTP_THUMBNAIL_SOURCE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 class ThumbnailService; | 21 class ThumbnailService; |
22 } | 22 } |
23 | 23 |
24 // ThumbnailSource is the gateway between network-level chrome: requests for | 24 // ThumbnailSource is the gateway between network-level chrome: requests for |
25 // thumbnails and the history/top-sites backend that serves these. | 25 // thumbnails and the history/top-sites backend that serves these. |
26 class ThumbnailSource : public content::URLDataSource { | 26 class ThumbnailSource : public content::URLDataSource { |
27 public: | 27 public: |
28 ThumbnailSource(Profile* profile, bool capture_thumbnails); | 28 ThumbnailSource(Profile* profile, bool capture_thumbnails); |
29 | 29 |
30 // content::URLDataSource implementation. | 30 // content::URLDataSource implementation. |
31 virtual std::string GetSource() const override; | 31 std::string GetSource() const override; |
32 virtual void StartDataRequest( | 32 void StartDataRequest( |
33 const std::string& path, | 33 const std::string& path, |
34 int render_process_id, | 34 int render_process_id, |
35 int render_frame_id, | 35 int render_frame_id, |
36 const content::URLDataSource::GotDataCallback& callback) override; | 36 const content::URLDataSource::GotDataCallback& callback) override; |
37 virtual std::string GetMimeType(const std::string& path) const override; | 37 std::string GetMimeType(const std::string& path) const override; |
38 virtual base::MessageLoop* MessageLoopForRequestPath( | 38 base::MessageLoop* MessageLoopForRequestPath( |
39 const std::string& path) const override; | 39 const std::string& path) const override; |
40 virtual bool ShouldServiceRequest( | 40 bool ShouldServiceRequest(const net::URLRequest* request) const override; |
41 const net::URLRequest* request) const override; | |
42 | 41 |
43 private: | 42 private: |
44 virtual ~ThumbnailSource(); | 43 ~ThumbnailSource() override; |
45 | 44 |
46 // Raw PNG representation of the thumbnail to show when the thumbnail | 45 // Raw PNG representation of the thumbnail to show when the thumbnail |
47 // database doesn't have a thumbnail for a webpage. | 46 // database doesn't have a thumbnail for a webpage. |
48 scoped_refptr<base::RefCountedMemory> default_thumbnail_; | 47 scoped_refptr<base::RefCountedMemory> default_thumbnail_; |
49 | 48 |
50 // ThumbnailService. | 49 // ThumbnailService. |
51 scoped_refptr<thumbnails::ThumbnailService> thumbnail_service_; | 50 scoped_refptr<thumbnails::ThumbnailService> thumbnail_service_; |
52 | 51 |
53 // Only used when servicing requests on the UI thread. | 52 // Only used when servicing requests on the UI thread. |
54 Profile* const profile_; | 53 Profile* const profile_; |
55 | 54 |
56 // Indicate that, when a URL for which we don't have a thumbnail is requested | 55 // Indicate that, when a URL for which we don't have a thumbnail is requested |
57 // from this source, then Chrome should capture a thumbnail next time it | 56 // from this source, then Chrome should capture a thumbnail next time it |
58 // navigates to this URL. This is useful when the thumbnail URLs are generated | 57 // navigates to this URL. This is useful when the thumbnail URLs are generated |
59 // by an external service rather than TopSites, so Chrome can learn about the | 58 // by an external service rather than TopSites, so Chrome can learn about the |
60 // URLs for which it should get thumbnails. Sources that capture thumbnails | 59 // URLs for which it should get thumbnails. Sources that capture thumbnails |
61 // are also be more lenient when matching thumbnail URLs by checking for | 60 // are also be more lenient when matching thumbnail URLs by checking for |
62 // existing thumbnails in the database that contain a URL matching the prefix | 61 // existing thumbnails in the database that contain a URL matching the prefix |
63 // of the requested URL. | 62 // of the requested URL. |
64 const bool capture_thumbnails_; | 63 const bool capture_thumbnails_; |
65 | 64 |
66 DISALLOW_COPY_AND_ASSIGN(ThumbnailSource); | 65 DISALLOW_COPY_AND_ASSIGN(ThumbnailSource); |
67 }; | 66 }; |
68 | 67 |
69 #endif // CHROME_BROWSER_UI_WEBUI_NTP_THUMBNAIL_SOURCE_H_ | 68 #endif // CHROME_BROWSER_UI_WEBUI_NTP_THUMBNAIL_SOURCE_H_ |
OLD | NEW |