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_IOS_WEB_FAVICON_DRIVER_H_ | 5 #ifndef COMPONENTS_FAVICON_IOS_WEB_FAVICON_DRIVER_H_ |
6 #define COMPONENTS_FAVICON_IOS_WEB_FAVICON_DRIVER_H_ | 6 #define COMPONENTS_FAVICON_IOS_WEB_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 #import "components/image_fetcher/ios/ios_image_data_fetcher_wrapper.h" | 10 #import "components/image_fetcher/ios/ios_image_data_fetcher_wrapper.h" |
11 #include "ios/web/public/web_state/web_state_observer.h" | 11 #include "ios/web/public/web_state/web_state_observer.h" |
12 #include "ios/web/public/web_state/web_state_user_data.h" | 12 #include "ios/web/public/web_state/web_state_user_data.h" |
13 | 13 |
14 namespace web { | 14 namespace web { |
15 class WebState; | 15 class WebState; |
16 } | 16 } |
17 | 17 |
18 namespace favicon { | 18 namespace favicon { |
19 | 19 |
20 // WebFaviconDriver is an implementation of FaviconDriver that listen to | 20 // WebFaviconDriver is an implementation of FaviconDriver that listen to |
21 // WebState events to start download of favicons and to get informed when the | 21 // WebState events to start download of favicons and to get informed when the |
22 // favicon download has completed. | 22 // favicon download has completed. |
23 class WebFaviconDriver : public web::WebStateObserver, | 23 class WebFaviconDriver : public web::WebStateObserver, |
24 public web::WebStateUserData<WebFaviconDriver>, | 24 public web::WebStateUserData<WebFaviconDriver>, |
25 public FaviconDriverImpl { | 25 public FaviconDriverImpl { |
26 public: | 26 public: |
| 27 ~WebFaviconDriver() override; |
| 28 |
27 static void CreateForWebState(web::WebState* web_state, | 29 static void CreateForWebState(web::WebState* web_state, |
28 FaviconService* favicon_service, | 30 FaviconService* favicon_service, |
29 history::HistoryService* history_service, | 31 history::HistoryService* history_service, |
30 bookmarks::BookmarkModel* bookmark_model); | 32 bookmarks::BookmarkModel* bookmark_model); |
31 | 33 |
32 // FaviconDriver implementation. | 34 // FaviconDriver implementation. |
33 void FetchFavicon(const GURL& url) override; | 35 void FetchFavicon(const GURL& url) override; |
34 gfx::Image GetFavicon() const override; | 36 gfx::Image GetFavicon() const override; |
35 bool FaviconIsValid() const override; | 37 bool FaviconIsValid() const override; |
36 GURL GetActiveURL() override; | 38 GURL GetActiveURL() override; |
(...skipping 10 matching lines...) Expand all Loading... |
47 bool icon_url_changed, | 49 bool icon_url_changed, |
48 const gfx::Image& image) override; | 50 const gfx::Image& image) override; |
49 | 51 |
50 private: | 52 private: |
51 friend class web::WebStateUserData<WebFaviconDriver>; | 53 friend class web::WebStateUserData<WebFaviconDriver>; |
52 | 54 |
53 WebFaviconDriver(web::WebState* web_state, | 55 WebFaviconDriver(web::WebState* web_state, |
54 FaviconService* favicon_service, | 56 FaviconService* favicon_service, |
55 history::HistoryService* history_service, | 57 history::HistoryService* history_service, |
56 bookmarks::BookmarkModel* bookmark_model); | 58 bookmarks::BookmarkModel* bookmark_model); |
57 ~WebFaviconDriver() override; | |
58 | 59 |
59 // web::WebStateObserver implementation. | 60 // web::WebStateObserver implementation. |
60 void FaviconUrlUpdated( | 61 void FaviconUrlUpdated( |
61 const std::vector<web::FaviconURL>& candidates) override; | 62 const std::vector<web::FaviconURL>& candidates) override; |
62 | 63 |
63 // The URL passed to FetchFavicon(). | 64 // The URL passed to FetchFavicon(). |
64 GURL fetch_favicon_url_; | 65 GURL fetch_favicon_url_; |
65 | 66 |
66 // Image Fetcher used to fetch favicon. | 67 // Image Fetcher used to fetch favicon. |
67 image_fetcher::IOSImageDataFetcherWrapper image_fetcher_; | 68 image_fetcher::IOSImageDataFetcherWrapper image_fetcher_; |
68 | 69 |
69 DISALLOW_COPY_AND_ASSIGN(WebFaviconDriver); | 70 DISALLOW_COPY_AND_ASSIGN(WebFaviconDriver); |
70 }; | 71 }; |
71 | 72 |
72 } // namespace favicon | 73 } // namespace favicon |
73 | 74 |
74 #endif // COMPONENTS_FAVICON_IOS_WEB_FAVICON_DRIVER_H_ | 75 #endif // COMPONENTS_FAVICON_IOS_WEB_FAVICON_DRIVER_H_ |
OLD | NEW |