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

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

Issue 2610953002: Do not reload pengingItem to open Reading List offline page. (Closed)
Patch Set: fix unittests 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_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 db32a0a30bbac4bdd1c5c70d9026a9762d333981..c58d76e1fc92bed10d25bd951754a7c3ad0c8055 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
@@ -125,7 +125,7 @@ void ReadingListWebStateObserver::ReadingListModelLoaded(
const GURL& currentURL = item->GetVirtualURL();
if (IsUrlAvailableOffline(currentURL)) {
pending_url_ = currentURL;
- LoadOfflineReadingListEntry(item);
+ LoadOfflineReadingListEntry();
StopCheckingProgress();
}
}
@@ -203,7 +203,7 @@ void ReadingListWebStateObserver::PageLoaded(
reading_list_model_->SetReadStatus(pending_url_, true);
UMA_HISTOGRAM_BOOLEAN("ReadingList.OfflineVersionDisplayed", false);
} else {
- LoadOfflineReadingListEntry(item);
+ LoadOfflineReadingListEntry();
}
StopCheckingProgress();
}
@@ -245,7 +245,7 @@ void ReadingListWebStateObserver::VerifyIfReadingListEntryStartedLoading() {
double progress = web_state()->GetLoadingProgress();
const double kMinimumExpectedProgressPerStep = 0.25;
if (progress < try_number_ * kMinimumExpectedProgressPerStep) {
- LoadOfflineReadingListEntry(item);
+ LoadOfflineReadingListEntry();
StopCheckingProgress();
return;
}
@@ -258,9 +258,7 @@ void ReadingListWebStateObserver::VerifyIfReadingListEntryStartedLoading() {
}
}
-void ReadingListWebStateObserver::LoadOfflineReadingListEntry(
- web::NavigationItem* item) {
- DCHECK(item);
+void ReadingListWebStateObserver::LoadOfflineReadingListEntry() {
DCHECK(reading_list_model_);
if (!pending_url_.is_valid() || !IsUrlAvailableOffline(pending_url_)) {
return;
@@ -270,9 +268,20 @@ void ReadingListWebStateObserver::LoadOfflineReadingListEntry(
DCHECK(entry->DistilledState() == ReadingListEntry::PROCESSED);
GURL url =
reading_list::DistilledURLForPath(entry->DistilledPath(), entry->URL());
- item->SetURL(url);
- item->SetVirtualURL(pending_url_);
- web_state()->GetNavigationManager()->Reload(false);
+ web::NavigationManager* manager = web_state()->GetNavigationManager();
+ web::NavigationItem* item = manager->GetPendingItem();
+ if (item) {
+ web_state()->Stop();
+ web::WebState::OpenURLParams params(url, item->GetReferrer(),
+ WindowOpenDisposition::CURRENT_TAB,
+ item->GetTransitionType(), NO);
+ web_state()->OpenURL(params);
+ } else {
+ item = manager->GetLastCommittedItem();
+ item->SetURL(url);
+ item->SetVirtualURL(pending_url_);
+ web_state()->GetNavigationManager()->Reload(false);
+ }
reading_list_model_->SetReadStatus(entry->URL(), true);
UMA_HISTOGRAM_BOOLEAN("ReadingList.OfflineVersionDisplayed", true);
}

Powered by Google App Engine
This is Rietveld 408576698