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

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

Issue 2838773002: Move offline related functions from Tab to OfflinePageUtils (Closed)
Patch Set: Fix tests Created 3 years, 8 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 47709b4ecaa56d3c3a03bca1f85c93db9906bb88..39f86dd3b467f3364d3dc87c0b817423f4b4d94c 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
@@ -283,7 +283,7 @@ public class OfflinePageUtils {
return;
}
- OfflinePageItem offlinePage = currentTab.getOfflinePage();
+ OfflinePageItem offlinePage = offlinePageBridge.getOfflinePage(currentTab.getWebContents());
if (offlinePage != null) {
// If we're currently on offline page get the saved file directly.
prepareFileAndShare(shareDirectly, saveLastUsed, mainActivity, title, text,
@@ -564,6 +564,28 @@ public class OfflinePageUtils {
}
/**
+ * Checks if an offline page is shown for the tab.
+ * @param tab The tab to be reloaded.
+ * @return True if the offline page is opened.
+ */
+ public static boolean isOfflinePage(Tab tab) {
+ OfflinePageBridge offlinePageBridge = getInstance().getOfflinePageBridge(tab.getProfile());
+ if (offlinePageBridge == null) return false;
+ return offlinePageBridge.isOfflinePage(tab.getWebContents());
+ }
+
+ /**
+ * Retrieves the offline page that is shown for the tab.
+ * @param tab The tab to be reloaded.
+ * @return The offline page if tab currently displays it, null otherwise.
+ */
+ public static OfflinePageItem getOfflinePage(Tab tab) {
+ OfflinePageBridge offlinePageBridge = getInstance().getOfflinePageBridge(tab.getProfile());
+ if (offlinePageBridge == null) return null;
+ return offlinePageBridge.getOfflinePage(tab.getWebContents());
+ }
+
+ /**
* Reloads specified tab, which should allow to open an online version of the page.
* @param tab The tab to be reloaded.
*/
@@ -698,7 +720,7 @@ public class OfflinePageUtils {
// We first compute the bitwise tab restore context.
int tabRestoreContext = 0;
if (isConnected()) tabRestoreContext |= BIT_ONLINE;
- OfflinePageItem page = tab.getOfflinePage();
+ OfflinePageItem page = getOfflinePage(tab);
if (page != null) {
tabRestoreContext |= BIT_OFFLINE_PAGE;
if (page.getClientId().getNamespace().equals(OfflinePageBridge.LAST_N_NAMESPACE)) {

Powered by Google App Engine
This is Rietveld 408576698