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

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: 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #include "components/bookmarks/browser/bookmark_node.h" 60 #include "components/bookmarks/browser/bookmark_node.h"
61 #include "components/bookmarks/browser/bookmark_utils.h" 61 #include "components/bookmarks/browser/bookmark_utils.h"
62 #include "components/bookmarks/managed/managed_bookmark_service.h" 62 #include "components/bookmarks/managed/managed_bookmark_service.h"
63 #include "components/dom_distiller/core/url_utils.h" 63 #include "components/dom_distiller/core/url_utils.h"
64 #include "components/favicon/content/content_favicon_driver.h" 64 #include "components/favicon/content/content_favicon_driver.h"
65 #include "components/navigation_interception/intercept_navigation_delegate.h" 65 #include "components/navigation_interception/intercept_navigation_delegate.h"
66 #include "components/navigation_interception/navigation_params.h" 66 #include "components/navigation_interception/navigation_params.h"
67 #include "components/offline_pages/offline_page_feature.h" 67 #include "components/offline_pages/offline_page_feature.h"
68 #include "components/offline_pages/offline_page_item.h" 68 #include "components/offline_pages/offline_page_item.h"
69 #include "components/offline_pages/offline_page_model.h" 69 #include "components/offline_pages/offline_page_model.h"
70 #include "components/offline_pages/request_header/offline_page_header.h"
70 #include "components/sessions/content/content_live_tab.h" 71 #include "components/sessions/content/content_live_tab.h"
71 #include "components/sessions/core/tab_restore_service.h" 72 #include "components/sessions/core/tab_restore_service.h"
72 #include "components/url_formatter/url_fixer.h" 73 #include "components/url_formatter/url_fixer.h"
73 #include "content/public/browser/android/compositor.h" 74 #include "content/public/browser/android/compositor.h"
74 #include "content/public/browser/browser_thread.h" 75 #include "content/public/browser/browser_thread.h"
75 #include "content/public/browser/interstitial_page.h" 76 #include "content/public/browser/interstitial_page.h"
76 #include "content/public/browser/navigation_entry.h" 77 #include "content/public/browser/navigation_entry.h"
77 #include "content/public/browser/notification_service.h" 78 #include "content/public/browser/notification_service.h"
78 #include "content/public/browser/render_frame_host.h" 79 #include "content/public/browser/render_frame_host.h"
79 #include "content/public/browser/render_process_host.h" 80 #include "content/public/browser/render_process_host.h"
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 const offline_pages::OfflinePageItem* offline_page = 830 const offline_pages::OfflinePageItem* offline_page =
830 offline_pages::OfflinePageUtils::GetOfflinePageFromWebContents( 831 offline_pages::OfflinePageUtils::GetOfflinePageFromWebContents(
831 web_contents()); 832 web_contents());
832 if (!offline_page) 833 if (!offline_page)
833 return ScopedJavaLocalRef<jobject>(); 834 return ScopedJavaLocalRef<jobject>();
834 835
835 return offline_pages::android::OfflinePageBridge::ConvertToJavaOfflinePage( 836 return offline_pages::android::OfflinePageBridge::ConvertToJavaOfflinePage(
836 env, *offline_page); 837 env, *offline_page);
837 } 838 }
838 839
840 ScopedJavaLocalRef<jstring> TabAndroid::GetOfflinePageHeaderForReload(
841 JNIEnv* env,
842 const base::android::JavaParamRef<jobject>& obj) {
843 const offline_pages::OfflinePageHeader* offline_header =
844 offline_pages::OfflinePageUtils::GetOfflineHeaderFromWebContents(
845 web_contents());
846 if (!offline_header)
847 return ScopedJavaLocalRef<jstring>();
848
849 offline_pages::OfflinePageHeader offline_header_for_reload = *offline_header;
850 offline_header_for_reload.reason =
851 offline_pages::OfflinePageHeader::Reason::RELOAD;
Dmitry Titov 2016/09/16 21:37:23 Please add comment why do you need the rest of the
jianli 2016/09/16 23:08:48 Done.
852 return ScopedJavaLocalRef<jstring>(ConvertUTF8ToJavaString(
853 env, offline_header_for_reload.ToFullHeaderString()));
854 }
855
839 bool TabAndroid::HasPrerenderedUrl(JNIEnv* env, 856 bool TabAndroid::HasPrerenderedUrl(JNIEnv* env,
840 const JavaParamRef<jobject>& obj, 857 const JavaParamRef<jobject>& obj,
841 const JavaParamRef<jstring>& url) { 858 const JavaParamRef<jstring>& url) {
842 GURL gurl(base::android::ConvertJavaStringToUTF8(env, url)); 859 GURL gurl(base::android::ConvertJavaStringToUTF8(env, url));
843 return HasPrerenderedUrl(gurl); 860 return HasPrerenderedUrl(gurl);
844 } 861 }
845 862
846 namespace { 863 namespace {
847 864
848 class ChromeInterceptNavigationDelegate : public InterceptNavigationDelegate { 865 class ChromeInterceptNavigationDelegate : public InterceptNavigationDelegate {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { 935 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) {
919 TRACE_EVENT0("native", "TabAndroid::Init"); 936 TRACE_EVENT0("native", "TabAndroid::Init");
920 // This will automatically bind to the Java object and pass ownership there. 937 // This will automatically bind to the Java object and pass ownership there.
921 new TabAndroid(env, obj); 938 new TabAndroid(env, obj);
922 } 939 }
923 940
924 // static 941 // static
925 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { 942 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) {
926 return RegisterNativesImpl(env); 943 return RegisterNativesImpl(env);
927 } 944 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698