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/favicon_handler_delegate.h" | 13 #include "components/favicon/core/favicon_handler_delegate.h" |
13 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
14 #include "content/public/browser/web_contents_user_data.h" | 15 #include "content/public/browser/web_contents_user_data.h" |
15 #include "content/public/common/favicon_url.h" | 16 #include "content/public/common/favicon_url.h" |
16 | 17 |
17 namespace gfx { | 18 namespace gfx { |
18 class Image; | 19 class Image; |
19 } | 20 } |
20 | 21 |
21 class GURL; | 22 class GURL; |
22 class FaviconHandler; | 23 class FaviconHandler; |
23 class Profile; | 24 class Profile; |
24 class SkBitmap; | 25 class SkBitmap; |
25 | 26 |
26 // FaviconTabHelper works with FaviconHandlers to fetch the favicons. | 27 // FaviconTabHelper works with FaviconHandlers to fetch the favicons. |
27 // | 28 // |
28 // 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 |
29 // 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 |
30 // downloaded and saved in the history backend. | 31 // downloaded and saved in the history backend. |
31 // | 32 // |
32 class FaviconTabHelper : public content::WebContentsObserver, | 33 class FaviconTabHelper : public content::WebContentsObserver, |
| 34 public FaviconClient, |
33 public FaviconHandlerDelegate, | 35 public FaviconHandlerDelegate, |
34 public content::WebContentsUserData<FaviconTabHelper> { | 36 public content::WebContentsUserData<FaviconTabHelper> { |
35 public: | 37 public: |
36 virtual ~FaviconTabHelper(); | 38 virtual ~FaviconTabHelper(); |
37 | 39 |
38 // Initiates loading the favicon for the specified url. | 40 // Initiates loading the favicon for the specified url. |
39 void FetchFavicon(const GURL& url); | 41 void FetchFavicon(const GURL& url); |
40 | 42 |
41 // 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 |
42 // not have a favicon. The default implementation uses the current navigation | 44 // not have a favicon. The default implementation uses the current navigation |
(...skipping 30 matching lines...) Expand all Loading... |
73 virtual bool IsOffTheRecord() OVERRIDE; | 75 virtual bool IsOffTheRecord() 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 // FaviconClient implementation: |
| 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 Profile* profile_; | 100 Profile* profile_; |
96 | 101 |
97 std::vector<content::FaviconURL> favicon_urls_; | 102 std::vector<content::FaviconURL> favicon_urls_; |
98 | 103 |
99 scoped_ptr<FaviconHandler> favicon_handler_; | 104 scoped_ptr<FaviconHandler> favicon_handler_; |
100 | 105 |
101 // Handles downloading touchicons. It is NULL if | 106 // Handles downloading touchicons. It is NULL if |
102 // browser_defaults::kEnableTouchIcon is false. | 107 // browser_defaults::kEnableTouchIcon is false. |
103 scoped_ptr<FaviconHandler> touch_icon_handler_; | 108 scoped_ptr<FaviconHandler> touch_icon_handler_; |
104 | 109 |
105 DISALLOW_COPY_AND_ASSIGN(FaviconTabHelper); | 110 DISALLOW_COPY_AND_ASSIGN(FaviconTabHelper); |
106 }; | 111 }; |
107 | 112 |
108 #endif // CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_ | 113 #endif // CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_ |
OLD | NEW |