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

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

Issue 2337363002: Load live version when reloading an offline page on connected network (Closed)
Patch Set: Update BUILD.gn 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_bridge.cc
diff --git a/chrome/browser/android/offline_pages/offline_page_bridge.cc b/chrome/browser/android/offline_pages/offline_page_bridge.cc
index a63608818adbbb8b7db428a95fc17ea96823b32b..578576764f6c575bae533c5daa593000eea7a1ed 100644
--- a/chrome/browser/android/offline_pages/offline_page_bridge.cc
+++ b/chrome/browser/android/offline_pages/offline_page_bridge.cc
@@ -28,6 +28,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 "content/public/browser/browser_context.h"
#include "content/public/browser/web_contents.h"
#include "jni/OfflinePageBridge_jni.h"
@@ -456,6 +457,34 @@ void OfflinePageBridge::CheckMetadataConsistency(
offline_page_model_->CheckMetadataConsistency();
}
+ScopedJavaLocalRef<jstring> OfflinePageBridge::GetOfflinePageHeaderForReload(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& obj,
+ const JavaParamRef<jobject>& j_web_contents) {
+ content::WebContents* web_contents =
+ content::WebContents::FromJavaWebContents(j_web_contents);
+ if (!web_contents)
+ return ScopedJavaLocalRef<jstring>();
+
+ 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()));
+}
+
void OfflinePageBridge::GetRequestsInQueue(
JNIEnv* env,
const JavaParamRef<jobject>& obj,

Powered by Google App Engine
This is Rietveld 408576698