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

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

Issue 10828127: Use hi-resolution favicon variants if available. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: daringfireball hackfix Created 8 years, 4 months 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_handler_delegate.h" 12 #include "chrome/browser/favicon/favicon_handler_delegate.h"
13 #include "chrome/browser/favicon/favicon_service.h" 13 #include "chrome/browser/favicon/favicon_service.h"
14 #include "chrome/common/favicon_url.h" 14 #include "chrome/common/favicon_url.h"
15 #include "content/public/browser/web_contents_observer.h" 15 #include "content/public/browser/web_contents_observer.h"
16 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.h"
17 17
18 namespace gfx {
19 class Image;
20 }
21
18 class FaviconHandler; 22 class FaviconHandler;
19 class SkBitmap; 23 class SkBitmap;
20 24
21 // FaviconTabHelper works with FaviconHandlers to fetch the favicons. 25 // FaviconTabHelper works with FaviconHandlers to fetch the favicons.
22 // 26 //
23 // FetchFavicon fetches the given page's icons. It requests the icons from the 27 // FetchFavicon fetches the given page's icons. It requests the icons from the
24 // history backend. If the icon is not available or expired, the icon will be 28 // history backend. If the icon is not available or expired, the icon will be
25 // downloaded and saved in the history backend. 29 // downloaded and saved in the history backend.
26 // 30 //
27 // DownloadImage downloads the specified icon and returns it through the given 31 // DownloadImage downloads the specified icon and returns it through the given
28 // callback. 32 // callback.
29 // 33 //
30 class FaviconTabHelper : public content::WebContentsObserver, 34 class FaviconTabHelper : public content::WebContentsObserver,
31 public FaviconHandlerDelegate { 35 public FaviconHandlerDelegate {
32 public: 36 public:
33 explicit FaviconTabHelper(content::WebContents* web_contents); 37 explicit FaviconTabHelper(content::WebContents* web_contents);
34 virtual ~FaviconTabHelper(); 38 virtual ~FaviconTabHelper();
35 39
36 // Initiates loading the favicon for the specified url. 40 // Initiates loading the favicon for the specified url.
37 void FetchFavicon(const GURL& url); 41 void FetchFavicon(const GURL& url);
38 42
39 // 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
40 // not have a favicon. The default implementation uses the current navigation 44 // not have a favicon. The default implementation uses the current navigation
41 // entry. This will return an isNull bitmap if there are no navigation 45 // entry. This will return an isNull bitmap if there are no navigation
42 // entries, which should rarely happen. 46 // entries, which should rarely happen.
43 SkBitmap GetFavicon() const; 47 SkBitmap GetFavicon() const;
44 48
49 gfx::Image GetFaviconImage() const;
50
45 // Returns true if we have the favicon for the page. 51 // Returns true if we have the favicon for the page.
46 bool FaviconIsValid() const; 52 bool FaviconIsValid() const;
47 53
48 // Returns whether the favicon should be displayed. If this returns false, no 54 // Returns whether the favicon should be displayed. If this returns false, no
49 // space is provided for the favicon, and the favicon is never displayed. 55 // space is provided for the favicon, and the favicon is never displayed.
50 virtual bool ShouldDisplayFavicon(); 56 virtual bool ShouldDisplayFavicon();
51 57
52 // Saves the favicon for the current page. 58 // Saves the favicon for the current page.
53 void SaveFavicon(); 59 void SaveFavicon();
54 60
(...skipping 11 matching lines...) Expand all
66 history::IconType icon_type, 72 history::IconType icon_type,
67 const ImageDownloadCallback& callback); 73 const ImageDownloadCallback& callback);
68 74
69 // Message Handler. Must be public, because also called from 75 // Message Handler. Must be public, because also called from
70 // PrerenderContents. 76 // PrerenderContents.
71 void OnUpdateFaviconURL(int32 page_id, 77 void OnUpdateFaviconURL(int32 page_id,
72 const std::vector<FaviconURL>& candidates); 78 const std::vector<FaviconURL>& candidates);
73 79
74 // FaviconHandlerDelegate methods. 80 // FaviconHandlerDelegate methods.
75 virtual content::NavigationEntry* GetActiveEntry() OVERRIDE; 81 virtual content::NavigationEntry* GetActiveEntry() OVERRIDE;
76 virtual int StartDownload(const GURL& url, int image_size) OVERRIDE; 82 virtual int StartDownload(const GURL& url, const std::vector<int>& image_size) OVERRIDE;
77 virtual void NotifyFaviconUpdated() OVERRIDE; 83 virtual void NotifyFaviconUpdated() OVERRIDE;
78 84
79 private: 85 private:
80 // content::WebContentsObserver overrides. 86 // content::WebContentsObserver overrides.
81 virtual void NavigateToPendingEntry( 87 virtual void NavigateToPendingEntry(
82 const GURL& url, 88 const GURL& url,
83 content::NavigationController::ReloadType reload_type) OVERRIDE; 89 content::NavigationController::ReloadType reload_type) OVERRIDE;
84 virtual void DidNavigateMainFrame( 90 virtual void DidNavigateMainFrame(
85 const content::LoadCommittedDetails& details, 91 const content::LoadCommittedDetails& details,
86 const content::FrameNavigateParams& params) OVERRIDE; 92 const content::FrameNavigateParams& params) OVERRIDE;
87 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 93 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
88 94
89 void OnDidDownloadFavicon(int id, 95 void OnDidDownloadFavicon(int id,
90 const GURL& image_url, 96 const GURL& image_url,
91 bool errored, 97 bool errored,
92 const SkBitmap& image); 98 const std::vector<SkBitmap>& image);
93 99
94 Profile* profile_; 100 Profile* profile_;
95 101
96 scoped_ptr<FaviconHandler> favicon_handler_; 102 scoped_ptr<FaviconHandler> favicon_handler_;
97 103
98 // Handles downloading touchicons. It is NULL if 104 // Handles downloading touchicons. It is NULL if
99 // browser_defaults::kEnableTouchIcon is false. 105 // browser_defaults::kEnableTouchIcon is false.
100 scoped_ptr<FaviconHandler> touch_icon_handler_; 106 scoped_ptr<FaviconHandler> touch_icon_handler_;
101 107
102 DISALLOW_COPY_AND_ASSIGN(FaviconTabHelper); 108 DISALLOW_COPY_AND_ASSIGN(FaviconTabHelper);
103 }; 109 };
104 110
105 #endif // CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_ 111 #endif // CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698