| 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" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 class Profile; | 28 class Profile; |
| 29 class SkBitmap; | 29 class SkBitmap; |
| 30 | 30 |
| 31 // FaviconTabHelper works with FaviconHandlers to fetch the favicons. | 31 // FaviconTabHelper works with FaviconHandlers to fetch the favicons. |
| 32 // | 32 // |
| 33 // FetchFavicon fetches the given page's icons. It requests the icons from the | 33 // FetchFavicon fetches the given page's icons. It requests the icons from the |
| 34 // history backend. If the icon is not available or expired, the icon will be | 34 // history backend. If the icon is not available or expired, the icon will be |
| 35 // downloaded and saved in the history backend. | 35 // downloaded and saved in the history backend. |
| 36 // | 36 // |
| 37 class FaviconTabHelper : public content::WebContentsObserver, | 37 class FaviconTabHelper : public content::WebContentsObserver, |
| 38 public FaviconClient, | |
| 39 public FaviconDriver, | 38 public FaviconDriver, |
| 40 public content::WebContentsUserData<FaviconTabHelper> { | 39 public content::WebContentsUserData<FaviconTabHelper> { |
| 41 public: | 40 public: |
| 42 virtual ~FaviconTabHelper(); | 41 virtual ~FaviconTabHelper(); |
| 43 | 42 |
| 44 // Initiates loading the favicon for the specified url. | 43 // Initiates loading the favicon for the specified url. |
| 45 void FetchFavicon(const GURL& url); | 44 void FetchFavicon(const GURL& url); |
| 46 | 45 |
| 47 // Returns the favicon for this tab, or IDR_DEFAULT_FAVICON if the tab does | 46 // Returns the favicon for this tab, or IDR_DEFAULT_FAVICON if the tab does |
| 48 // not have a favicon. The default implementation uses the current navigation | 47 // not have a favicon. The default implementation uses the current navigation |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 virtual void SetActiveFaviconValidity(bool validity) OVERRIDE; | 83 virtual void SetActiveFaviconValidity(bool validity) OVERRIDE; |
| 85 | 84 |
| 86 // Favicon download callback. | 85 // Favicon download callback. |
| 87 void DidDownloadFavicon( | 86 void DidDownloadFavicon( |
| 88 int id, | 87 int id, |
| 89 int http_status_code, | 88 int http_status_code, |
| 90 const GURL& image_url, | 89 const GURL& image_url, |
| 91 const std::vector<SkBitmap>& bitmaps, | 90 const std::vector<SkBitmap>& bitmaps, |
| 92 const std::vector<gfx::Size>& original_bitmap_sizes); | 91 const std::vector<gfx::Size>& original_bitmap_sizes); |
| 93 | 92 |
| 94 // FaviconClient implementation: | |
| 95 virtual FaviconService* GetFaviconService() OVERRIDE; | |
| 96 virtual bool IsBookmarked(const GURL& url) OVERRIDE; | |
| 97 | |
| 98 private: | 93 private: |
| 99 explicit FaviconTabHelper(content::WebContents* web_contents); | 94 explicit FaviconTabHelper(content::WebContents* web_contents); |
| 100 friend class content::WebContentsUserData<FaviconTabHelper>; | 95 friend class content::WebContentsUserData<FaviconTabHelper>; |
| 101 | 96 |
| 102 // content::WebContentsObserver overrides. | 97 // content::WebContentsObserver overrides. |
| 103 virtual void DidStartNavigationToPendingEntry( | 98 virtual void DidStartNavigationToPendingEntry( |
| 104 const GURL& url, | 99 const GURL& url, |
| 105 content::NavigationController::ReloadType reload_type) OVERRIDE; | 100 content::NavigationController::ReloadType reload_type) OVERRIDE; |
| 106 virtual void DidNavigateMainFrame( | 101 virtual void DidNavigateMainFrame( |
| 107 const content::LoadCommittedDetails& details, | 102 const content::LoadCommittedDetails& details, |
| 108 const content::FrameNavigateParams& params) OVERRIDE; | 103 const content::FrameNavigateParams& params) OVERRIDE; |
| 109 | 104 |
| 110 // Helper method that returns the active navigation entry's favicon. | 105 // Helper method that returns the active navigation entry's favicon. |
| 111 content::FaviconStatus& GetFaviconStatus(); | 106 content::FaviconStatus& GetFaviconStatus(); |
| 112 | 107 |
| 113 Profile* profile_; | 108 Profile* profile_; |
| 114 | 109 |
| 110 scoped_ptr<FaviconClient> client_; |
| 111 |
| 115 std::vector<content::FaviconURL> favicon_urls_; | 112 std::vector<content::FaviconURL> favicon_urls_; |
| 116 | 113 |
| 117 scoped_ptr<FaviconHandler> favicon_handler_; | 114 scoped_ptr<FaviconHandler> favicon_handler_; |
| 118 | 115 |
| 119 // Handles downloading touchicons. It is NULL if | 116 // Handles downloading touchicons. It is NULL if |
| 120 // browser_defaults::kEnableTouchIcon is false. | 117 // browser_defaults::kEnableTouchIcon is false. |
| 121 scoped_ptr<FaviconHandler> touch_icon_handler_; | 118 scoped_ptr<FaviconHandler> touch_icon_handler_; |
| 122 | 119 |
| 123 DISALLOW_COPY_AND_ASSIGN(FaviconTabHelper); | 120 DISALLOW_COPY_AND_ASSIGN(FaviconTabHelper); |
| 124 }; | 121 }; |
| 125 | 122 |
| 126 #endif // CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_ | 123 #endif // CHROME_BROWSER_FAVICON_FAVICON_TAB_HELPER_H_ |
| OLD | NEW |