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

Unified Diff: ios/chrome/browser/reading_list/reading_list_distiller_page.mm

Issue 2646993002: Store distilled URL during distillation in Reading List on iOS (Closed)
Patch Set: Created 3 years, 11 months 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/reading_list/reading_list_distiller_page.mm
diff --git a/ios/chrome/browser/reading_list/reading_list_distiller_page.mm b/ios/chrome/browser/reading_list/reading_list_distiller_page.mm
index 9bf23db09388e4c8415320c1df6b097b776e4a77..e3f9ee954fd4dee65a903391eb1b5f27f8a2cf08 100644
--- a/ios/chrome/browser/reading_list/reading_list_distiller_page.mm
+++ b/ios/chrome/browser/reading_list/reading_list_distiller_page.mm
@@ -38,6 +38,11 @@ ReadingListDistillerPage::ReadingListDistillerPage(
ReadingListDistillerPage::~ReadingListDistillerPage() {}
+void ReadingListDistillerPage::SetRedirectionCallback(
+ RedirectionCallback redirection_callback) {
+ redirection_callback_ = redirection_callback;
+}
+
void ReadingListDistillerPage::DistillPageImpl(const GURL& url,
const std::string& script) {
std::unique_ptr<web::WebState> old_web_state = DetachWebState();
@@ -52,6 +57,7 @@ void ReadingListDistillerPage::DistillPageImpl(const GURL& url,
favicon_driver->FetchFavicon(url);
}
AttachWebState(std::move(new_web_state));
+ original_url_ = url;
DistillerPageIOS::DistillPageImpl(url, script);
}
@@ -117,6 +123,13 @@ void ReadingListDistillerPage::WaitForPageLoadCompletion() {
}
void ReadingListDistillerPage::DelayedOnLoadURLDone() {
+ // The page is ready to be distilled.
+ // If the visible URL is not the original URL, notify the caller that URL
+ // changed.
+ redirected_url_ = CurrentWebState()->GetVisibleURL();
+ if (redirected_url_ != original_url_ && redirection_callback_) {
jif 2017/01/20 10:23:19 testing |redirection_callback_| does not result in
Olivier 2017/01/20 10:47:07 It compiles and works. But the callback provides a
+ redirection_callback_.Run(original_url_, redirected_url_);
+ }
DistillerPageIOS::OnLoadURLDone(web::PageLoadCompletionStatus::SUCCESS);
}
@@ -166,7 +179,7 @@ void ReadingListDistillerPage::HandleGoogleCachedAMPPage() {
bool ReadingListDistillerPage::HandleGoogleCachedAMPPageJavaScriptResult(
id result,
- NSError* error) {
+ id error) {
if (error) {
return false;
}

Powered by Google App Engine
This is Rietveld 408576698