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 "components/favicon/core/browser/favicon_client.h" | 12 #include "components/favicon/core/browser/favicon_client.h" |
13 #include "components/favicon/core/favicon_handler_delegate.h" | 13 #include "components/favicon/core/favicon_driver.h" |
14 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
15 #include "content/public/browser/web_contents_user_data.h" | 15 #include "content/public/browser/web_contents_user_data.h" |
16 #include "content/public/common/favicon_url.h" | 16 #include "content/public/common/favicon_url.h" |
17 | 17 |
18 namespace gfx { | 18 namespace gfx { |
19 class Image; | 19 class Image; |
20 } | 20 } |
21 | 21 |
22 class GURL; | 22 class GURL; |
23 class FaviconHandler; | 23 class FaviconHandler; |
24 class Profile; | 24 class Profile; |
25 class SkBitmap; | 25 class SkBitmap; |
26 | 26 |
27 // FaviconTabHelper works with FaviconHandlers to fetch the favicons. | 27 // FaviconTabHelper works with FaviconHandlers to fetch the favicons. |
28 // | 28 // |
29 // FetchFavicon fetches the given page's icons. It requests the icons from the | 29 // 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 | 30 // history backend. If the icon is not available or expired, the icon will be |
31 // downloaded and saved in the history backend. | 31 // downloaded and saved in the history backend. |
32 // | 32 // |
33 class FaviconTabHelper : public content::WebContentsObserver, | 33 class FaviconTabHelper : public content::WebContentsObserver, |
34 public FaviconClient, | 34 public FaviconClient, |
35 public FaviconHandlerDelegate, | 35 public FaviconDriver, |
36 public content::WebContentsUserData<FaviconTabHelper> { | 36 public content::WebContentsUserData<FaviconTabHelper> { |
37 public: | 37 public: |
38 virtual ~FaviconTabHelper(); | 38 virtual ~FaviconTabHelper(); |
39 | 39 |
40 // Initiates loading the favicon for the specified url. | 40 // Initiates loading the favicon for the specified url. |
41 void FetchFavicon(const GURL& url); | 41 void FetchFavicon(const GURL& url); |
42 | 42 |
43 // Returns the favicon for this tab, or IDR_DEFAULT_FAVICON if the tab does | 43 // Returns the favicon for this tab, or IDR_DEFAULT_FAVICON if the tab does |
44 // not have a favicon. The default implementation uses the current navigation | 44 // not have a favicon. The default implementation uses the current navigation |
45 // entry. This will return an empty bitmap if there are no navigation | 45 // entry. This will return an empty bitmap if there are no navigation |
(...skipping 15 matching lines...) Expand all Loading... |
61 | 61 |
62 // content::WebContentsObserver override. Must be public, because also | 62 // content::WebContentsObserver override. Must be public, because also |
63 // called from PrerenderContents. | 63 // called from PrerenderContents. |
64 virtual void DidUpdateFaviconURL( | 64 virtual void DidUpdateFaviconURL( |
65 int32 page_id, | 65 int32 page_id, |
66 const std::vector<content::FaviconURL>& candidates) OVERRIDE; | 66 const std::vector<content::FaviconURL>& candidates) OVERRIDE; |
67 | 67 |
68 // Saves the favicon for the current page. | 68 // Saves the favicon for the current page. |
69 void SaveFavicon(); | 69 void SaveFavicon(); |
70 | 70 |
71 // FaviconHandlerDelegate methods. | 71 // FaviconDriver methods. |
72 virtual content::NavigationEntry* GetActiveEntry() OVERRIDE; | 72 virtual content::NavigationEntry* GetActiveEntry() OVERRIDE; |
73 virtual int StartDownload(const GURL& url, int max_bitmap_size) OVERRIDE; | 73 virtual int StartDownload(const GURL& url, int max_bitmap_size) OVERRIDE; |
74 virtual void NotifyFaviconUpdated(bool icon_url_changed) OVERRIDE; | 74 virtual void NotifyFaviconUpdated(bool icon_url_changed) OVERRIDE; |
75 virtual bool IsOffTheRecord() OVERRIDE; | 75 virtual bool IsOffTheRecord() OVERRIDE; |
76 | 76 |
77 // Favicon download callback. | 77 // Favicon download callback. |
78 void DidDownloadFavicon( | 78 void DidDownloadFavicon( |
79 int id, | 79 int id, |
80 int http_status_code, | 80 int http_status_code, |
81 const GURL& image_url, | 81 const GURL& image_url, |
(...skipping 23 matching lines...) Expand all Loading... |
105 scoped_ptr<FaviconHandler> favicon_handler_; | 105 scoped_ptr<FaviconHandler> favicon_handler_; |
106 | 106 |
107 // Handles downloading touchicons. It is NULL if | 107 // Handles downloading touchicons. It is NULL if |
108 // browser_defaults::kEnableTouchIcon is false. | 108 // browser_defaults::kEnableTouchIcon is false. |
109 scoped_ptr<FaviconHandler> touch_icon_handler_; | 109 scoped_ptr<FaviconHandler> touch_icon_handler_; |
110 | 110 |
111 DISALLOW_COPY_AND_ASSIGN(FaviconTabHelper); | 111 DISALLOW_COPY_AND_ASSIGN(FaviconTabHelper); |
112 }; | 112 }; |
113 | 113 |
114 #endif // CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_ | 114 #endif // CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_ |
OLD | NEW |