| 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 13 matching lines...) Expand all Loading... |
| 24 import org.chromium.chrome.browser.ChromeActivity; | 24 import org.chromium.chrome.browser.ChromeActivity; |
| 25 import org.chromium.chrome.browser.profiles.Profile; | 25 import org.chromium.chrome.browser.profiles.Profile; |
| 26 import org.chromium.chrome.browser.share.ShareHelper; | 26 import org.chromium.chrome.browser.share.ShareHelper; |
| 27 import org.chromium.chrome.browser.snackbar.Snackbar; | 27 import org.chromium.chrome.browser.snackbar.Snackbar; |
| 28 import org.chromium.chrome.browser.snackbar.SnackbarManager; | 28 import org.chromium.chrome.browser.snackbar.SnackbarManager; |
| 29 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController; | 29 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController; |
| 30 import org.chromium.chrome.browser.tab.Tab; | 30 import org.chromium.chrome.browser.tab.Tab; |
| 31 import org.chromium.chrome.browser.tabmodel.TabModelSelector; | 31 import org.chromium.chrome.browser.tabmodel.TabModelSelector; |
| 32 import org.chromium.components.bookmarks.BookmarkId; | 32 import org.chromium.components.bookmarks.BookmarkId; |
| 33 import org.chromium.components.offlinepages.SavePageResult; | 33 import org.chromium.components.offlinepages.SavePageResult; |
| 34 import org.chromium.content_public.browser.LoadUrlParams; | |
| 35 import org.chromium.content_public.browser.WebContents; | 34 import org.chromium.content_public.browser.WebContents; |
| 36 import org.chromium.net.ConnectionType; | 35 import org.chromium.net.ConnectionType; |
| 37 import org.chromium.net.NetworkChangeNotifier; | 36 import org.chromium.net.NetworkChangeNotifier; |
| 38 import org.chromium.ui.base.PageTransition; | |
| 39 | 37 |
| 40 import java.io.File; | 38 import java.io.File; |
| 41 import java.io.FileInputStream; | 39 import java.io.FileInputStream; |
| 42 import java.io.FileOutputStream; | 40 import java.io.FileOutputStream; |
| 43 import java.io.IOException; | 41 import java.io.IOException; |
| 44 import java.nio.channels.FileChannel; | 42 import java.nio.channels.FileChannel; |
| 45 import java.util.concurrent.TimeUnit; | 43 import java.util.concurrent.TimeUnit; |
| 46 | 44 |
| 47 /** | 45 /** |
| 48 * A class holding static util functions for offline pages. | 46 * A class holding static util functions for offline pages. |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 Log.d(TAG, "building snackbar controller"); | 208 Log.d(TAG, "building snackbar controller"); |
| 211 | 209 |
| 212 return new SnackbarController() { | 210 return new SnackbarController() { |
| 213 @Override | 211 @Override |
| 214 public void onAction(Object actionData) { | 212 public void onAction(Object actionData) { |
| 215 assert actionData != null; | 213 assert actionData != null; |
| 216 int tabId = (int) actionData; | 214 int tabId = (int) actionData; |
| 217 RecordUserAction.record("OfflinePages.ReloadButtonClicked"); | 215 RecordUserAction.record("OfflinePages.ReloadButtonClicked"); |
| 218 Tab foundTab = tabModelSelector.getTabById(tabId); | 216 Tab foundTab = tabModelSelector.getTabById(tabId); |
| 219 if (foundTab == null) return; | 217 if (foundTab == null) return; |
| 220 | 218 // Delegates to Tab to reload the page. Tab will send the correc
t header in order to |
| 221 LoadUrlParams params = | 219 // load the right page. |
| 222 new LoadUrlParams(foundTab.getOriginalUrl(), PageTransit
ion.RELOAD); | 220 foundTab.reload(); |
| 223 foundTab.loadUrl(params); | |
| 224 } | 221 } |
| 225 | 222 |
| 226 @Override | 223 @Override |
| 227 public void onDismissNoAction(Object actionData) { | 224 public void onDismissNoAction(Object actionData) { |
| 228 RecordUserAction.record("OfflinePages.ReloadButtonNotClicked"); | 225 RecordUserAction.record("OfflinePages.ReloadButtonNotClicked"); |
| 229 } | 226 } |
| 230 }; | 227 }; |
| 231 } | 228 } |
| 232 | 229 |
| 233 public static DeviceConditions getDeviceConditions(Context context) { | 230 public static DeviceConditions getDeviceConditions(Context context) { |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 @VisibleForTesting | 576 @VisibleForTesting |
| 580 static void setInstanceForTesting(OfflinePageUtils instance) { | 577 static void setInstanceForTesting(OfflinePageUtils instance) { |
| 581 sInstance = instance; | 578 sInstance = instance; |
| 582 } | 579 } |
| 583 | 580 |
| 584 @VisibleForTesting | 581 @VisibleForTesting |
| 585 public static void setSnackbarDurationForTesting(int durationMs) { | 582 public static void setSnackbarDurationForTesting(int durationMs) { |
| 586 sSnackbarDurationMs = durationMs; | 583 sSnackbarDurationMs = durationMs; |
| 587 } | 584 } |
| 588 } | 585 } |
| OLD | NEW |