OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 #include "ios/chrome/browser/dom_distiller/distiller_favicon.h" | |
6 | |
7 #include "components/favicon/ios/web_favicon_driver.h" | |
8 #include "components/keyed_service/core/service_access_type.h" | |
9 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" | |
10 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | |
11 #include "ios/chrome/browser/favicon/favicon_service_factory.h" | |
12 #include "ios/chrome/browser/history/history_service_factory.h" | |
13 #include "ios/public/provider/web/web_controller_provider.h" | |
14 #include "ios/web/public/favicon_url.h" | |
15 #include "url/gurl.h" | |
16 | |
17 namespace dom_distiller { | |
18 | |
19 DistillerFavicon::DistillerFavicon(web::BrowserState* browser_state) | |
20 : browser_state_(browser_state) {} | |
21 | |
22 DistillerFavicon::~DistillerFavicon() {} | |
23 | |
24 void DistillerFavicon::HandleFaviconURL(std::vector<web::FaviconURL> urls, | |
25 const GURL& page_url) { | |
26 if (urls.empty()) | |
27 return; | |
28 | |
29 ios::ChromeBrowserState* original_browser_state = | |
30 ios::ChromeBrowserState::FromBrowserState(browser_state_); | |
31 | |
32 std::unique_ptr<ios::WebControllerProvider> provider = | |
33 ios::GetWebControllerProviderFactory()->CreateWebControllerProvider( | |
kkhorimoto
2016/11/28 23:48:25
This is creating a new WebState, so this will be d
| |
34 browser_state_); | |
35 | |
36 web::WebState* web_state = provider->GetWebState(); | |
gambard
2016/11/28 10:20:04
This might not be the good way to get the web_stat
kkhorimoto
2016/11/28 23:48:25
Ideally, we should be removing the web controller
Eugene But (OOO till 7-30)
2016/11/30 18:51:31
There should be no need to create new WebControlle
| |
37 | |
38 favicon::WebFaviconDriver::CreateForWebState( | |
39 web_state, | |
40 ios::FaviconServiceFactory::GetForBrowserState( | |
41 original_browser_state, ServiceAccessType::EXPLICIT_ACCESS), | |
42 ios::HistoryServiceFactory::GetForBrowserState( | |
43 original_browser_state, ServiceAccessType::EXPLICIT_ACCESS), | |
44 ios::BookmarkModelFactory::GetForBrowserState(original_browser_state)); | |
45 | |
46 favicon::WebFaviconDriver* favicon_driver = | |
47 favicon::WebFaviconDriver::FromWebState(web_state); | |
48 | |
49 favicon_driver->FetchFavicon(page_url); | |
kkhorimoto
2016/11/28 23:48:26
Is this doing the same as executing the fetch favi
| |
50 | |
51 ((web::WebStateObserver*)favicon_driver)->FaviconUrlUpdated(urls); | |
kkhorimoto
2016/11/28 23:48:25
I'm unclear on what exactly is happening here. Co
kkhorimoto
2016/11/28 23:48:26
Also, we need to be using static_cast<> for these
gambard
2016/11/30 10:59:43
You are right, but it is because this code isn't w
| |
52 } | |
53 } | |
OLD | NEW |