| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 package org.chromium.chrome.browser.offlinepages; | 5 package org.chromium.chrome.browser.offlinepages; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.content.Intent; | 9 import android.content.Intent; |
| 10 import android.content.IntentFilter; | 10 import android.content.IntentFilter; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 return onlineUrl; | 153 return onlineUrl; |
| 154 } | 154 } |
| 155 } | 155 } |
| 156 | 156 |
| 157 /** | 157 /** |
| 158 * Shows the snackbar for the current tab to provide offline specific inform
ation if needed. | 158 * Shows the snackbar for the current tab to provide offline specific inform
ation if needed. |
| 159 * @param activity The activity owning the tab. | 159 * @param activity The activity owning the tab. |
| 160 * @param tab The current tab. | 160 * @param tab The current tab. |
| 161 */ | 161 */ |
| 162 public static void showOfflineSnackbarIfNecessary(ChromeActivity activity, T
ab tab) { | 162 public static void showOfflineSnackbarIfNecessary(ChromeActivity activity, T
ab tab) { |
| 163 if (!OfflinePageBridge.isOfflinePagesEnabled()) return; | |
| 164 | |
| 165 if (OfflinePageTabObserver.getInstance() == null) { | 163 if (OfflinePageTabObserver.getInstance() == null) { |
| 166 SnackbarController snackbarController = | 164 SnackbarController snackbarController = |
| 167 createReloadSnackbarController(activity.getTabModelSelector(
)); | 165 createReloadSnackbarController(activity.getTabModelSelector(
)); |
| 168 OfflinePageTabObserver.init( | 166 OfflinePageTabObserver.init( |
| 169 activity.getBaseContext(), activity.getSnackbarManager(), sn
ackbarController); | 167 activity.getBaseContext(), activity.getSnackbarManager(), sn
ackbarController); |
| 170 } | 168 } |
| 171 | 169 |
| 172 showOfflineSnackbarIfNecessary(tab); | 170 showOfflineSnackbarIfNecessary(tab); |
| 173 } | 171 } |
| 174 | 172 |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 @VisibleForTesting | 579 @VisibleForTesting |
| 582 static void setInstanceForTesting(OfflinePageUtils instance) { | 580 static void setInstanceForTesting(OfflinePageUtils instance) { |
| 583 sInstance = instance; | 581 sInstance = instance; |
| 584 } | 582 } |
| 585 | 583 |
| 586 @VisibleForTesting | 584 @VisibleForTesting |
| 587 public static void setSnackbarDurationForTesting(int durationMs) { | 585 public static void setSnackbarDurationForTesting(int durationMs) { |
| 588 sSnackbarDurationMs = durationMs; | 586 sSnackbarDurationMs = durationMs; |
| 589 } | 587 } |
| 590 } | 588 } |
| OLD | NEW |