OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_NEW_TAB_UI_H__ | 5 #ifndef CHROME_BROWSER_DOM_UI_NEW_TAB_UI_H__ |
6 #define CHROME_BROWSER_DOM_UI_NEW_TAB_UI_H__ | 6 #define CHROME_BROWSER_DOM_UI_NEW_TAB_UI_H__ |
7 | 7 |
8 #include "chrome/browser/bookmarks/bookmark_model.h" | 8 #include "chrome/browser/bookmarks/bookmark_model.h" |
9 #include "chrome/browser/dom_ui/dom_ui_host.h" | 9 #include "chrome/browser/dom_ui/dom_ui_host.h" |
10 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" | 10 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 // put here for clarity. | 29 // put here for clarity. |
30 | 30 |
31 class NewTabHTMLSource : public ChromeURLDataManager::DataSource { | 31 class NewTabHTMLSource : public ChromeURLDataManager::DataSource { |
32 public: | 32 public: |
33 NewTabHTMLSource(); | 33 NewTabHTMLSource(); |
34 | 34 |
35 // Called when the network layer has requested a resource underneath | 35 // Called when the network layer has requested a resource underneath |
36 // the path we registered. | 36 // the path we registered. |
37 virtual void StartDataRequest(const std::string& path, int request_id); | 37 virtual void StartDataRequest(const std::string& path, int request_id); |
38 | 38 |
| 39 virtual std::string GetMimeType(const std::string&) const { |
| 40 return "text/html"; |
| 41 } |
| 42 |
39 // Setters and getters for first_view. | 43 // Setters and getters for first_view. |
40 static void set_first_view(bool first_view) { first_view_ = first_view; } | 44 static void set_first_view(bool first_view) { first_view_ = first_view; } |
41 static bool first_view() { return first_view_; } | 45 static bool first_view() { return first_view_; } |
42 private: | 46 private: |
43 // Whether this is the is the first viewing of the new tab page and | 47 // Whether this is the is the first viewing of the new tab page and |
44 // we think it is the user's startup page. | 48 // we think it is the user's startup page. |
45 static bool first_view_; | 49 static bool first_view_; |
46 | 50 |
47 DISALLOW_EVIL_CONSTRUCTORS(NewTabHTMLSource); | 51 DISALLOW_EVIL_CONSTRUCTORS(NewTabHTMLSource); |
48 }; | 52 }; |
49 | 53 |
50 class IncognitoTabHTMLSource : public ChromeURLDataManager::DataSource { | 54 class IncognitoTabHTMLSource : public ChromeURLDataManager::DataSource { |
51 public: | 55 public: |
52 // Creates our datasource and sets our user message to a specific message | 56 // Creates our datasource and sets our user message to a specific message |
53 // from our string bundle. | 57 // from our string bundle. |
54 IncognitoTabHTMLSource(); | 58 IncognitoTabHTMLSource(); |
55 | 59 |
56 // Called when the network layer has requested a resource underneath | 60 // Called when the network layer has requested a resource underneath |
57 // the path we registered. | 61 // the path we registered. |
58 virtual void StartDataRequest(const std::string& path, int request_id); | 62 virtual void StartDataRequest(const std::string& path, int request_id); |
59 | 63 |
| 64 virtual std::string GetMimeType(const std::string&) const { |
| 65 return "text/html"; |
| 66 } |
| 67 |
60 private: | 68 private: |
61 DISALLOW_EVIL_CONSTRUCTORS(IncognitoTabHTMLSource); | 69 DISALLOW_EVIL_CONSTRUCTORS(IncognitoTabHTMLSource); |
62 }; | 70 }; |
63 | 71 |
64 // ThumbnailSource is the gateway between network-level chrome-resource: | 72 // ThumbnailSource is the gateway between network-level chrome-resource: |
65 // requests for thumbnails and the history backend that serves these. | 73 // requests for thumbnails and the history backend that serves these. |
66 class ThumbnailSource : public ChromeURLDataManager::DataSource { | 74 class ThumbnailSource : public ChromeURLDataManager::DataSource { |
67 public: | 75 public: |
68 explicit ThumbnailSource(Profile* profile); | 76 explicit ThumbnailSource(Profile* profile); |
69 | 77 |
70 // Called when the network layer has requested a resource underneath | 78 // Called when the network layer has requested a resource underneath |
71 // the path we registered. | 79 // the path we registered. |
72 virtual void StartDataRequest(const std::string& path, int request_id); | 80 virtual void StartDataRequest(const std::string& path, int request_id); |
73 | 81 |
| 82 virtual std::string GetMimeType(const std::string&) const { |
| 83 // Rely on image decoder inferring the correct type. |
| 84 return std::string(); |
| 85 } |
| 86 |
74 // Called when thumbnail data is available from the history backend. | 87 // Called when thumbnail data is available from the history backend. |
75 void OnThumbnailDataAvailable( | 88 void OnThumbnailDataAvailable( |
76 HistoryService::Handle request_handle, | 89 HistoryService::Handle request_handle, |
77 scoped_refptr<RefCountedBytes> data); | 90 scoped_refptr<RefCountedBytes> data); |
78 | 91 |
79 private: | 92 private: |
80 Profile* profile_; | 93 Profile* profile_; |
81 CancelableRequestConsumerT<int, 0> cancelable_consumer_; | 94 CancelableRequestConsumerT<int, 0> cancelable_consumer_; |
82 | 95 |
83 // Raw PNG representation of the thumbnail to show when the thumbnail | 96 // Raw PNG representation of the thumbnail to show when the thumbnail |
84 // database doesn't have a thumbnail for a webpage. | 97 // database doesn't have a thumbnail for a webpage. |
85 scoped_refptr<RefCountedBytes> default_thumbnail_; | 98 scoped_refptr<RefCountedBytes> default_thumbnail_; |
86 | 99 |
87 DISALLOW_EVIL_CONSTRUCTORS(ThumbnailSource); | 100 DISALLOW_EVIL_CONSTRUCTORS(ThumbnailSource); |
88 }; | 101 }; |
89 | 102 |
90 // ThumbnailSource is the gateway between network-level chrome-resource: | 103 // ThumbnailSource is the gateway between network-level chrome-resource: |
91 // requests for favicons and the history backend that serves these. | 104 // requests for favicons and the history backend that serves these. |
92 class FavIconSource : public ChromeURLDataManager::DataSource { | 105 class FavIconSource : public ChromeURLDataManager::DataSource { |
93 public: | 106 public: |
94 explicit FavIconSource(Profile* profile); | 107 explicit FavIconSource(Profile* profile); |
95 | 108 |
96 // Called when the network layer has requested a resource underneath | 109 // Called when the network layer has requested a resource underneath |
97 // the path we registered. | 110 // the path we registered. |
98 virtual void StartDataRequest(const std::string& path, int request_id); | 111 virtual void StartDataRequest(const std::string& path, int request_id); |
99 | 112 |
| 113 virtual std::string GetMimeType(const std::string&) const { |
| 114 // Rely on image decoder inferring the correct type. |
| 115 return std::string(); |
| 116 } |
| 117 |
100 // Called when favicon data is available from the history backend. | 118 // Called when favicon data is available from the history backend. |
101 void OnFavIconDataAvailable( | 119 void OnFavIconDataAvailable( |
102 HistoryService::Handle request_handle, | 120 HistoryService::Handle request_handle, |
103 bool know_favicon, | 121 bool know_favicon, |
104 scoped_refptr<RefCountedBytes> data, | 122 scoped_refptr<RefCountedBytes> data, |
105 bool expired, | 123 bool expired, |
106 GURL url); | 124 GURL url); |
107 | 125 |
108 private: | 126 private: |
109 Profile* profile_; | 127 Profile* profile_; |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 | 353 |
336 // A pointer to the handler for most visited. | 354 // A pointer to the handler for most visited. |
337 // Owned by the DOMUIHost. | 355 // Owned by the DOMUIHost. |
338 MostVisitedHandler* most_visited_handler_; | 356 MostVisitedHandler* most_visited_handler_; |
339 | 357 |
340 DISALLOW_EVIL_CONSTRUCTORS(NewTabUIContents); | 358 DISALLOW_EVIL_CONSTRUCTORS(NewTabUIContents); |
341 }; | 359 }; |
342 | 360 |
343 #endif // CHROME_BROWSER_DOM_UI_NEW_TAB_UI_H__ | 361 #endif // CHROME_BROWSER_DOM_UI_NEW_TAB_UI_H__ |
344 | 362 |
OLD | NEW |