| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_DOM_UI_DOM_UI_THUMBNAIL_SOURCE_H_ | 5 #ifndef CHROME_BROWSER_DOM_UI_DOM_UI_THUMBNAIL_SOURCE_H_ |
| 6 #define CHROME_BROWSER_DOM_UI_DOM_UI_THUMBNAIL_SOURCE_H_ | 6 #define CHROME_BROWSER_DOM_UI_DOM_UI_THUMBNAIL_SOURCE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
| 13 #include "base/ref_counted_memory.h" |
| 13 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" | 14 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" |
| 14 #include "chrome/browser/history/history.h" | |
| 15 #include "chrome/common/notification_registrar.h" | |
| 16 | 15 |
| 17 class Profile; | 16 class Profile; |
| 18 | 17 |
| 19 namespace history { | 18 namespace history { |
| 20 class TopSites; | 19 class TopSites; |
| 21 } | 20 } |
| 22 | 21 |
| 23 // ThumbnailSource is the gateway between network-level chrome: requests for | 22 // ThumbnailSource is the gateway between network-level chrome: requests for |
| 24 // thumbnails and the history/top-sites backend that serves these. | 23 // thumbnails and the history/top-sites backend that serves these. |
| 25 class DOMUIThumbnailSource : public ChromeURLDataManager::DataSource { | 24 class DOMUIThumbnailSource : public ChromeURLDataManager::DataSource { |
| 26 public: | 25 public: |
| 27 explicit DOMUIThumbnailSource(Profile* profile); | 26 explicit DOMUIThumbnailSource(Profile* profile); |
| 28 | 27 |
| 29 // Called when the network layer has requested a resource underneath | 28 // Called when the network layer has requested a resource underneath |
| 30 // the path we registered. | 29 // the path we registered. |
| 31 virtual void StartDataRequest(const std::string& path, | 30 virtual void StartDataRequest(const std::string& path, |
| 32 bool is_off_the_record, | 31 bool is_off_the_record, |
| 33 int request_id); | 32 int request_id); |
| 34 | 33 |
| 35 virtual std::string GetMimeType(const std::string& path) const; | 34 virtual std::string GetMimeType(const std::string& path) const; |
| 36 | 35 |
| 37 virtual MessageLoop* MessageLoopForRequestPath(const std::string& path) const; | 36 virtual MessageLoop* MessageLoopForRequestPath(const std::string& path) const; |
| 38 | 37 |
| 39 // Called when thumbnail data is available from the history backend. | |
| 40 void OnThumbnailDataAvailable(HistoryService::Handle request_handle, | |
| 41 scoped_refptr<RefCountedBytes> data); | |
| 42 | |
| 43 private: | 38 private: |
| 44 virtual ~DOMUIThumbnailSource(); | 39 virtual ~DOMUIThumbnailSource(); |
| 45 | 40 |
| 46 // Send the default thumbnail when we are missing a real one. | 41 // Send the default thumbnail when we are missing a real one. |
| 47 void SendDefaultThumbnail(int request_id); | 42 void SendDefaultThumbnail(int request_id); |
| 48 | 43 |
| 49 Profile* profile_; | 44 Profile* profile_; |
| 50 | 45 |
| 51 CancelableRequestConsumerT<int, 0> cancelable_consumer_; | |
| 52 | |
| 53 // Raw PNG representation of the thumbnail to show when the thumbnail | 46 // Raw PNG representation of the thumbnail to show when the thumbnail |
| 54 // database doesn't have a thumbnail for a webpage. | 47 // database doesn't have a thumbnail for a webpage. |
| 55 scoped_refptr<RefCountedMemory> default_thumbnail_; | 48 scoped_refptr<RefCountedMemory> default_thumbnail_; |
| 56 | 49 |
| 57 // TopSites. If non-null we're using TopSites. | 50 // TopSites. |
| 58 scoped_refptr<history::TopSites> top_sites_; | 51 scoped_refptr<history::TopSites> top_sites_; |
| 59 | 52 |
| 60 DISALLOW_COPY_AND_ASSIGN(DOMUIThumbnailSource); | 53 DISALLOW_COPY_AND_ASSIGN(DOMUIThumbnailSource); |
| 61 }; | 54 }; |
| 62 | 55 |
| 63 #endif // CHROME_BROWSER_DOM_UI_DOM_UI_THUMBNAIL_SOURCE_H_ | 56 #endif // CHROME_BROWSER_DOM_UI_DOM_UI_THUMBNAIL_SOURCE_H_ |
| OLD | NEW |