| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_FAVICON_CONTENT_CONTENT_FAVICON_DRIVER_H_ | 5 #ifndef COMPONENTS_FAVICON_CONTENT_CONTENT_FAVICON_DRIVER_H_ |
| 6 #define COMPONENTS_FAVICON_CONTENT_CONTENT_FAVICON_DRIVER_H_ | 6 #define COMPONENTS_FAVICON_CONTENT_CONTENT_FAVICON_DRIVER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "components/favicon/core/favicon_driver_impl.h" | 9 #include "components/favicon/core/favicon_driver_impl.h" |
| 10 #include "content/public/browser/reload_type.h" | 10 #include "content/public/browser/reload_type.h" |
| 11 #include "content/public/browser/web_contents_observer.h" | 11 #include "content/public/browser/web_contents_observer.h" |
| 12 #include "content/public/browser/web_contents_user_data.h" | 12 #include "content/public/browser/web_contents_user_data.h" |
| 13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 struct FaviconURL; | 16 struct FaviconURL; |
| 17 class WebContents; | 17 class WebContents; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace favicon { | 20 namespace favicon { |
| 21 | 21 |
| 22 // ContentFaviconDriver is an implementation of FaviconDriver that listens to | 22 // ContentFaviconDriver is an implementation of FaviconDriver that listens to |
| 23 // WebContents events to start download of favicons and to get informed when the | 23 // WebContents events to start download of favicons and to get informed when the |
| 24 // favicon download has completed. | 24 // favicon download has completed. |
| 25 class ContentFaviconDriver | 25 class ContentFaviconDriver |
| 26 : public content::WebContentsObserver, | 26 : public content::WebContentsObserver, |
| 27 public content::WebContentsUserData<ContentFaviconDriver>, | 27 public content::WebContentsUserData<ContentFaviconDriver>, |
| 28 public FaviconDriverImpl { | 28 public FaviconDriverImpl { |
| 29 public: | 29 public: |
| 30 ~ContentFaviconDriver() override; |
| 31 |
| 30 static void CreateForWebContents(content::WebContents* web_contents, | 32 static void CreateForWebContents(content::WebContents* web_contents, |
| 31 FaviconService* favicon_service, | 33 FaviconService* favicon_service, |
| 32 history::HistoryService* history_service, | 34 history::HistoryService* history_service, |
| 33 bookmarks::BookmarkModel* bookmark_model); | 35 bookmarks::BookmarkModel* bookmark_model); |
| 34 | 36 |
| 35 // Returns the current tab's favicon URLs. If this is empty, | 37 // Returns the current tab's favicon URLs. If this is empty, |
| 36 // DidUpdateFaviconURL has not yet been called for the current navigation. | 38 // DidUpdateFaviconURL has not yet been called for the current navigation. |
| 37 const std::vector<content::FaviconURL>& favicon_urls() const { | 39 const std::vector<content::FaviconURL>& favicon_urls() const { |
| 38 return favicon_urls_; | 40 return favicon_urls_; |
| 39 } | 41 } |
| 40 | 42 |
| 41 // Saves the favicon for the last committed navigation entry to the thumbnail | 43 // Saves the favicon for the last committed navigation entry to the thumbnail |
| 42 // database. | 44 // database. |
| 43 void SaveFavicon(); | 45 void SaveFavicon(); |
| 44 | 46 |
| 45 // FaviconDriver implementation. | 47 // FaviconDriver implementation. |
| 46 gfx::Image GetFavicon() const override; | 48 gfx::Image GetFavicon() const override; |
| 47 bool FaviconIsValid() const override; | 49 bool FaviconIsValid() const override; |
| 48 GURL GetActiveURL() override; | 50 GURL GetActiveURL() override; |
| 49 | 51 |
| 50 protected: | 52 protected: |
| 51 ContentFaviconDriver(content::WebContents* web_contents, | 53 ContentFaviconDriver(content::WebContents* web_contents, |
| 52 FaviconService* favicon_service, | 54 FaviconService* favicon_service, |
| 53 history::HistoryService* history_service, | 55 history::HistoryService* history_service, |
| 54 bookmarks::BookmarkModel* bookmark_model); | 56 bookmarks::BookmarkModel* bookmark_model); |
| 55 ~ContentFaviconDriver() override; | |
| 56 | 57 |
| 57 private: | 58 private: |
| 58 friend class content::WebContentsUserData<ContentFaviconDriver>; | 59 friend class content::WebContentsUserData<ContentFaviconDriver>; |
| 59 | 60 |
| 60 // FaviconHandler::Delegate implementation. | 61 // FaviconHandler::Delegate implementation. |
| 61 int DownloadImage(const GURL& url, | 62 int DownloadImage(const GURL& url, |
| 62 int max_image_size, | 63 int max_image_size, |
| 63 ImageDownloadCallback callback) override; | 64 ImageDownloadCallback callback) override; |
| 64 bool IsOffTheRecord() override; | 65 bool IsOffTheRecord() override; |
| 65 void OnFaviconUpdated(const GURL& page_url, | 66 void OnFaviconUpdated(const GURL& page_url, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 78 | 79 |
| 79 GURL bypass_cache_page_url_; | 80 GURL bypass_cache_page_url_; |
| 80 std::vector<content::FaviconURL> favicon_urls_; | 81 std::vector<content::FaviconURL> favicon_urls_; |
| 81 | 82 |
| 82 DISALLOW_COPY_AND_ASSIGN(ContentFaviconDriver); | 83 DISALLOW_COPY_AND_ASSIGN(ContentFaviconDriver); |
| 83 }; | 84 }; |
| 84 | 85 |
| 85 } // namespace favicon | 86 } // namespace favicon |
| 86 | 87 |
| 87 #endif // COMPONENTS_FAVICON_CONTENT_CONTENT_FAVICON_DRIVER_H_ | 88 #endif // COMPONENTS_FAVICON_CONTENT_CONTENT_FAVICON_DRIVER_H_ |
| OLD | NEW |