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

Unified Diff: ios/chrome/browser/dom_distiller/distiller_favicon.mm

Issue 2529283002: Save favicon during reading list distillation (Closed)
Patch Set: Add a comment Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/dom_distiller/distiller_favicon.mm
diff --git a/ios/chrome/browser/dom_distiller/distiller_favicon.mm b/ios/chrome/browser/dom_distiller/distiller_favicon.mm
new file mode 100644
index 0000000000000000000000000000000000000000..392349a22842d465595e6a5d21a60a3ecb8335e4
--- /dev/null
+++ b/ios/chrome/browser/dom_distiller/distiller_favicon.mm
@@ -0,0 +1,53 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ios/chrome/browser/dom_distiller/distiller_favicon.h"
+
+#include "components/favicon/ios/web_favicon_driver.h"
+#include "components/keyed_service/core/service_access_type.h"
+#include "ios/chrome/browser/bookmarks/bookmark_model_factory.h"
+#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
+#include "ios/chrome/browser/favicon/favicon_service_factory.h"
+#include "ios/chrome/browser/history/history_service_factory.h"
+#include "ios/public/provider/web/web_controller_provider.h"
+#include "ios/web/public/favicon_url.h"
+#include "url/gurl.h"
+
+namespace dom_distiller {
+
+DistillerFavicon::DistillerFavicon(web::BrowserState* browser_state)
+ : browser_state_(browser_state) {}
+
+DistillerFavicon::~DistillerFavicon() {}
+
+void DistillerFavicon::HandleFaviconURL(std::vector<web::FaviconURL> urls,
+ const GURL& page_url) {
+ if (urls.empty())
+ return;
+
+ ios::ChromeBrowserState* original_browser_state =
+ ios::ChromeBrowserState::FromBrowserState(browser_state_);
+
+ std::unique_ptr<ios::WebControllerProvider> provider =
+ ios::GetWebControllerProviderFactory()->CreateWebControllerProvider(
kkhorimoto 2016/11/28 23:48:25 This is creating a new WebState, so this will be d
+ browser_state_);
+
+ 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
+
+ favicon::WebFaviconDriver::CreateForWebState(
+ web_state,
+ ios::FaviconServiceFactory::GetForBrowserState(
+ original_browser_state, ServiceAccessType::EXPLICIT_ACCESS),
+ ios::HistoryServiceFactory::GetForBrowserState(
+ original_browser_state, ServiceAccessType::EXPLICIT_ACCESS),
+ ios::BookmarkModelFactory::GetForBrowserState(original_browser_state));
+
+ favicon::WebFaviconDriver* favicon_driver =
+ favicon::WebFaviconDriver::FromWebState(web_state);
+
+ favicon_driver->FetchFavicon(page_url);
kkhorimoto 2016/11/28 23:48:26 Is this doing the same as executing the fetch favi
+
+ ((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
+}
+}

Powered by Google App Engine
This is Rietveld 408576698