BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / components / favicon / core / favicon_driver_impl.h
blob7c4c442a10915a68a2d0784e085f3eb7fb253430
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_CORE_FAVICON_DRIVER_IMPL_H_
6 #define COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_IMPL_H_
8 #include <vector>
10 #include "base/macros.h"
11 #include "components/favicon/core/favicon_driver.h"
13 class GURL;
14 class SkBitmap;
16 namespace bookmarks {
17 class BookmarkModel;
20 namespace gfx {
21 class Image;
22 class Size;
25 namespace history {
26 class HistoryService;
29 namespace favicon {
31 class FaviconDriverObserver;
32 class FaviconHandler;
33 class FaviconService;
34 struct FaviconURL;
36 // FaviconDriverImpl is a partial implementation of FaviconDriver that allow
37 // sharing implementation between different embedder.
39 // FaviconDriverImpl works with FaviconHandlers to fetch the favicons. It
40 // fetches the given page's icons, requesting them from history backend. If the
41 // icon is not available or expired, the icon will be downloaded and saved in
42 // the history backend.
43 class FaviconDriverImpl : public FaviconDriver {
44 public:
45 // Favicon download callback.
46 // Public for testing.
47 void DidDownloadFavicon(int id,
48 int http_status_code,
49 const GURL& image_url,
50 const std::vector<SkBitmap>& bitmaps,
51 const std::vector<gfx::Size>& original_bitmap_sizes);
53 // FaviconDriver implementation.
54 void FetchFavicon(const GURL& url) override;
55 bool IsBookmarked(const GURL& url) override;
56 void OnFaviconAvailable(const gfx::Image& image,
57 const GURL& icon_url,
58 bool is_active_favicon) override;
59 bool HasPendingTasksForTest() override;
61 protected:
62 FaviconDriverImpl(FaviconService* favicon_service,
63 history::HistoryService* history_service,
64 bookmarks::BookmarkModel* bookmark_model);
65 ~FaviconDriverImpl() override;
67 // Returns whether downloading favicon for |url| previously failed.
68 bool WasUnableToDownloadFavicon(const GURL& url);
70 // Informs FaviconService that the favicon for |url| is out of date. If
71 // |force_reload| is true, then discard information about favicon download
72 // failures.
73 void SetFaviconOutOfDateForPage(const GURL& url, bool force_reload);
75 // Broadcasts new favicon URL candidates to FaviconHandlers.
76 void OnUpdateFaviconURL(const std::vector<FaviconURL>& candidates);
78 protected:
79 history::HistoryService* history_service() { return history_service_; }
81 FaviconService* favicon_service() { return favicon_service_; }
83 private:
84 // KeyedServices used by FaviconDriverImpl. They may be null during testing,
85 // but if they are defined, they must outlive the FaviconDriverImpl.
86 FaviconService* favicon_service_;
87 history::HistoryService* history_service_;
88 bookmarks::BookmarkModel* bookmark_model_;
90 // FaviconHandlers used to download the different kind of favicons. Both
91 // |touch_icon_handler_| and |large_icon_handler_| may be null depending
92 // on the platform or variations.
93 scoped_ptr<FaviconHandler> favicon_handler_;
94 scoped_ptr<FaviconHandler> touch_icon_handler_;
95 scoped_ptr<FaviconHandler> large_icon_handler_;
97 DISALLOW_COPY_AND_ASSIGN(FaviconDriverImpl);
100 } // namespace favicon
102 #endif // COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_IMPL_H_