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 #include "ios/chrome/browser/dom_distiller/distiller_favicon_driver.h" |
| 17 |
| 18 namespace dom_distiller { |
| 19 |
| 20 DistillerFavicon::DistillerFavicon(web::BrowserState* browser_state) |
| 21 : browser_state_(browser_state) {} |
| 22 |
| 23 DistillerFavicon::~DistillerFavicon() {} |
| 24 std::unique_ptr<ios::WebControllerProvider> DistillerFavicon::CreateProvider( |
| 25 const GURL& page_url) { |
| 26 ios::ChromeBrowserState* original_browser_state = |
| 27 ios::ChromeBrowserState::FromBrowserState(browser_state_); |
| 28 |
| 29 std::unique_ptr<ios::WebControllerProvider> provider = |
| 30 ios::GetWebControllerProviderFactory()->CreateWebControllerProvider( |
| 31 browser_state_); |
| 32 |
| 33 web::WebState* web_state = provider->GetWebState(); |
| 34 |
| 35 ::DistillerFaviconDriver::CreateForWebState( |
| 36 web_state, |
| 37 ios::FaviconServiceFactory::GetForBrowserState( |
| 38 original_browser_state, ServiceAccessType::EXPLICIT_ACCESS), |
| 39 ios::HistoryServiceFactory::GetForBrowserState( |
| 40 original_browser_state, ServiceAccessType::EXPLICIT_ACCESS), |
| 41 ios::BookmarkModelFactory::GetForBrowserState(original_browser_state), |
| 42 page_url); |
| 43 |
| 44 favicon::WebFaviconDriver* favicon_driver = |
| 45 favicon::WebFaviconDriver::FromWebState(web_state); |
| 46 |
| 47 favicon_driver->FetchFavicon(page_url); |
| 48 |
| 49 return provider; |
| 50 } |
| 51 } |
OLD | NEW |