| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Contains code for managing local HTML UI at chrome:// URLs. |
| 6 |
| 7 #ifndef CHROME_BROWSER_DOM_UI_CONTENTS_H__ |
| 8 #define CHROME_BROWSER_DOM_UI_CONTENTS_H__ |
| 9 |
| 10 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" |
| 11 #include "chrome/browser/web_contents.h" |
| 12 #include "webkit/glue/webpreferences.h" |
| 13 |
| 14 class DOMUI; |
| 15 class render_view_host; |
| 16 |
| 17 // FavIconSource is the gateway between network-level chrome: |
| 18 // requests for favicons and the history backend that serves these. |
| 19 class FavIconSource : public ChromeURLDataManager::DataSource { |
| 20 public: |
| 21 explicit FavIconSource(Profile* profile); |
| 22 |
| 23 // Called when the network layer has requested a resource underneath |
| 24 // the path we registered. |
| 25 virtual void StartDataRequest(const std::string& path, int request_id); |
| 26 |
| 27 virtual std::string GetMimeType(const std::string&) const { |
| 28 // Rely on image decoder inferring the correct type. |
| 29 return std::string(); |
| 30 } |
| 31 |
| 32 // Called when favicon data is available from the history backend. |
| 33 void OnFavIconDataAvailable( |
| 34 HistoryService::Handle request_handle, |
| 35 bool know_favicon, |
| 36 scoped_refptr<RefCountedBytes> data, |
| 37 bool expired, |
| 38 GURL url); |
| 39 |
| 40 private: |
| 41 Profile* const profile_; |
| 42 CancelableRequestConsumerT<int, 0> cancelable_consumer_; |
| 43 |
| 44 // Raw PNG representation of the favicon to show when the favicon |
| 45 // database doesn't have a favicon for a webpage. |
| 46 scoped_refptr<RefCountedBytes> default_favicon_; |
| 47 |
| 48 DISALLOW_COPY_AND_ASSIGN(FavIconSource); |
| 49 }; |
| 50 |
| 51 // ThumbnailSource is the gateway between network-level chrome: |
| 52 // requests for thumbnails and the history backend that serves these. |
| 53 class ThumbnailSource : public ChromeURLDataManager::DataSource { |
| 54 public: |
| 55 explicit ThumbnailSource(Profile* profile); |
| 56 |
| 57 // Called when the network layer has requested a resource underneath |
| 58 // the path we registered. |
| 59 virtual void StartDataRequest(const std::string& path, int request_id); |
| 60 |
| 61 virtual std::string GetMimeType(const std::string&) const { |
| 62 // Rely on image decoder inferring the correct type. |
| 63 return std::string(); |
| 64 } |
| 65 |
| 66 // Called when thumbnail data is available from the history backend. |
| 67 void OnThumbnailDataAvailable( |
| 68 HistoryService::Handle request_handle, |
| 69 scoped_refptr<RefCountedBytes> data); |
| 70 |
| 71 private: |
| 72 Profile* const profile_; |
| 73 CancelableRequestConsumerT<int, 0> cancelable_consumer_; |
| 74 |
| 75 // Raw PNG representation of the thumbnail to show when the thumbnail |
| 76 // database doesn't have a thumbnail for a webpage. |
| 77 scoped_refptr<RefCountedBytes> default_thumbnail_; |
| 78 |
| 79 DISALLOW_COPY_AND_ASSIGN(ThumbnailSource); |
| 80 }; |
| 81 |
| 82 // Exposed for use by BrowserURLHandler. |
| 83 bool DOMUIContentsCanHandleURL(GURL* url, TabContentsType* result_type); |
| 84 |
| 85 class DOMUIContents : public WebContents { |
| 86 public: |
| 87 DOMUIContents(Profile* profile, |
| 88 SiteInstance* instance, |
| 89 RenderViewHostFactory* render_view_factory); |
| 90 ~DOMUIContents(); |
| 91 |
| 92 // |
| 93 // WebContents overrides |
| 94 // |
| 95 virtual void ProcessDOMUIMessage(const std::string& message, |
| 96 const std::string& content); |
| 97 virtual bool CreateRenderViewForRenderManager( |
| 98 RenderViewHost* render_view_host); |
| 99 // Override this method so we can ensure that javascript and image loading |
| 100 // are always on even for DOMUIHost tabs. |
| 101 virtual WebPreferences GetWebkitPrefs(); |
| 102 |
| 103 // |
| 104 // TabContents overrides |
| 105 // |
| 106 virtual void UpdateHistoryForNavigation(const GURL& url, |
| 107 const ViewHostMsg_FrameNavigate_Params& params) { } |
| 108 virtual bool NavigateToPendingEntry(bool reload); |
| 109 |
| 110 // Return the scheme used. We currently use chrome: |
| 111 static const std::string GetScheme(); |
| 112 |
| 113 private: |
| 114 // Return a DOM UI for the provided URL. |
| 115 DOMUI* GetDOMUIForURL(const GURL& url); |
| 116 |
| 117 // The DOMUI we own and show. |
| 118 DOMUI* current_ui_; |
| 119 |
| 120 DISALLOW_COPY_AND_ASSIGN(DOMUIContents); |
| 121 }; |
| 122 |
| 123 #endif // CHROME_BROWSER_DOM_UI_CONTENTS_H__ |
| OLD | NEW |