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_driver.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 namespace content { | |
23 struct FaviconStatus; | |
24 } | |
25 | |
22 class GURL; | 26 class GURL; |
23 class FaviconHandler; | 27 class FaviconHandler; |
24 class Profile; | 28 class Profile; |
25 class SkBitmap; | 29 class SkBitmap; |
26 | 30 |
27 // FaviconTabHelper works with FaviconHandlers to fetch the favicons. | 31 // FaviconTabHelper works with FaviconHandlers to fetch the favicons. |
28 // | 32 // |
29 // FetchFavicon fetches the given page's icons. It requests the icons from the | 33 // 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 | 34 // history backend. If the icon is not available or expired, the icon will be |
31 // downloaded and saved in the history backend. | 35 // downloaded and saved in the history backend. |
(...skipping 29 matching lines...) Expand all Loading... | |
61 | 65 |
62 // content::WebContentsObserver override. Must be public, because also | 66 // content::WebContentsObserver override. Must be public, because also |
63 // called from PrerenderContents. | 67 // called from PrerenderContents. |
64 virtual void DidUpdateFaviconURL( | 68 virtual void DidUpdateFaviconURL( |
65 const std::vector<content::FaviconURL>& candidates) OVERRIDE; | 69 const std::vector<content::FaviconURL>& candidates) OVERRIDE; |
66 | 70 |
67 // Saves the favicon for the current page. | 71 // Saves the favicon for the current page. |
68 void SaveFavicon(); | 72 void SaveFavicon(); |
69 | 73 |
70 // FaviconDriver methods. | 74 // FaviconDriver methods. |
71 virtual content::NavigationEntry* GetActiveEntry() OVERRIDE; | |
72 virtual int StartDownload(const GURL& url, int max_bitmap_size) OVERRIDE; | 75 virtual int StartDownload(const GURL& url, int max_bitmap_size) OVERRIDE; |
73 virtual void NotifyFaviconUpdated(bool icon_url_changed) OVERRIDE; | 76 virtual void NotifyFaviconUpdated(bool icon_url_changed) OVERRIDE; |
74 virtual bool IsOffTheRecord() OVERRIDE; | 77 virtual bool IsOffTheRecord() OVERRIDE; |
78 virtual const gfx::Image GetActiveFaviconImage() OVERRIDE; | |
79 virtual const GURL GetActiveFaviconURL() OVERRIDE; | |
80 virtual bool GetActiveFaviconValidity() OVERRIDE; | |
81 virtual const GURL GetActiveURL() OVERRIDE; | |
82 virtual void SetActiveFaviconImage(gfx::Image image) OVERRIDE; | |
83 virtual void SetActiveFaviconURL(GURL url) OVERRIDE; | |
84 virtual void SetActiveFaviconValidity(bool validity) OVERRIDE; | |
75 | 85 |
76 // Favicon download callback. | 86 // Favicon download callback. |
77 void DidDownloadFavicon( | 87 void DidDownloadFavicon( |
78 int id, | 88 int id, |
79 int http_status_code, | 89 int http_status_code, |
80 const GURL& image_url, | 90 const GURL& image_url, |
81 const std::vector<SkBitmap>& bitmaps, | 91 const std::vector<SkBitmap>& bitmaps, |
82 const std::vector<gfx::Size>& original_bitmap_sizes); | 92 const std::vector<gfx::Size>& original_bitmap_sizes); |
83 | 93 |
84 // FaviconClient implementation: | 94 // FaviconClient implementation: |
85 virtual FaviconService* GetFaviconService() OVERRIDE; | 95 virtual FaviconService* GetFaviconService() OVERRIDE; |
86 virtual bool IsBookmarked(const GURL& url) OVERRIDE; | 96 virtual bool IsBookmarked(const GURL& url) OVERRIDE; |
87 | 97 |
88 private: | 98 private: |
89 explicit FaviconTabHelper(content::WebContents* web_contents); | 99 explicit FaviconTabHelper(content::WebContents* web_contents); |
90 friend class content::WebContentsUserData<FaviconTabHelper>; | 100 friend class content::WebContentsUserData<FaviconTabHelper>; |
91 | 101 |
92 // content::WebContentsObserver overrides. | 102 // content::WebContentsObserver overrides. |
93 virtual void DidStartNavigationToPendingEntry( | 103 virtual void DidStartNavigationToPendingEntry( |
94 const GURL& url, | 104 const GURL& url, |
95 content::NavigationController::ReloadType reload_type) OVERRIDE; | 105 content::NavigationController::ReloadType reload_type) OVERRIDE; |
96 virtual void DidNavigateMainFrame( | 106 virtual void DidNavigateMainFrame( |
97 const content::LoadCommittedDetails& details, | 107 const content::LoadCommittedDetails& details, |
98 const content::FrameNavigateParams& params) OVERRIDE; | 108 const content::FrameNavigateParams& params) OVERRIDE; |
99 | 109 |
110 // FaviconDriver helper method. | |
blundell
2014/05/12 07:52:19
I would comment what this function does.
jif
2014/05/12 18:07:41
Done.
| |
111 content::FaviconStatus& GetFaviconStatus(); | |
112 | |
100 Profile* profile_; | 113 Profile* profile_; |
101 | 114 |
102 std::vector<content::FaviconURL> favicon_urls_; | 115 std::vector<content::FaviconURL> favicon_urls_; |
103 | 116 |
104 scoped_ptr<FaviconHandler> favicon_handler_; | 117 scoped_ptr<FaviconHandler> favicon_handler_; |
105 | 118 |
106 // Handles downloading touchicons. It is NULL if | 119 // Handles downloading touchicons. It is NULL if |
107 // browser_defaults::kEnableTouchIcon is false. | 120 // browser_defaults::kEnableTouchIcon is false. |
108 scoped_ptr<FaviconHandler> touch_icon_handler_; | 121 scoped_ptr<FaviconHandler> touch_icon_handler_; |
109 | 122 |
110 DISALLOW_COPY_AND_ASSIGN(FaviconTabHelper); | 123 DISALLOW_COPY_AND_ASSIGN(FaviconTabHelper); |
111 }; | 124 }; |
112 | 125 |
113 #endif // CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_ | 126 #endif // CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_ |
OLD | NEW |