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 #include "components/favicon/ios/web_favicon_driver.h" | 5 #include "components/favicon/ios/web_favicon_driver.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" |
8 #include "base/threading/sequenced_worker_pool.h" | 9 #include "base/threading/sequenced_worker_pool.h" |
9 #include "components/favicon/core/favicon_url.h" | 10 #include "components/favicon/core/favicon_url.h" |
10 #include "components/favicon/ios/favicon_url_util.h" | 11 #include "components/favicon/ios/favicon_url_util.h" |
11 #include "ios/web/public/browser_state.h" | 12 #include "ios/web/public/browser_state.h" |
12 #include "ios/web/public/favicon_status.h" | 13 #include "ios/web/public/favicon_status.h" |
13 #include "ios/web/public/navigation_item.h" | 14 #include "ios/web/public/navigation_item.h" |
14 #include "ios/web/public/navigation_manager.h" | 15 #include "ios/web/public/navigation_manager.h" |
15 #include "ios/web/public/web_state/web_state.h" | 16 #include "ios/web/public/web_state/web_state.h" |
16 #include "ios/web/public/web_thread.h" | 17 #include "ios/web/public/web_thread.h" |
17 #include "skia/ext/skia_utils_ios.h" | 18 #include "skia/ext/skia_utils_ios.h" |
(...skipping 18 matching lines...) Expand all Loading... |
36 | 37 |
37 // static | 38 // static |
38 void WebFaviconDriver::CreateForWebState( | 39 void WebFaviconDriver::CreateForWebState( |
39 web::WebState* web_state, | 40 web::WebState* web_state, |
40 FaviconService* favicon_service, | 41 FaviconService* favicon_service, |
41 history::HistoryService* history_service, | 42 history::HistoryService* history_service, |
42 bookmarks::BookmarkModel* bookmark_model) { | 43 bookmarks::BookmarkModel* bookmark_model) { |
43 if (FromWebState(web_state)) | 44 if (FromWebState(web_state)) |
44 return; | 45 return; |
45 | 46 |
46 web_state->SetUserData(UserDataKey(), | 47 web_state->SetUserData(UserDataKey(), base::WrapUnique(new WebFaviconDriver( |
47 new WebFaviconDriver(web_state, favicon_service, | 48 web_state, favicon_service, |
48 history_service, bookmark_model)); | 49 history_service, bookmark_model))); |
49 } | 50 } |
50 | 51 |
51 void WebFaviconDriver::FetchFavicon(const GURL& url) { | 52 void WebFaviconDriver::FetchFavicon(const GURL& url) { |
52 fetch_favicon_url_ = url; | 53 fetch_favicon_url_ = url; |
53 FaviconDriverImpl::FetchFavicon(url); | 54 FaviconDriverImpl::FetchFavicon(url); |
54 } | 55 } |
55 | 56 |
56 gfx::Image WebFaviconDriver::GetFavicon() const { | 57 gfx::Image WebFaviconDriver::GetFavicon() const { |
57 web::NavigationItem* item = | 58 web::NavigationItem* item = |
58 web_state()->GetNavigationManager()->GetLastCommittedItem(); | 59 web_state()->GetNavigationManager()->GetLastCommittedItem(); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 WebFaviconDriver::~WebFaviconDriver() { | 138 WebFaviconDriver::~WebFaviconDriver() { |
138 } | 139 } |
139 | 140 |
140 void WebFaviconDriver::FaviconUrlUpdated( | 141 void WebFaviconDriver::FaviconUrlUpdated( |
141 const std::vector<web::FaviconURL>& candidates) { | 142 const std::vector<web::FaviconURL>& candidates) { |
142 DCHECK(!candidates.empty()); | 143 DCHECK(!candidates.empty()); |
143 OnUpdateFaviconURL(GetActiveURL(), FaviconURLsFromWebFaviconURLs(candidates)); | 144 OnUpdateFaviconURL(GetActiveURL(), FaviconURLsFromWebFaviconURLs(candidates)); |
144 } | 145 } |
145 | 146 |
146 } // namespace favicon | 147 } // namespace favicon |
OLD | NEW |