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

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

Issue 1514833002: [Offline Pages on the NTP] Bypass the network interstitial (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@offline_badge
Patch Set: newt review 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
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 c5e4dd7919b8d84e6b832dda3d203b05b4a6cdc7..a7ab9fa216ba50df287c092da932bf254a057a83 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
@@ -71,6 +71,26 @@ public class OfflinePageUtils {
}
/**
+ * Returns the offline URL corresponding to the given online URL if it is available and the
+ * network is not connected, otherwise returns the given online URL. If an offline URL is
+ * returned, it is also marked as accessed.
+ * @param context Context associated with the activity.
+ * @param bridge The OfflinePageBridge.
+ * @param onlineUrl The online URL in question.
+ */
+ public static String getOfflineUrlIfNecessary(
+ Context context, OfflinePageBridge bridge, String onlineUrl) {
+ if (OfflinePageBridge.isEnabled() && bridge != null && !isConnected(context)) {
+ OfflinePageItem offlineItem = bridge.getPageByOnlineURL(onlineUrl);
+ if (offlineItem != null) {
+ bridge.markPageAccessed(offlineItem.getBookmarkId());
+ return offlineItem.getOfflineUrl();
+ }
+ }
+ return onlineUrl;
+ }
+
+ /**
* 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.

Powered by Google App Engine
This is Rietveld 408576698