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

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

Issue 2616093002: Do not start timer on when reloading a Reading List offline page on iOS. (Closed)
Patch Set: feedback 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_web_state_observer.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_web_state_observer.mm
diff --git a/ios/chrome/browser/reading_list/reading_list_web_state_observer.mm b/ios/chrome/browser/reading_list/reading_list_web_state_observer.mm
index 7de2fe25d300fb863166979f6373e99997ce3f55..8b9196558f571ee9bf1c441e46ffee38c3b4f752 100644
--- a/ios/chrome/browser/reading_list/reading_list_web_state_observer.mm
+++ b/ios/chrome/browser/reading_list/reading_list_web_state_observer.mm
@@ -85,6 +85,7 @@ ReadingListWebStateObserver::ReadingListWebStateObserver(
ReadingListModel* reading_list_model)
: web::WebStateObserver(web_state),
reading_list_model_(reading_list_model),
+ last_load_was_offline_(false),
last_load_result_(web::PageLoadCompletionStatus::SUCCESS) {
reading_list_model_->AddObserver(this);
DCHECK(web_state);
@@ -156,24 +157,36 @@ void ReadingListWebStateObserver::StartCheckingLoading() {
web::NavigationManager* manager = web_state()->GetNavigationManager();
web::NavigationItem* item = manager->GetPendingItem();
+ bool is_reload = false;
// Manager->GetPendingItem() returns null on reload.
// TODO(crbug.com/676129): Remove this workaround once GetPendingItem()
// returns the correct value on reload.
if (!item) {
item = manager->GetLastCommittedItem();
+ is_reload = true;
}
if (!ShouldObserveItem(item)) {
StopCheckingProgress();
return;
}
+ bool last_load_was_offline = last_load_was_offline_;
+ last_load_was_offline_ = false;
pending_url_ = item->GetVirtualURL();
- if (!IsUrlAvailableOffline(pending_url_)) {
- // No need to launch the timer as there is no offline version to show.
- // Track |pending_url_| to mark the entry as read in case of a successful
- // load.
+
+ is_reload =
+ is_reload || ui::PageTransitionCoreTypeIs(item->GetTransitionType(),
+ ui::PAGE_TRANSITION_RELOAD);
+ // If the user is reloading from the offline page, the intention is to access
+ // the online page even on bad networks. No need to launch timer.
+ bool reloading_from_offline = last_load_was_offline && is_reload;
+
+ // No need to launch the timer either if there is no offline version to show.
+ // Track |pending_url_| to mark the entry as read in case of a successful
+ // load.
+ if (reloading_from_offline || !IsUrlAvailableOffline(pending_url_)) {
return;
}
try_number_ = 0;
@@ -265,6 +278,7 @@ void ReadingListWebStateObserver::LoadOfflineReadingListEntry() {
}
const ReadingListEntry* entry =
reading_list_model_->GetEntryByURL(pending_url_);
+ last_load_was_offline_ = true;
DCHECK(entry->DistilledState() == ReadingListEntry::PROCESSED);
GURL url =
reading_list::DistilledURLForPath(entry->DistilledPath(), entry->URL());
« no previous file with comments | « ios/chrome/browser/reading_list/reading_list_web_state_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698