| 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 "base/optional.h" | 9 #include "base/optional.h" |
| 10 #include "components/favicon/core/favicon_driver_impl.h" | 10 #include "components/favicon/core/favicon_driver_impl.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // favicon download has completed. | 26 // favicon download has completed. |
| 27 class ContentFaviconDriver | 27 class ContentFaviconDriver |
| 28 : public content::WebContentsObserver, | 28 : public content::WebContentsObserver, |
| 29 public content::WebContentsUserData<ContentFaviconDriver>, | 29 public content::WebContentsUserData<ContentFaviconDriver>, |
| 30 public FaviconDriverImpl { | 30 public FaviconDriverImpl { |
| 31 public: | 31 public: |
| 32 ~ContentFaviconDriver() override; | 32 ~ContentFaviconDriver() override; |
| 33 | 33 |
| 34 static void CreateForWebContents(content::WebContents* web_contents, | 34 static void CreateForWebContents(content::WebContents* web_contents, |
| 35 FaviconService* favicon_service, | 35 FaviconService* favicon_service, |
| 36 history::HistoryService* history_service, | 36 history::HistoryService* history_service); |
| 37 bookmarks::BookmarkModel* bookmark_model); | |
| 38 | 37 |
| 39 // Returns the current tab's favicon URLs. If this is empty, | 38 // Returns the current tab's favicon URLs. If this is empty, |
| 40 // DidUpdateFaviconURL has not yet been called for the current navigation. | 39 // DidUpdateFaviconURL has not yet been called for the current navigation. |
| 41 std::vector<content::FaviconURL> favicon_urls() const { | 40 std::vector<content::FaviconURL> favicon_urls() const { |
| 42 return favicon_urls_.value_or(std::vector<content::FaviconURL>()); | 41 return favicon_urls_.value_or(std::vector<content::FaviconURL>()); |
| 43 } | 42 } |
| 44 | 43 |
| 45 // Saves the favicon for the last committed navigation entry to the thumbnail | 44 // Saves the favicon for the last committed navigation entry to the thumbnail |
| 46 // database. | 45 // database. |
| 47 void SaveFavicon(); | 46 void SaveFaviconEvenIfInIncognito(); |
| 48 | 47 |
| 49 // FaviconDriver implementation. | 48 // FaviconDriver implementation. |
| 50 gfx::Image GetFavicon() const override; | 49 gfx::Image GetFavicon() const override; |
| 51 bool FaviconIsValid() const override; | 50 bool FaviconIsValid() const override; |
| 52 GURL GetActiveURL() override; | 51 GURL GetActiveURL() override; |
| 53 | 52 |
| 54 protected: | 53 protected: |
| 55 ContentFaviconDriver(content::WebContents* web_contents, | 54 ContentFaviconDriver(content::WebContents* web_contents, |
| 56 FaviconService* favicon_service, | 55 FaviconService* favicon_service, |
| 57 history::HistoryService* history_service, | 56 history::HistoryService* history_service); |
| 58 bookmarks::BookmarkModel* bookmark_model); | |
| 59 | 57 |
| 60 private: | 58 private: |
| 61 friend class content::WebContentsUserData<ContentFaviconDriver>; | 59 friend class content::WebContentsUserData<ContentFaviconDriver>; |
| 62 | 60 |
| 63 // FaviconHandler::Delegate implementation. | 61 // FaviconHandler::Delegate implementation. |
| 64 int DownloadImage(const GURL& url, | 62 int DownloadImage(const GURL& url, |
| 65 int max_image_size, | 63 int max_image_size, |
| 66 ImageDownloadCallback callback) override; | 64 ImageDownloadCallback callback) override; |
| 67 void DownloadManifest(const GURL& url, | 65 void DownloadManifest(const GURL& url, |
| 68 ManifestDownloadCallback callback) override; | 66 ManifestDownloadCallback callback) override; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 88 base::Optional<std::vector<content::FaviconURL>> favicon_urls_; | 86 base::Optional<std::vector<content::FaviconURL>> favicon_urls_; |
| 89 // Web Manifest URL or empty URL if none. | 87 // Web Manifest URL or empty URL if none. |
| 90 GURL manifest_url_; | 88 GURL manifest_url_; |
| 91 | 89 |
| 92 DISALLOW_COPY_AND_ASSIGN(ContentFaviconDriver); | 90 DISALLOW_COPY_AND_ASSIGN(ContentFaviconDriver); |
| 93 }; | 91 }; |
| 94 | 92 |
| 95 } // namespace favicon | 93 } // namespace favicon |
| 96 | 94 |
| 97 #endif // COMPONENTS_FAVICON_CONTENT_CONTENT_FAVICON_DRIVER_H_ | 95 #endif // COMPONENTS_FAVICON_CONTENT_CONTENT_FAVICON_DRIVER_H_ |
| OLD | NEW |