| 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 "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 empty bitmap if there are no navigation |
| 42 // entries, which should rarely happen. | 46 // entries, which should rarely happen. |
| 43 SkBitmap GetFavicon() const; | 47 gfx::Image GetFavicon() const; |
| 44 | 48 |
| 45 // Returns true if we have the favicon for the page. | 49 // Returns true if we have the favicon for the page. |
| 46 bool FaviconIsValid() const; | 50 bool FaviconIsValid() const; |
| 47 | 51 |
| 48 // Returns whether the favicon should be displayed. If this returns false, no | 52 // 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. | 53 // space is provided for the favicon, and the favicon is never displayed. |
| 50 virtual bool ShouldDisplayFavicon(); | 54 virtual bool ShouldDisplayFavicon(); |
| 51 | 55 |
| 52 // Saves the favicon for the current page. | 56 // Saves the favicon for the current page. |
| 53 void SaveFavicon(); | 57 void SaveFavicon(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 scoped_ptr<FaviconHandler> favicon_handler_; | 100 scoped_ptr<FaviconHandler> favicon_handler_; |
| 97 | 101 |
| 98 // Handles downloading touchicons. It is NULL if | 102 // Handles downloading touchicons. It is NULL if |
| 99 // browser_defaults::kEnableTouchIcon is false. | 103 // browser_defaults::kEnableTouchIcon is false. |
| 100 scoped_ptr<FaviconHandler> touch_icon_handler_; | 104 scoped_ptr<FaviconHandler> touch_icon_handler_; |
| 101 | 105 |
| 102 DISALLOW_COPY_AND_ASSIGN(FaviconTabHelper); | 106 DISALLOW_COPY_AND_ASSIGN(FaviconTabHelper); |
| 103 }; | 107 }; |
| 104 | 108 |
| 105 #endif // CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_ | 109 #endif // CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_ |
| OLD | NEW |