OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_FAVICON_CONTENT_CONTENT_FAVICON_DRIVER_H_ |
| 6 #define COMPONENTS_FAVICON_CONTENT_CONTENT_FAVICON_DRIVER_H_ |
| 7 |
| 8 #include "components/favicon/core/favicon_driver_impl.h" |
| 9 #include "content/public/browser/web_contents_observer.h" |
| 10 #include "content/public/browser/web_contents_user_data.h" |
| 11 #include "url/gurl.h" |
| 12 |
| 13 namespace content { |
| 14 struct FaviconStatus; |
| 15 struct FaviconURL; |
| 16 class WebContents; |
| 17 } |
| 18 |
| 19 namespace favicon { |
| 20 |
| 21 // ContentFaviconDriver is an implementation of FaviconDriver that listens to |
| 22 // WebContents events to start download of favicons and to get informed when the |
| 23 // favicon download has completed. |
| 24 class ContentFaviconDriver |
| 25 : public content::WebContentsObserver, |
| 26 public content::WebContentsUserData<ContentFaviconDriver>, |
| 27 public FaviconDriverImpl { |
| 28 public: |
| 29 static void CreateForWebContents(content::WebContents* web_contents, |
| 30 FaviconService* favicon_service, |
| 31 history::HistoryService* history_service, |
| 32 bookmarks::BookmarkModel* bookmark_model); |
| 33 |
| 34 // Returns the current tab's favicon URLs. If this is empty, |
| 35 // DidUpdateFaviconURL has not yet been called for the current navigation. |
| 36 const std::vector<content::FaviconURL>& favicon_urls() const { |
| 37 return favicon_urls_; |
| 38 } |
| 39 |
| 40 // FaviconDriver implementation. |
| 41 gfx::Image GetFavicon() const override; |
| 42 bool FaviconIsValid() const override; |
| 43 int StartDownload(const GURL& url, int max_bitmap_size) override; |
| 44 bool IsOffTheRecord() override; |
| 45 GURL GetActiveURL() override; |
| 46 base::string16 GetActiveTitle() override; |
| 47 bool GetActiveFaviconValidity() override; |
| 48 void SetActiveFaviconValidity(bool valid) override; |
| 49 GURL GetActiveFaviconURL() override; |
| 50 void SetActiveFaviconURL(const GURL& url) override; |
| 51 gfx::Image GetActiveFaviconImage() override; |
| 52 void SetActiveFaviconImage(const gfx::Image& image) override; |
| 53 |
| 54 protected: |
| 55 ContentFaviconDriver(content::WebContents* web_contents, |
| 56 FaviconService* favicon_service, |
| 57 history::HistoryService* history_service, |
| 58 bookmarks::BookmarkModel* bookmark_model); |
| 59 ~ContentFaviconDriver() override; |
| 60 |
| 61 private: |
| 62 friend class content::WebContentsUserData<ContentFaviconDriver>; |
| 63 |
| 64 // FaviconDriver implementation. |
| 65 void NotifyFaviconUpdated(bool icon_url_changed) override; |
| 66 |
| 67 // content::WebContentsObserver implementation. |
| 68 void DidUpdateFaviconURL( |
| 69 const std::vector<content::FaviconURL>& candidates) override; |
| 70 void DidStartNavigationToPendingEntry( |
| 71 const GURL& url, |
| 72 content::NavigationController::ReloadType reload_type) override; |
| 73 void DidNavigateMainFrame( |
| 74 const content::LoadCommittedDetails& details, |
| 75 const content::FrameNavigateParams& params) override; |
| 76 |
| 77 // Returns the active navigation entry's favicon. |
| 78 content::FaviconStatus& GetFaviconStatus(); |
| 79 |
| 80 GURL bypass_cache_page_url_; |
| 81 std::vector<content::FaviconURL> favicon_urls_; |
| 82 |
| 83 DISALLOW_COPY_AND_ASSIGN(ContentFaviconDriver); |
| 84 }; |
| 85 |
| 86 } // namespace favicon |
| 87 |
| 88 #endif // COMPONENTS_FAVICON_CONTENT_CONTENT_FAVICON_DRIVER_H_ |
OLD | NEW |