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

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

Issue 2337363002: Load live version when reloading an offline page on connected network (Closed)
Patch Set: Rebase again 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
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 0b31e810fe92a55927db70c03a82d99744604963..39486a553a371036fc9fc8341045787a46c5820e 100644
--- a/chrome/browser/android/offline_pages/offline_page_tab_helper.cc
+++ b/chrome/browser/android/offline_pages/offline_page_tab_helper.cc
@@ -37,11 +37,20 @@ void OfflinePageTabHelper::DidStartNavigation(
if (!navigation_handle->IsInMainFrame())
return;
+ // If the navigation is referencing fragment (synchronous navigation could
+ // only be referencing fragment navigation or pushState/popState navigation,
+ // while the latter is unlikely because offline page disables Javascript
+ // execution), do not reset out cached offline info.
+ if (navigation_handle->IsSynchronousNavigation())
Dmitry Titov 2016/09/17 02:22:54 As discussed, lets keep the IsSamePage() check in
jianli 2016/09/19 21:29:05 We also need to clear the real values here because
+ return;
+
// This is a new navigation so we can invalidate any previously scheduled
// operations.
weak_ptr_factory_.InvalidateWeakPtrs();
provisional_offline_page_ = nullptr;
+ offline_page_ = nullptr;
+ offline_header_.Clear();
is_offline_preview_ = false;
reloading_url_on_net_error_ = false;
}
@@ -55,9 +64,8 @@ void OfflinePageTabHelper::DidFinishNavigation(
if (!navigation_handle->HasCommitted())
return;
- if (navigation_handle->IsSamePage()) {
+ if (navigation_handle->IsSynchronousNavigation())
return;
- }
offline_page_ = std::move(provisional_offline_page_);
provisional_offline_page_ = nullptr;
@@ -121,19 +129,20 @@ void OfflinePageTabHelper::SelectPageForOnlineURLDone(
// Reloads the page with extra header set to force loading the offline page.
content::NavigationController::LoadURLParams load_params(offline_page->url);
load_params.transition_type = ui::PAGE_TRANSITION_RELOAD;
- load_params.extra_headers = kOfflinePageHeader;
- load_params.extra_headers += ":";
- load_params.extra_headers += kOfflinePageHeaderReasonKey;
- load_params.extra_headers += "=";
- load_params.extra_headers += kOfflinePageHeaderReasonValueDueToNetError;
+ OfflinePageHeader offline_header;
+ offline_header.reason = OfflinePageHeader::Reason::NET_ERROR;
+ load_params.extra_headers = offline_header.GetCompleteHeaderString();
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) {
+void OfflinePageTabHelper::SetOfflinePage(
+ const OfflinePageItem& offline_page,
+ const OfflinePageHeader& offline_header,
+ bool is_offline_preview) {
provisional_offline_page_ = base::MakeUnique<OfflinePageItem>(offline_page);
+ offline_header_ = offline_header;
is_offline_preview_ = is_offline_preview;
}

Powered by Google App Engine
This is Rietveld 408576698