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_FAVICON_FAVICON_TAB_HELPER_H_ | 5 #ifndef CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_ |
6 #define CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_ | 6 #define CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "chrome/browser/favicon/favicon_download_helper_delegate.h" |
12 #include "chrome/browser/favicon/favicon_handler_delegate.h" | 13 #include "chrome/browser/favicon/favicon_handler_delegate.h" |
13 #include "chrome/browser/history/history_types.h" | 14 #include "chrome/browser/history/history_types.h" |
14 #include "chrome/common/favicon_url.h" | 15 #include "chrome/common/favicon_url.h" |
15 #include "content/public/browser/web_contents_observer.h" | 16 #include "content/public/browser/web_contents_observer.h" |
16 #include "content/public/browser/web_contents_user_data.h" | 17 #include "content/public/browser/web_contents_user_data.h" |
17 | 18 |
18 namespace gfx { | 19 namespace gfx { |
19 class Image; | 20 class Image; |
20 } | 21 } |
21 | 22 |
22 class GURL; | 23 class GURL; |
23 class FaviconHandler; | 24 class FaviconHandler; |
24 class Profile; | 25 class Profile; |
25 class SkBitmap; | 26 class SkBitmap; |
26 | 27 |
27 // FaviconTabHelper works with FaviconHandlers to fetch the favicons. | 28 // FaviconTabHelper works with FaviconHandlers to fetch the favicons. |
28 // | 29 // |
29 // FetchFavicon fetches the given page's icons. It requests the icons from the | 30 // FetchFavicon fetches the given page's icons. It requests the icons from the |
30 // history backend. If the icon is not available or expired, the icon will be | 31 // history backend. If the icon is not available or expired, the icon will be |
31 // downloaded and saved in the history backend. | 32 // downloaded and saved in the history backend. |
32 // | 33 // |
33 // DownloadImage downloads the specified icon and returns it through the given | 34 // DownloadImage downloads the specified icon and returns it through the given |
34 // callback. | 35 // callback. |
35 // | 36 // |
36 class FaviconTabHelper : public content::WebContentsObserver, | 37 class FaviconTabHelper : public content::WebContentsObserver, |
37 public FaviconHandlerDelegate, | 38 public FaviconHandlerDelegate, |
| 39 public FaviconDownloadHelperDelegate, |
38 public content::WebContentsUserData<FaviconTabHelper> { | 40 public content::WebContentsUserData<FaviconTabHelper> { |
39 public: | 41 public: |
40 virtual ~FaviconTabHelper(); | 42 virtual ~FaviconTabHelper(); |
41 | 43 |
42 // Initiates loading the favicon for the specified url. | 44 // Initiates loading the favicon for the specified url. |
43 void FetchFavicon(const GURL& url); | 45 void FetchFavicon(const GURL& url); |
44 | 46 |
45 // Returns the favicon for this tab, or IDR_DEFAULT_FAVICON if the tab does | 47 // Returns the favicon for this tab, or IDR_DEFAULT_FAVICON if the tab does |
46 // not have a favicon. The default implementation uses the current navigation | 48 // not have a favicon. The default implementation uses the current navigation |
47 // entry. This will return an empty bitmap if there are no navigation | 49 // entry. This will return an empty bitmap if there are no navigation |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 90 |
89 // content::WebContentsObserver overrides. | 91 // content::WebContentsObserver overrides. |
90 virtual void NavigateToPendingEntry( | 92 virtual void NavigateToPendingEntry( |
91 const GURL& url, | 93 const GURL& url, |
92 content::NavigationController::ReloadType reload_type) OVERRIDE; | 94 content::NavigationController::ReloadType reload_type) OVERRIDE; |
93 virtual void DidNavigateMainFrame( | 95 virtual void DidNavigateMainFrame( |
94 const content::LoadCommittedDetails& details, | 96 const content::LoadCommittedDetails& details, |
95 const content::FrameNavigateParams& params) OVERRIDE; | 97 const content::FrameNavigateParams& params) OVERRIDE; |
96 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 98 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
97 | 99 |
98 // Message handler for IconHostMsg_DidDownloadFavicon. | 100 // FaviconDownloadHelperDelegate overrides. |
99 void OnDidDownloadFavicon(int id, | 101 virtual void OnDidDownloadFavicon( |
100 const GURL& image_url, | 102 int id, |
101 bool errored, | 103 const GURL& image_url, |
102 int requested_size, | 104 bool errored, |
103 const std::vector<SkBitmap>& bitmaps); | 105 int requested_size, |
| 106 const std::vector<SkBitmap>& bitmaps) OVERRIDE; |
104 | 107 |
105 Profile* profile_; | 108 Profile* profile_; |
106 | 109 |
107 scoped_ptr<FaviconHandler> favicon_handler_; | 110 scoped_ptr<FaviconHandler> favicon_handler_; |
108 | 111 |
109 // Handles downloading touchicons. It is NULL if | 112 // Handles downloading touchicons. It is NULL if |
110 // browser_defaults::kEnableTouchIcon is false. | 113 // browser_defaults::kEnableTouchIcon is false. |
111 scoped_ptr<FaviconHandler> touch_icon_handler_; | 114 scoped_ptr<FaviconHandler> touch_icon_handler_; |
112 | 115 |
113 DISALLOW_COPY_AND_ASSIGN(FaviconTabHelper); | 116 DISALLOW_COPY_AND_ASSIGN(FaviconTabHelper); |
114 }; | 117 }; |
115 | 118 |
116 #endif // CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_ | 119 #endif // CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_ |
OLD | NEW |