Roll ANGLE cc54ab3..c5b2ba5
[chromium-blink-merge.git] / components / favicon / ios / web_favicon_driver.h
blob9ea3e7d2a1d2b052191c8d12d0b8aef7a102cb98
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.
5 #ifndef COMPONENTS_FAVICON_IOS_WEB_FAVICON_DRIVER_H_
6 #define COMPONENTS_FAVICON_IOS_WEB_FAVICON_DRIVER_H_
8 #include "components/favicon/core/favicon_driver_impl.h"
9 #include "ios/web/public/web_state/web_state_observer.h"
10 #include "ios/web/public/web_state/web_state_user_data.h"
12 namespace web {
13 struct FaviconStatus;
14 class WebState;
17 namespace favicon {
19 // WebFaviconDriver is an implementation of FaviconDriver that listen to
20 // WebState events to start download of favicons and to get informed when the
21 // favicon download has completed.
22 class WebFaviconDriver : public web::WebStateObserver,
23 public web::WebStateUserData<WebFaviconDriver>,
24 public FaviconDriverImpl {
25 public:
26 static void CreateForWebState(web::WebState* web_state,
27 FaviconService* favicon_service,
28 history::HistoryService* history_service,
29 bookmarks::BookmarkModel* bookmark_model);
31 // FaviconDriver implementation.
32 gfx::Image GetFavicon() const override;
33 bool FaviconIsValid() const override;
34 int StartDownload(const GURL& url, int max_bitmap_size) override;
35 bool IsOffTheRecord() override;
36 GURL GetActiveURL() override;
37 bool GetActiveFaviconValidity() override;
38 void SetActiveFaviconValidity(bool valid) override;
39 GURL GetActiveFaviconURL() override;
40 void SetActiveFaviconURL(const GURL& url) override;
41 void SetActiveFaviconImage(const gfx::Image& image) override;
43 private:
44 friend class web::WebStateUserData<WebFaviconDriver>;
46 WebFaviconDriver(web::WebState* web_state,
47 FaviconService* favicon_service,
48 history::HistoryService* history_service,
49 bookmarks::BookmarkModel* bookmark_model);
50 ~WebFaviconDriver() override;
52 // web::WebStateObserver implementation.
53 void FaviconUrlUpdated(
54 const std::vector<web::FaviconURL>& candidates) override;
56 // Returns the active navigation entry's favicon.
57 web::FaviconStatus& GetFaviconStatus();
59 DISALLOW_COPY_AND_ASSIGN(WebFaviconDriver);
62 } // namespace favicon
64 #endif // COMPONENTS_FAVICON_IOS_WEB_FAVICON_DRIVER_H_