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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java

Issue 1586783003: If you reload an offline page while online, load the online version. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR fixes per fGorski Created 4 years, 11 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
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageTabObserver.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java
index 7282f35b7e0ef00a40ffc4befe40659feaf6e76c..d884142e035071842de18c52bf6a319fb990617d 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java
@@ -193,6 +193,18 @@ public class OfflinePageUtils {
}
/**
+ * Whenever we reload an offline page, if we are online, load the online version of the page
+ * instead, on the theory that the user prefers the online version of the page.
+ */
+ public static void preferOnlineVersion(ChromeActivity activity, Tab tab, String newUrl) {
+ // If we are reloading an offline page, but are online, get the online version.
+ if (newUrl.equals(tab.getUrl()) && isConnected(activity.getBaseContext())) {
+ Log.i(TAG, "Refreshing to the online version of an offline page, since we are online");
+ tab.loadUrl(new LoadUrlParams(tab.getOfflinePageOriginalUrl(), PageTransition.RELOAD));
+ }
+ }
+
+ /**
* Shows the snackbar for the current tab to provide offline specific information if needed.
* @param activity The activity owning the tab.
* @param tab The current tab.
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageTabObserver.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698