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

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

Issue 2649263007: [ReadingList Offline] Handle AMP pages after the rendering delay. (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
« no previous file with comments | « ios/chrome/browser/reading_list/reading_list_distiller_page.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a95d1ab24c25c8a5666b58505c3730a7442cbea2..8a3d58c758c149579c4ba4da95537d184b00668a 100644
--- a/ios/chrome/browser/reading_list/reading_list_distiller_page.mm
+++ b/ios/chrome/browser/reading_list/reading_list_distiller_page.mm
@@ -21,8 +21,9 @@
#include "url/url_constants.h"
namespace {
-// The delay between the page load and the distillation in seconds.
-const int64_t kDistillationDelayInSeconds = 2;
+// The delay given to the web page to render after the PageLoaded callback.
+const int64_t kPageLoadDelayInSeconds = 2;
+
const char* kGetIframeURLJavaScript =
"document.getElementsByTagName('iframe')[0].src;";
} // namespace
@@ -105,24 +106,25 @@ void ReadingListDistillerPage::OnLoadURLDone(
DistillerPageIOS::OnLoadURLDone(load_completion_status);
return;
}
- if (IsGoogleCachedAMPPage()) {
- // Workaround for Google AMP pages.
- HandleGoogleCachedAMPPage();
- } else {
- WaitForPageLoadCompletion();
- }
-}
-
-void ReadingListDistillerPage::WaitForPageLoadCompletion() {
+ // Page is loaded but rendering may not be done yet. Give a delay to the page.
base::WeakPtr<ReadingListDistillerPage> weak_this =
weak_ptr_factory_.GetWeakPtr();
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::Bind(&ReadingListDistillerPage::DelayedOnLoadURLDone, weak_this),
- base::TimeDelta::FromSeconds(kDistillationDelayInSeconds));
+ base::TimeDelta::FromSeconds(kPageLoadDelayInSeconds));
}
void ReadingListDistillerPage::DelayedOnLoadURLDone() {
+ if (IsGoogleCachedAMPPage()) {
+ // Workaround for Google AMP pages.
+ HandleGoogleCachedAMPPage();
+ } else {
+ ContinuePageDistillation();
+ }
+}
+
+void ReadingListDistillerPage::ContinuePageDistillation() {
// The page is ready to be distilled.
// If the visible URL is not the original URL, notify the caller that URL
// changed.
@@ -170,7 +172,7 @@ void ReadingListDistillerPage::HandleGoogleCachedAMPPage() {
!weak_this->HandleGoogleCachedAMPPageJavaScriptResult(result,
error)) {
// If there is an error on navigation, continue normal distillation.
- weak_this->WaitForPageLoadCompletion();
+ weak_this->ContinuePageDistillation();
}
// If there is no error, the navigation completion will trigger a new
// |OnLoadURLDone| call that will resume the distillation.
« no previous file with comments | « ios/chrome/browser/reading_list/reading_list_distiller_page.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698