Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: components/favicon/core/favicon_driver_impl.h

Issue 1064823002: Componentize FaviconTabHelper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@favicon-notification
Patch Set: Fix BUILD.gn Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_CORE_FAVICON_DRIVER_IMPL_H_
6 #define COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_IMPL_H_
7
8 #include <vector>
9
10 #include "base/macros.h"
11 #include "components/favicon/core/favicon_driver.h"
12
13 class GURL;
14 class SkBitmap;
15
16 namespace bookmarks {
17 class BookmarkModel;
18 }
19
20 namespace gfx {
21 class Image;
22 class Size;
23 }
24
25 namespace history {
26 class HistoryService;
27 }
28
29 namespace favicon {
30
31 class FaviconDriverObserver;
32 class FaviconHandler;
33 class FaviconService;
34 struct FaviconURL;
35
36 // FaviconDriverImpl is a partial implementation of FaviconDriver that allow
37 // sharing implementation between different embedder.
38 //
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);
52
53 // FaviconDriver implementation.
54 void FetchFavicon(const GURL& url) override;
55 void SaveFavicon() override;
56 bool IsBookmarked(const GURL& url) override;
57 void OnFaviconAvailable(const gfx::Image& image,
58 const GURL& icon_url,
59 bool is_active_favicon) override;
60 bool HasPendingTasksForTest() override;
61
62 protected:
63 FaviconDriverImpl(FaviconService* favicon_service,
64 history::HistoryService* history_service,
65 bookmarks::BookmarkModel* bookmark_model);
66 ~FaviconDriverImpl() override;
67
68 // Returns whether downloading favicon for |url| previously failed.
69 bool WasUnableToDownloadFavicon(const GURL& url);
70
71 // Informs FaviconService that the favicon for |url| is out of date. If
72 // |force_reload| is true, then discard information about favicon download
73 // failures.
74 void SetFaviconOutOfDateForPage(const GURL& url, bool force_reload);
75
76 // Broadcasts new favicon URL candidates to FaviconHandlers.
77 void OnUpdateFaviconURL(const std::vector<FaviconURL>& candidates);
78
79 private:
80 // KeyedServices used by FaviconDriverImpl. They may be null during testing,
81 // but if they are defined, they must outlive the FaviconDriverImpl.
82 FaviconService* favicon_service_;
83 history::HistoryService* history_service_;
84 bookmarks::BookmarkModel* bookmark_model_;
85
86 // FaviconHandlers used to download the different kind of favicons. Both
87 // |touch_icon_handler_| and |large_icon_handler_| may be null depending
88 // on the platform or variations.
89 scoped_ptr<FaviconHandler> favicon_handler_;
90 scoped_ptr<FaviconHandler> touch_icon_handler_;
91 scoped_ptr<FaviconHandler> large_icon_handler_;
92
93 DISALLOW_COPY_AND_ASSIGN(FaviconDriverImpl);
94 };
95
96 } // namespace favicon
97
98 #endif // COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_IMPL_H_
OLDNEW
« no previous file with comments | « components/favicon/core/favicon_driver.cc ('k') | components/favicon/core/favicon_driver_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698