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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/tab_android.h" 5 #include "chrome/browser/android/tab_android.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 #include "components/bookmarks/browser/bookmark_node.h" 61 #include "components/bookmarks/browser/bookmark_node.h"
62 #include "components/bookmarks/browser/bookmark_utils.h" 62 #include "components/bookmarks/browser/bookmark_utils.h"
63 #include "components/bookmarks/managed/managed_bookmark_service.h" 63 #include "components/bookmarks/managed/managed_bookmark_service.h"
64 #include "components/dom_distiller/core/url_utils.h" 64 #include "components/dom_distiller/core/url_utils.h"
65 #include "components/favicon/content/content_favicon_driver.h" 65 #include "components/favicon/content/content_favicon_driver.h"
66 #include "components/navigation_interception/intercept_navigation_delegate.h" 66 #include "components/navigation_interception/intercept_navigation_delegate.h"
67 #include "components/navigation_interception/navigation_params.h" 67 #include "components/navigation_interception/navigation_params.h"
68 #include "components/offline_pages/offline_page_feature.h" 68 #include "components/offline_pages/offline_page_feature.h"
69 #include "components/offline_pages/offline_page_item.h" 69 #include "components/offline_pages/offline_page_item.h"
70 #include "components/offline_pages/offline_page_model.h" 70 #include "components/offline_pages/offline_page_model.h"
71 #include "components/offline_pages/request_header/offline_page_header.h"
71 #include "components/sessions/content/content_live_tab.h" 72 #include "components/sessions/content/content_live_tab.h"
72 #include "components/sessions/core/tab_restore_service.h" 73 #include "components/sessions/core/tab_restore_service.h"
73 #include "components/url_formatter/url_fixer.h" 74 #include "components/url_formatter/url_fixer.h"
74 #include "content/public/browser/android/compositor.h" 75 #include "content/public/browser/android/compositor.h"
75 #include "content/public/browser/browser_thread.h" 76 #include "content/public/browser/browser_thread.h"
76 #include "content/public/browser/interstitial_page.h" 77 #include "content/public/browser/interstitial_page.h"
77 #include "content/public/browser/navigation_entry.h" 78 #include "content/public/browser/navigation_entry.h"
78 #include "content/public/browser/notification_service.h" 79 #include "content/public/browser/notification_service.h"
79 #include "content/public/browser/render_frame_host.h" 80 #include "content/public/browser/render_frame_host.h"
80 #include "content/public/browser/render_process_host.h" 81 #include "content/public/browser/render_process_host.h"
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 const offline_pages::OfflinePageItem* offline_page = 827 const offline_pages::OfflinePageItem* offline_page =
827 offline_pages::OfflinePageUtils::GetOfflinePageFromWebContents( 828 offline_pages::OfflinePageUtils::GetOfflinePageFromWebContents(
828 web_contents()); 829 web_contents());
829 if (!offline_page) 830 if (!offline_page)
830 return ScopedJavaLocalRef<jobject>(); 831 return ScopedJavaLocalRef<jobject>();
831 832
832 return offline_pages::android::OfflinePageBridge::ConvertToJavaOfflinePage( 833 return offline_pages::android::OfflinePageBridge::ConvertToJavaOfflinePage(
833 env, *offline_page); 834 env, *offline_page);
834 } 835 }
835 836
837 ScopedJavaLocalRef<jstring> TabAndroid::GetOfflinePageHeaderForReload(
838 JNIEnv* env,
839 const base::android::JavaParamRef<jobject>& obj) {
840 const offline_pages::OfflinePageHeader* offline_header =
841 offline_pages::OfflinePageUtils::GetOfflineHeaderFromWebContents(
842 web_contents());
843 if (!offline_header)
844 return ScopedJavaLocalRef<jstring>();
845
846 // Only replaces the reason field with "reload" value that is used to trigger
847 // the network conditon check again in deciding whether to load the offline
848 // page. All other fields in the offline header should still carry to the
849 // reload request in order to keep the consistent behavior if we do decide to
850 // load the offline page. For example, "id" field should be kept in order to
851 // load the same offline version again if desired.
852 offline_pages::OfflinePageHeader offline_header_for_reload = *offline_header;
853 offline_header_for_reload.reason =
854 offline_pages::OfflinePageHeader::Reason::RELOAD;
855 return ScopedJavaLocalRef<jstring>(ConvertUTF8ToJavaString(
856 env, offline_header_for_reload.GetCompleteHeaderString()));
857 }
858
836 bool TabAndroid::HasPrerenderedUrl(JNIEnv* env, 859 bool TabAndroid::HasPrerenderedUrl(JNIEnv* env,
837 const JavaParamRef<jobject>& obj, 860 const JavaParamRef<jobject>& obj,
838 const JavaParamRef<jstring>& url) { 861 const JavaParamRef<jstring>& url) {
839 GURL gurl(base::android::ConvertJavaStringToUTF8(env, url)); 862 GURL gurl(base::android::ConvertJavaStringToUTF8(env, url));
840 return HasPrerenderedUrl(gurl); 863 return HasPrerenderedUrl(gurl);
841 } 864 }
842 865
843 namespace { 866 namespace {
844 867
845 class ChromeInterceptNavigationDelegate : public InterceptNavigationDelegate { 868 class ChromeInterceptNavigationDelegate : public InterceptNavigationDelegate {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { 938 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) {
916 TRACE_EVENT0("native", "TabAndroid::Init"); 939 TRACE_EVENT0("native", "TabAndroid::Init");
917 // This will automatically bind to the Java object and pass ownership there. 940 // This will automatically bind to the Java object and pass ownership there.
918 new TabAndroid(env, obj); 941 new TabAndroid(env, obj);
919 } 942 }
920 943
921 // static 944 // static
922 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { 945 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) {
923 return RegisterNativesImpl(env); 946 return RegisterNativesImpl(env);
924 } 947 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698