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

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

Issue 2836333004: [Offline pages] Update of OfflinePageUtils for better testability (Closed)
Patch Set: Rebasing and addressing feedback Created 3 years, 7 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 | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java » ('j') | 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/OfflinePageTabObserver.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageTabObserver.java b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageTabObserver.java
index c1dff32614a6b70f35510d6b0f4944520332140a..cd995bab1d2d944442d222e25038f023ffa8b3bb 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageTabObserver.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageTabObserver.java
@@ -171,7 +171,7 @@ public class OfflinePageTabObserver
@Override
public void onUrlUpdated(Tab tab) {
Log.d(TAG, "onUrlUpdated");
- if (!isOfflinePage(tab)) {
+ if (!OfflinePageUtils.isOfflinePage(tab)) {
stopObservingTab(tab);
} else {
if (isObservingTab(tab)) {
@@ -184,7 +184,7 @@ public class OfflinePageTabObserver
}
void startObservingTab(Tab tab) {
- if (!isOfflinePage(tab)) return;
+ if (!OfflinePageUtils.isOfflinePage(tab)) return;
mCurrentTab = tab;
@@ -240,15 +240,16 @@ public class OfflinePageTabObserver
// Methods from ConnectionTypeObserver.
@Override
public void onConnectionTypeChanged(int connectionType) {
- Log.d(TAG, "Got connectivity event, connectionType: " + connectionType + ", is connected: "
- + isConnected() + ", controller: " + mSnackbarController);
+ Log.d(TAG,
+ "Got connectivity event, connectionType: " + connectionType + ", is connected: "
+ + OfflinePageUtils.isConnected() + ", controller: " + mSnackbarController);
maybeShowReloadSnackbar(mCurrentTab, true);
// Since we are loosing the connection, next time we connect, we still want to show a
// snackbar. This works in event that onConnectionTypeChanged happens, while Chrome is not
// visible. Making it visible after that would not trigger the snackbar, even though
// connection state changed. See http://crbug.com/651410
- if (!isConnected()) {
+ if (!OfflinePageUtils.isConnected()) {
for (TabState tabState : mObservedTabs.values()) {
tabState.wasSnackbarSeen = false;
}
@@ -275,26 +276,11 @@ public class OfflinePageTabObserver
return mIsObservingNetworkChanges;
}
- @VisibleForTesting
- boolean isConnected() {
- return OfflinePageUtils.isConnected();
- }
-
- @VisibleForTesting
- boolean isShowingOfflinePreview(Tab tab) {
- return OfflinePageUtils.isShowingOfflinePreview(tab);
- }
-
- @VisibleForTesting
- boolean isOfflinePage(Tab tab) {
- return OfflinePageUtils.isOfflinePage(tab);
- }
-
void maybeShowReloadSnackbar(Tab tab, boolean isNetworkEvent) {
// Exclude Offline Previews, as there is a seperate UI for previews.
- if (tab == null || tab.isFrozen() || tab.isHidden() || !isOfflinePage(tab)
- || isShowingOfflinePreview(tab) || !isConnected() || !isLoadedTab(tab)
- || (wasSnackbarSeen(tab) && !isNetworkEvent)) {
+ if (tab == null || tab.isFrozen() || tab.isHidden() || !OfflinePageUtils.isOfflinePage(tab)
+ || OfflinePageUtils.isShowingOfflinePreview(tab) || !OfflinePageUtils.isConnected()
+ || !isLoadedTab(tab) || (wasSnackbarSeen(tab) && !isNetworkEvent)) {
// Conditions to show a snackbar are not met.
return;
}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698