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

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

Issue 2650593003: 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..a95d1ab24c25c8a5666b58505c3730a7442cbea2 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.
+ GURL redirected_url = CurrentWebState()->GetVisibleURL();
+ if (redirected_url != original_url_ && !redirection_callback_.is_null()) {
+ 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