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_CORE_FAVICON_DRIVER_IMPL_H_ | 5 #ifndef COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_IMPL_H_ |
6 #define COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_IMPL_H_ | 6 #define COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_IMPL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "components/favicon/core/favicon_driver.h" | 12 #include "components/favicon/core/favicon_driver.h" |
| 13 #include "components/favicon/core/favicon_handler.h" |
13 | 14 |
14 class GURL; | 15 class GURL; |
15 class SkBitmap; | |
16 | |
17 namespace bookmarks { | 16 namespace bookmarks { |
18 class BookmarkModel; | 17 class BookmarkModel; |
19 } | 18 } |
20 | 19 |
21 namespace gfx { | |
22 class Size; | |
23 } | |
24 | 20 |
25 namespace history { | 21 namespace history { |
26 class HistoryService; | 22 class HistoryService; |
27 } | 23 } |
28 | 24 |
29 namespace favicon { | 25 namespace favicon { |
30 | 26 |
31 class FaviconHandler; | |
32 class FaviconService; | 27 class FaviconService; |
33 struct FaviconURL; | 28 struct FaviconURL; |
34 | 29 |
35 // FaviconDriverImpl is a partial implementation of FaviconDriver that allow | 30 // FaviconDriverImpl is a partial implementation of FaviconDriver that allow |
36 // sharing implementation between different embedder. | 31 // sharing implementation between different embedder. |
37 // | 32 // |
38 // FaviconDriverImpl works with FaviconHandlers to fetch the favicons. It | 33 // FaviconDriverImpl works with FaviconHandlers to fetch the favicons. It |
39 // fetches the given page's icons, requesting them from history backend. If the | 34 // fetches the given page's icons, requesting them from history backend. If the |
40 // icon is not available or expired, the icon will be downloaded and saved in | 35 // icon is not available or expired, the icon will be downloaded and saved in |
41 // the history backend. | 36 // the history backend. |
42 class FaviconDriverImpl : public FaviconDriver { | 37 class FaviconDriverImpl : public FaviconDriver, |
| 38 public FaviconHandler::Delegate { |
43 public: | 39 public: |
44 // Favicon download callback. | |
45 // Public for testing. | |
46 void DidDownloadFavicon(int id, | |
47 int http_status_code, | |
48 const GURL& image_url, | |
49 const std::vector<SkBitmap>& bitmaps, | |
50 const std::vector<gfx::Size>& original_bitmap_sizes); | |
51 | |
52 // FaviconDriver implementation. | 40 // FaviconDriver implementation. |
53 void FetchFavicon(const GURL& url) override; | 41 void FetchFavicon(const GURL& url) override; |
| 42 |
| 43 // FaviconHandler::Delegate implementation. |
54 bool IsBookmarked(const GURL& url) override; | 44 bool IsBookmarked(const GURL& url) override; |
55 bool HasPendingTasksForTest() override; | 45 |
| 46 // Returns whether the driver is waiting for a download to complete or for |
| 47 // data from the FaviconService. Reserved for testing. |
| 48 bool HasPendingTasksForTest(); |
56 | 49 |
57 protected: | 50 protected: |
58 FaviconDriverImpl(FaviconService* favicon_service, | 51 FaviconDriverImpl(FaviconService* favicon_service, |
59 history::HistoryService* history_service, | 52 history::HistoryService* history_service, |
60 bookmarks::BookmarkModel* bookmark_model); | 53 bookmarks::BookmarkModel* bookmark_model); |
61 ~FaviconDriverImpl() override; | 54 ~FaviconDriverImpl() override; |
62 | 55 |
63 // Returns whether downloading favicon for |url| previously failed. | 56 // Returns whether downloading favicon for |url| previously failed. |
64 bool WasUnableToDownloadFavicon(const GURL& url); | 57 bool WasUnableToDownloadFavicon(const GURL& url); |
65 | 58 |
(...skipping 22 matching lines...) Expand all Loading... |
88 // |touch_icon_handler_| may be null depending on the platform and variations. | 81 // |touch_icon_handler_| may be null depending on the platform and variations. |
89 std::unique_ptr<FaviconHandler> favicon_handler_; | 82 std::unique_ptr<FaviconHandler> favicon_handler_; |
90 std::unique_ptr<FaviconHandler> touch_icon_handler_; | 83 std::unique_ptr<FaviconHandler> touch_icon_handler_; |
91 | 84 |
92 DISALLOW_COPY_AND_ASSIGN(FaviconDriverImpl); | 85 DISALLOW_COPY_AND_ASSIGN(FaviconDriverImpl); |
93 }; | 86 }; |
94 | 87 |
95 } // namespace favicon | 88 } // namespace favicon |
96 | 89 |
97 #endif // COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_IMPL_H_ | 90 #endif // COMPONENTS_FAVICON_CORE_FAVICON_DRIVER_IMPL_H_ |
OLD | NEW |