Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: chrome/browser/favicon/favicon_tab_helper.h

Issue 11411180: move favicon download code from chrome/ into content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
13 #include "chrome/browser/favicon/favicon_handler_delegate.h" 12 #include "chrome/browser/favicon/favicon_handler_delegate.h"
14 #include "chrome/browser/history/history_types.h" 13 #include "chrome/browser/history/history_types.h"
15 #include "chrome/common/favicon_url.h" 14 #include "content/public/browser/favicon_download_delegate.h"
16 #include "content/public/browser/web_contents_observer.h" 15 #include "content/public/browser/web_contents_observer.h"
17 #include "content/public/browser/web_contents_user_data.h" 16 #include "content/public/browser/web_contents_user_data.h"
17 #include "content/public/common/favicon_url.h"
18 18
19 namespace gfx { 19 namespace gfx {
20 class Image; 20 class Image;
21 } 21 }
22 22
23 class GURL; 23 class GURL;
24 class FaviconDownloadHelper;
25 class FaviconHandler; 24 class FaviconHandler;
26 class Profile; 25 class Profile;
27 class SkBitmap; 26 class SkBitmap;
28 27
29 // FaviconTabHelper works with FaviconHandlers to fetch the favicons. 28 // FaviconTabHelper works with FaviconHandlers to fetch the favicons.
30 // 29 //
31 // 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
32 // 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
33 // downloaded and saved in the history backend. 32 // downloaded and saved in the history backend.
34 // 33 //
35 class FaviconTabHelper : public content::WebContentsObserver, 34 class FaviconTabHelper : public content::WebContentsObserver,
36 public FaviconHandlerDelegate, 35 public FaviconHandlerDelegate,
37 public FaviconDownloadHelperDelegate, 36 public content::FaviconDownloadDelegate,
38 public content::WebContentsUserData<FaviconTabHelper> { 37 public content::WebContentsUserData<FaviconTabHelper> {
39 public: 38 public:
40 virtual ~FaviconTabHelper(); 39 virtual ~FaviconTabHelper();
41 40
42 // Initiates loading the favicon for the specified url. 41 // Initiates loading the favicon for the specified url.
43 void FetchFavicon(const GURL& url); 42 void FetchFavicon(const GURL& url);
44 43
45 // 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
46 // not have a favicon. The default implementation uses the current navigation 45 // not have a favicon. The default implementation uses the current navigation
47 // entry. This will return an empty bitmap if there are no navigation 46 // entry. This will return an empty bitmap if there are no navigation
48 // entries, which should rarely happen. 47 // entries, which should rarely happen.
49 gfx::Image GetFavicon() const; 48 gfx::Image GetFavicon() const;
50 49
51 // Returns true if we have the favicon for the page. 50 // Returns true if we have the favicon for the page.
52 bool FaviconIsValid() const; 51 bool FaviconIsValid() const;
53 52
54 // Returns whether the favicon should be displayed. If this returns false, no 53 // Returns whether the favicon should be displayed. If this returns false, no
55 // space is provided for the favicon, and the favicon is never displayed. 54 // space is provided for the favicon, and the favicon is never displayed.
56 virtual bool ShouldDisplayFavicon(); 55 virtual bool ShouldDisplayFavicon();
57 56
58 // Message Handler. Must be public, because also called from 57 // content::FaviconDownloadDelegate override. Must be public, because also
59 // PrerenderContents. 58 // called from PrerenderContents.
60 virtual void OnUpdateFaviconURL( 59 virtual void UpdateFaviconURL(
61 int32 page_id, 60 int32 page_id,
62 const std::vector<FaviconURL>& candidates) OVERRIDE; 61 const std::vector<content::FaviconURL>& candidates) OVERRIDE;
63 62
64 // Saves the favicon for the current page. 63 // Saves the favicon for the current page.
65 void SaveFavicon(); 64 void SaveFavicon();
66 65
67 // FaviconHandlerDelegate methods. 66 // FaviconHandlerDelegate methods.
68 virtual content::NavigationEntry* GetActiveEntry() OVERRIDE; 67 virtual content::NavigationEntry* GetActiveEntry() OVERRIDE;
69 virtual int StartDownload(const GURL& url, int image_size) OVERRIDE; 68 virtual int StartDownload(const GURL& url, int image_size) OVERRIDE;
70 virtual void NotifyFaviconUpdated() OVERRIDE; 69 virtual void NotifyFaviconUpdated() OVERRIDE;
71 70
72 private: 71 private:
73 explicit FaviconTabHelper(content::WebContents* web_contents); 72 explicit FaviconTabHelper(content::WebContents* web_contents);
74 friend class content::WebContentsUserData<FaviconTabHelper>; 73 friend class content::WebContentsUserData<FaviconTabHelper>;
75 74
76 // content::WebContentsObserver overrides. 75 // content::WebContentsObserver overrides.
77 virtual void NavigateToPendingEntry( 76 virtual void NavigateToPendingEntry(
78 const GURL& url, 77 const GURL& url,
79 content::NavigationController::ReloadType reload_type) OVERRIDE; 78 content::NavigationController::ReloadType reload_type) OVERRIDE;
80 virtual void DidNavigateMainFrame( 79 virtual void DidNavigateMainFrame(
81 const content::LoadCommittedDetails& details, 80 const content::LoadCommittedDetails& details,
82 const content::FrameNavigateParams& params) OVERRIDE; 81 const content::FrameNavigateParams& params) OVERRIDE;
83 82
84 // FaviconDownloadHelperDelegate overrides. 83 // content::FaviconDownloadDelegate override.
85 virtual void OnDidDownloadFavicon( 84 virtual void DidDownloadFavicon(
86 int id, 85 int id,
87 const GURL& image_url, 86 const GURL& image_url,
88 bool errored, 87 bool errored,
89 int requested_size, 88 int requested_size,
90 const std::vector<SkBitmap>& bitmaps) OVERRIDE; 89 const std::vector<SkBitmap>& bitmaps) OVERRIDE;
91 90
92 Profile* profile_; 91 Profile* profile_;
93 92
94 scoped_ptr<FaviconDownloadHelper> favicon_download_helper_;
95
96 scoped_ptr<FaviconHandler> favicon_handler_; 93 scoped_ptr<FaviconHandler> favicon_handler_;
97 94
98 // Handles downloading touchicons. It is NULL if 95 // Handles downloading touchicons. It is NULL if
99 // browser_defaults::kEnableTouchIcon is false. 96 // browser_defaults::kEnableTouchIcon is false.
100 scoped_ptr<FaviconHandler> touch_icon_handler_; 97 scoped_ptr<FaviconHandler> touch_icon_handler_;
101 98
102 DISALLOW_COPY_AND_ASSIGN(FaviconTabHelper); 99 DISALLOW_COPY_AND_ASSIGN(FaviconTabHelper);
103 }; 100 };
104 101
105 #endif // CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_ 102 #endif // CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698