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

Unified Diff: chrome/browser/android/offline_pages/offline_page_tab_helper.cc

Issue 2347723002: Fix the disappearance of "Offline" chip from the LocationBar when navigating to a fragment. (Closed)
Patch Set: updated per CR, fixed failing tests. Created 4 years, 3 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 | « chrome/browser/android/offline_pages/offline_page_tab_helper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/offline_pages/offline_page_tab_helper.cc
diff --git a/chrome/browser/android/offline_pages/offline_page_tab_helper.cc b/chrome/browser/android/offline_pages/offline_page_tab_helper.cc
index 79cb4183475e93bb07135bb1cc56dc2d9b364a88..0b31e810fe92a55927db70c03a82d99744604963 100644
--- a/chrome/browser/android/offline_pages/offline_page_tab_helper.cc
+++ b/chrome/browser/android/offline_pages/offline_page_tab_helper.cc
@@ -41,10 +41,8 @@ void OfflinePageTabHelper::DidStartNavigation(
// operations.
weak_ptr_factory_.InvalidateWeakPtrs();
- // Since this is a new navigation, we will reset the cached offline page,
- offline_page_ = nullptr;
+ provisional_offline_page_ = nullptr;
is_offline_preview_ = false;
-
reloading_url_on_net_error_ = false;
}
@@ -54,6 +52,16 @@ void OfflinePageTabHelper::DidFinishNavigation(
if (!navigation_handle->IsInMainFrame())
return;
+ if (!navigation_handle->HasCommitted())
+ return;
+
+ if (navigation_handle->IsSamePage()) {
+ return;
+ }
+
+ offline_page_ = std::move(provisional_offline_page_);
+ provisional_offline_page_ = nullptr;
+
// We might be reloading the URL in order to fetch the offline page.
// * If successful, nothing to do.
// * Otherwise, we're hitting error again. Bail out to avoid loop.
@@ -121,10 +129,16 @@ void OfflinePageTabHelper::SelectPageForOnlineURLDone(
web_contents()->GetController().LoadURLWithParams(load_params);
}
+// This is a callback from network request interceptor. It happens between
+// DidStartNavigation and DidFinishNavigation calls on this tab helper.
void OfflinePageTabHelper::SetOfflinePage(const OfflinePageItem& offline_page,
bool is_offline_preview) {
- offline_page_ = base::MakeUnique<OfflinePageItem>(offline_page);
+ provisional_offline_page_ = base::MakeUnique<OfflinePageItem>(offline_page);
is_offline_preview_ = is_offline_preview;
}
+const OfflinePageItem* OfflinePageTabHelper::GetOfflinePageForTest() const {
+ return provisional_offline_page_.get();
+}
+
} // namespace offline_pages
« no previous file with comments | « chrome/browser/android/offline_pages/offline_page_tab_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698