| 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" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 12 #include "content/public/browser/url_data_source_delegate.h" |
| 13 | 13 |
| 14 class Profile; | 14 class Profile; |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class RefCountedMemory; | 17 class RefCountedMemory; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace thumbnails { | 20 namespace thumbnails { |
| 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 ChromeURLDataManager::DataSource { | 26 class ThumbnailSource : public content::URLDataSourceDelegate { |
| 27 public: | 27 public: |
| 28 explicit ThumbnailSource(Profile* profile); | 28 explicit ThumbnailSource(Profile* profile); |
| 29 | 29 |
| 30 // Called when the network layer has requested a resource underneath | 30 // content::URLDataSourceDelegate implementation. |
| 31 // the path we registered. | 31 virtual std::string GetSource() OVERRIDE; |
| 32 virtual void StartDataRequest(const std::string& path, | 32 virtual void StartDataRequest(const std::string& path, |
| 33 bool is_incognito, | 33 bool is_incognito, |
| 34 int request_id) OVERRIDE; | 34 int request_id) OVERRIDE; |
| 35 | |
| 36 virtual std::string GetMimeType(const std::string& path) const OVERRIDE; | 35 virtual std::string GetMimeType(const std::string& path) const OVERRIDE; |
| 37 | |
| 38 virtual MessageLoop* MessageLoopForRequestPath( | 36 virtual MessageLoop* MessageLoopForRequestPath( |
| 39 const std::string& path) const OVERRIDE; | 37 const std::string& path) const OVERRIDE; |
| 40 | 38 |
| 41 private: | 39 private: |
| 42 virtual ~ThumbnailSource(); | 40 virtual ~ThumbnailSource(); |
| 43 | 41 |
| 44 // Send the default thumbnail when we are missing a real one. | 42 // Send the default thumbnail when we are missing a real one. |
| 45 void SendDefaultThumbnail(int request_id); | 43 void SendDefaultThumbnail(int request_id); |
| 46 | 44 |
| 47 // Raw PNG representation of the thumbnail to show when the thumbnail | 45 // Raw PNG representation of the thumbnail to show when the thumbnail |
| 48 // database doesn't have a thumbnail for a webpage. | 46 // database doesn't have a thumbnail for a webpage. |
| 49 scoped_refptr<base::RefCountedMemory> default_thumbnail_; | 47 scoped_refptr<base::RefCountedMemory> default_thumbnail_; |
| 50 | 48 |
| 51 // ThumbnailService. | 49 // ThumbnailService. |
| 52 scoped_refptr<thumbnails::ThumbnailService> thumbnail_service_; | 50 scoped_refptr<thumbnails::ThumbnailService> thumbnail_service_; |
| 53 | 51 |
| 54 DISALLOW_COPY_AND_ASSIGN(ThumbnailSource); | 52 DISALLOW_COPY_AND_ASSIGN(ThumbnailSource); |
| 55 }; | 53 }; |
| 56 | 54 |
| 57 #endif // CHROME_BROWSER_UI_WEBUI_NTP_THUMBNAIL_SOURCE_H_ | 55 #endif // CHROME_BROWSER_UI_WEBUI_NTP_THUMBNAIL_SOURCE_H_ |
| OLD | NEW |