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

Unified Diff: chrome/browser/android/tab_android.cc

Issue 2337363002: Load live version when reloading an offline page on connected network (Closed)
Patch Set: Fix 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/tab_android.cc
diff --git a/chrome/browser/android/tab_android.cc b/chrome/browser/android/tab_android.cc
index a0e5897d7a52551babfceaed467d0c6b6580238f..96e28b1e72a81b4519025e550ff4200e1fdfbe56 100644
--- a/chrome/browser/android/tab_android.cc
+++ b/chrome/browser/android/tab_android.cc
@@ -68,6 +68,7 @@
#include "components/offline_pages/offline_page_feature.h"
#include "components/offline_pages/offline_page_item.h"
#include "components/offline_pages/offline_page_model.h"
+#include "components/offline_pages/request_header/offline_page_header.h"
#include "components/sessions/content/content_live_tab.h"
#include "components/sessions/core/tab_restore_service.h"
#include "components/url_formatter/url_fixer.h"
@@ -833,6 +834,28 @@ ScopedJavaLocalRef<jobject> TabAndroid::GetOfflinePage(
env, *offline_page);
}
+ScopedJavaLocalRef<jstring> TabAndroid::GetOfflinePageHeaderForReload(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& obj) {
+ const offline_pages::OfflinePageHeader* offline_header =
+ offline_pages::OfflinePageUtils::GetOfflineHeaderFromWebContents(
+ web_contents());
+ if (!offline_header)
+ return ScopedJavaLocalRef<jstring>();
+
+ // Only replaces the reason field with "reload" value that is used to trigger
+ // the network conditon check again in deciding whether to load the offline
+ // page. All other fields in the offline header should still carry to the
+ // reload request in order to keep the consistent behavior if we do decide to
+ // load the offline page. For example, "id" field should be kept in order to
+ // load the same offline version again if desired.
+ offline_pages::OfflinePageHeader offline_header_for_reload = *offline_header;
+ offline_header_for_reload.reason =
+ offline_pages::OfflinePageHeader::Reason::RELOAD;
+ return ScopedJavaLocalRef<jstring>(ConvertUTF8ToJavaString(
+ env, offline_header_for_reload.GetCompleteHeaderString()));
+}
+
bool TabAndroid::HasPrerenderedUrl(JNIEnv* env,
const JavaParamRef<jobject>& obj,
const JavaParamRef<jstring>& url) {

Powered by Google App Engine
This is Rietveld 408576698