summaryrefslogtreecommitdiffstats
path: root/components/favicon/ios/web_favicon_driver.h
diff options
context:
space:
mode:
Diffstat (limited to 'components/favicon/ios/web_favicon_driver.h')
-rw-r--r--components/favicon/ios/web_favicon_driver.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/components/favicon/ios/web_favicon_driver.h b/components/favicon/ios/web_favicon_driver.h
new file mode 100644
index 0000000..343d2be
--- /dev/null
+++ b/components/favicon/ios/web_favicon_driver.h
@@ -0,0 +1,66 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_FAVICON_IOS_WEB_FAVICON_DRIVER_H_
+#define COMPONENTS_FAVICON_IOS_WEB_FAVICON_DRIVER_H_
+
+#include "components/favicon/core/favicon_driver_impl.h"
+#include "ios/web/public/web_state/web_state_observer.h"
+#include "ios/web/public/web_state/web_state_user_data.h"
+
+namespace web {
+struct FaviconStatus;
+class WebState;
+}
+
+namespace favicon {
+
+// WebFaviconDriver is an implementation of FaviconDriver that listen to
+// WebState events to start download of favicons and to get informed when the
+// favicon download has completed.
+class WebFaviconDriver : public web::WebStateObserver,
+ public web::WebStateUserData<WebFaviconDriver>,
+ public FaviconDriverImpl {
+ public:
+ static void CreateForWebState(web::WebState* web_state,
+ FaviconService* favicon_service,
+ history::HistoryService* history_service,
+ bookmarks::BookmarkModel* bookmark_model);
+
+ // FaviconDriver implementation.
+ gfx::Image GetFavicon() const override;
+ bool FaviconIsValid() const override;
+ int StartDownload(const GURL& url, int max_bitmap_size) override;
+ bool IsOffTheRecord() override;
+ GURL GetActiveURL() override;
+ base::string16 GetActiveTitle() override;
+ bool GetActiveFaviconValidity() override;
+ void SetActiveFaviconValidity(bool valid) override;
+ GURL GetActiveFaviconURL() override;
+ void SetActiveFaviconURL(const GURL& url) override;
+ gfx::Image GetActiveFaviconImage() override;
+ void SetActiveFaviconImage(const gfx::Image& image) override;
+
+ private:
+ friend class web::WebStateUserData<WebFaviconDriver>;
+
+ WebFaviconDriver(web::WebState* web_state,
+ FaviconService* favicon_service,
+ history::HistoryService* history_service,
+ bookmarks::BookmarkModel* bookmark_model);
+ ~WebFaviconDriver() override;
+
+ // web::WebStateObserver implementation.
+ void FaviconURLUpdated(
+ const std::vector<web::FaviconURL>& candidates) override;
+
+ // Returns the active navigation entry's favicon.
+ web::FaviconStatus& GetFaviconStatus();
+
+ DISALLOW_COPY_AND_ASSIGN(WebFaviconDriver);
+};
+
+} // namespace favicon
+
+#endif // COMPONENTS_FAVICON_IOS_WEB_FAVICON_DRIVER_H_