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/content/browser/content_favicon_driver.h" | 12 #include "components/favicon/content/browser/content_favicon_driver.h" |
13 #include "components/favicon/core/browser/favicon_client.h" | |
13 #include "components/favicon/core/favicon_handler_delegate.h" | 14 #include "components/favicon/core/favicon_handler_delegate.h" |
14 #include "content/public/browser/web_contents_observer.h" | 15 #include "content/public/browser/web_contents_observer.h" |
15 #include "content/public/browser/web_contents_user_data.h" | 16 #include "content/public/browser/web_contents_user_data.h" |
16 #include "content/public/common/favicon_url.h" | 17 #include "content/public/common/favicon_url.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 class FaviconTabHelper : public content::WebContentsObserver, | 34 class FaviconTabHelper : public content::WebContentsObserver, |
35 public FaviconClient, | |
34 public FaviconHandlerDelegate, | 36 public FaviconHandlerDelegate, |
35 public content::WebContentsUserData<FaviconTabHelper> { | 37 public content::WebContentsUserData<FaviconTabHelper> { |
36 public: | 38 public: |
37 virtual ~FaviconTabHelper(); | 39 virtual ~FaviconTabHelper(); |
38 | 40 |
39 // Initiates loading the favicon for the specified url. | 41 // Initiates loading the favicon for the specified url. |
40 void FetchFavicon(const GURL& url); | 42 void FetchFavicon(const GURL& url); |
41 | 43 |
42 // Returns the favicon for this tab, or IDR_DEFAULT_FAVICON if the tab does | 44 // Returns the favicon for this tab, or IDR_DEFAULT_FAVICON if the tab does |
43 // not have a favicon. The default implementation uses the current navigation | 45 // not have a favicon. The default implementation uses the current navigation |
(...skipping 29 matching lines...) Expand all Loading... | |
73 virtual void NotifyFaviconUpdated(bool icon_url_changed) OVERRIDE; | 75 virtual void NotifyFaviconUpdated(bool icon_url_changed) OVERRIDE; |
74 | 76 |
75 // Favicon download callback. | 77 // Favicon download callback. |
76 void DidDownloadFavicon( | 78 void DidDownloadFavicon( |
77 int id, | 79 int id, |
78 int http_status_code, | 80 int http_status_code, |
79 const GURL& image_url, | 81 const GURL& image_url, |
80 const std::vector<SkBitmap>& bitmaps, | 82 const std::vector<SkBitmap>& bitmaps, |
81 const std::vector<gfx::Size>& original_bitmap_sizes); | 83 const std::vector<gfx::Size>& original_bitmap_sizes); |
82 | 84 |
85 // Returns a FaviconService. | |
blundell
2014/04/09 09:17:21
Don't need to comment overriden methods. Just say
jif
2014/04/09 11:22:48
Done.
| |
86 virtual FaviconService* GetFaviconService() OVERRIDE; | |
87 | |
83 private: | 88 private: |
84 explicit FaviconTabHelper(content::WebContents* web_contents); | 89 explicit FaviconTabHelper(content::WebContents* web_contents); |
85 friend class content::WebContentsUserData<FaviconTabHelper>; | 90 friend class content::WebContentsUserData<FaviconTabHelper>; |
86 | 91 |
87 // content::WebContentsObserver overrides. | 92 // content::WebContentsObserver overrides. |
88 virtual void DidStartNavigationToPendingEntry( | 93 virtual void DidStartNavigationToPendingEntry( |
89 const GURL& url, | 94 const GURL& url, |
90 content::NavigationController::ReloadType reload_type) OVERRIDE; | 95 content::NavigationController::ReloadType reload_type) OVERRIDE; |
91 virtual void DidNavigateMainFrame( | 96 virtual void DidNavigateMainFrame( |
92 const content::LoadCommittedDetails& details, | 97 const content::LoadCommittedDetails& details, |
93 const content::FrameNavigateParams& params) OVERRIDE; | 98 const content::FrameNavigateParams& params) OVERRIDE; |
94 | 99 |
95 ContentFaviconDriver driver_; | 100 ContentFaviconDriver driver_; |
96 | 101 |
97 Profile* profile_; | 102 Profile* profile_; |
98 | 103 |
99 std::vector<content::FaviconURL> favicon_urls_; | 104 std::vector<content::FaviconURL> favicon_urls_; |
100 | 105 |
101 scoped_ptr<FaviconHandler> favicon_handler_; | 106 scoped_ptr<FaviconHandler> favicon_handler_; |
102 | 107 |
103 // Handles downloading touchicons. It is NULL if | 108 // Handles downloading touchicons. It is NULL if |
104 // browser_defaults::kEnableTouchIcon is false. | 109 // browser_defaults::kEnableTouchIcon is false. |
105 scoped_ptr<FaviconHandler> touch_icon_handler_; | 110 scoped_ptr<FaviconHandler> touch_icon_handler_; |
106 | 111 |
107 DISALLOW_COPY_AND_ASSIGN(FaviconTabHelper); | 112 DISALLOW_COPY_AND_ASSIGN(FaviconTabHelper); |
108 }; | 113 }; |
109 | 114 |
110 #endif // CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_ | 115 #endif // CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_ |
OLD | NEW |