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

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: fix order 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"
16 #include "content/public/browser/web_contents_observer.h" 14 #include "content/public/browser/web_contents_observer.h"
17 #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"
18 17
19 namespace gfx { 18 namespace gfx {
20 class Image; 19 class Image;
21 } 20 }
22 21
23 class GURL; 22 class GURL;
24 class FaviconDownloadHelper;
25 class FaviconHandler; 23 class FaviconHandler;
26 class Profile; 24 class Profile;
27 class SkBitmap; 25 class SkBitmap;
28 26
29 // FaviconTabHelper works with FaviconHandlers to fetch the favicons. 27 // FaviconTabHelper works with FaviconHandlers to fetch the favicons.
30 // 28 //
31 // 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
32 // 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
33 // downloaded and saved in the history backend. 31 // downloaded and saved in the history backend.
34 // 32 //
35 class FaviconTabHelper : public content::WebContentsObserver, 33 class FaviconTabHelper : public content::WebContentsObserver,
36 public FaviconHandlerDelegate, 34 public FaviconHandlerDelegate,
37 public FaviconDownloadHelperDelegate,
38 public content::WebContentsUserData<FaviconTabHelper> { 35 public content::WebContentsUserData<FaviconTabHelper> {
39 public: 36 public:
40 virtual ~FaviconTabHelper(); 37 virtual ~FaviconTabHelper();
41 38
42 // Initiates loading the favicon for the specified url. 39 // Initiates loading the favicon for the specified url.
43 void FetchFavicon(const GURL& url); 40 void FetchFavicon(const GURL& url);
44 41
45 // Returns the favicon for this tab, or IDR_DEFAULT_FAVICON if the tab does 42 // 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 43 // not have a favicon. The default implementation uses the current navigation
47 // entry. This will return an empty bitmap if there are no navigation 44 // entry. This will return an empty bitmap if there are no navigation
48 // entries, which should rarely happen. 45 // entries, which should rarely happen.
49 gfx::Image GetFavicon() const; 46 gfx::Image GetFavicon() const;
50 47
51 // Returns true if we have the favicon for the page. 48 // Returns true if we have the favicon for the page.
52 bool FaviconIsValid() const; 49 bool FaviconIsValid() const;
53 50
54 // Returns whether the favicon should be displayed. If this returns false, no 51 // 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. 52 // space is provided for the favicon, and the favicon is never displayed.
56 virtual bool ShouldDisplayFavicon(); 53 virtual bool ShouldDisplayFavicon();
57 54
58 // Message Handler. Must be public, because also called from 55 // content::WebContentsObserver override. Must be public, because also
59 // PrerenderContents. 56 // called from PrerenderContents.
60 virtual void OnUpdateFaviconURL( 57 virtual void DidUpdateFaviconURL(
61 int32 page_id, 58 int32 page_id,
62 const std::vector<FaviconURL>& candidates) OVERRIDE; 59 const std::vector<content::FaviconURL>& candidates) OVERRIDE;
63 60
64 // Saves the favicon for the current page. 61 // Saves the favicon for the current page.
65 void SaveFavicon(); 62 void SaveFavicon();
66 63
67 // FaviconHandlerDelegate methods. 64 // FaviconHandlerDelegate methods.
68 virtual content::NavigationEntry* GetActiveEntry() OVERRIDE; 65 virtual content::NavigationEntry* GetActiveEntry() OVERRIDE;
69 virtual int StartDownload(const GURL& url, int image_size) OVERRIDE; 66 virtual int StartDownload(const GURL& url, int image_size) OVERRIDE;
70 virtual void NotifyFaviconUpdated() OVERRIDE; 67 virtual void NotifyFaviconUpdated() OVERRIDE;
71 68
72 private: 69 private:
73 explicit FaviconTabHelper(content::WebContents* web_contents); 70 explicit FaviconTabHelper(content::WebContents* web_contents);
74 friend class content::WebContentsUserData<FaviconTabHelper>; 71 friend class content::WebContentsUserData<FaviconTabHelper>;
75 72
76 // content::WebContentsObserver overrides. 73 // content::WebContentsObserver overrides.
77 virtual void NavigateToPendingEntry( 74 virtual void NavigateToPendingEntry(
78 const GURL& url, 75 const GURL& url,
79 content::NavigationController::ReloadType reload_type) OVERRIDE; 76 content::NavigationController::ReloadType reload_type) OVERRIDE;
80 virtual void DidNavigateMainFrame( 77 virtual void DidNavigateMainFrame(
81 const content::LoadCommittedDetails& details, 78 const content::LoadCommittedDetails& details,
82 const content::FrameNavigateParams& params) OVERRIDE; 79 const content::FrameNavigateParams& params) OVERRIDE;
83 80
84 // FaviconDownloadHelperDelegate overrides. 81 // Favicon download callback.
85 virtual void OnDidDownloadFavicon( 82 void DidDownloadFavicon(
86 int id, 83 int id,
87 const GURL& image_url, 84 const GURL& image_url,
88 bool errored, 85 bool errored,
89 int requested_size, 86 int requested_size,
90 const std::vector<SkBitmap>& bitmaps) OVERRIDE; 87 const std::vector<SkBitmap>& bitmaps);
91 88
92 Profile* profile_; 89 Profile* profile_;
93 90
94 scoped_ptr<FaviconDownloadHelper> favicon_download_helper_;
95
96 scoped_ptr<FaviconHandler> favicon_handler_; 91 scoped_ptr<FaviconHandler> favicon_handler_;
97 92
98 // Handles downloading touchicons. It is NULL if 93 // Handles downloading touchicons. It is NULL if
99 // browser_defaults::kEnableTouchIcon is false. 94 // browser_defaults::kEnableTouchIcon is false.
100 scoped_ptr<FaviconHandler> touch_icon_handler_; 95 scoped_ptr<FaviconHandler> touch_icon_handler_;
101 96
102 DISALLOW_COPY_AND_ASSIGN(FaviconTabHelper); 97 DISALLOW_COPY_AND_ASSIGN(FaviconTabHelper);
103 }; 98 };
104 99
105 #endif // CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_ 100 #endif // CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_handler_unittest.cc ('k') | chrome/browser/favicon/favicon_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698