OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.downloads; | 5 package org.chromium.chrome.browser.offlinepages.downloads; |
6 | 6 |
7 import org.chromium.base.ContextUtils; | 7 import org.chromium.base.ContextUtils; |
8 import org.chromium.base.annotations.CalledByNative; | 8 import org.chromium.base.annotations.CalledByNative; |
9 import org.chromium.chrome.R; | 9 import org.chromium.chrome.R; |
10 import org.chromium.chrome.browser.download.DownloadInfo; | 10 import org.chromium.chrome.browser.download.DownloadInfo; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 * @param url URL of the page to download. | 66 * @param url URL of the page to download. |
67 * @param startTime Time of the request. | 67 * @param startTime Time of the request. |
68 * @param displayName Name to be displayed on notification. | 68 * @param displayName Name to be displayed on notification. |
69 */ | 69 */ |
70 @CalledByNative | 70 @CalledByNative |
71 public static void notifyDownloadProgress( | 71 public static void notifyDownloadProgress( |
72 String guid, String url, long startTime, long bytesReceived, String
displayName) { | 72 String guid, String url, long startTime, long bytesReceived, String
displayName) { |
73 DownloadNotifier notifier = getDownloadNotifier(); | 73 DownloadNotifier notifier = getDownloadNotifier(); |
74 if (notifier == null) return; | 74 if (notifier == null) return; |
75 | 75 |
76 int percentage = | |
77 org.chromium.chrome.browser.download.DownloadItem.INDETERMINATE_
DOWNLOAD_PERCENTAGE; | |
78 DownloadInfo downloadInfo = new DownloadInfo.Builder() | 76 DownloadInfo downloadInfo = new DownloadInfo.Builder() |
79 .setIsOfflinePage(true) | 77 .setIsOfflinePage(true) |
80 .setDownloadGuid(guid) | 78 .setDownloadGuid(guid) |
81 .setFileName(displayName) | 79 .setFileName(displayName) |
82 .setFilePath(url) | 80 .setFilePath(url) |
83 .setPercentCompleted(percentage) | |
84 .setBytesReceived(bytesReceived) | 81 .setBytesReceived(bytesReceived) |
85 .setIsOffTheRecord(false) | 82 .setIsOffTheRecord(false) |
86 .setIsResumable(true) | 83 .setIsResumable(true) |
87 .setTimeRemainingInMillis(0) | 84 .setTimeRemainingInMillis(0) |
88 .build(); | 85 .build(); |
89 | 86 |
90 notifier.notifyDownloadProgress(downloadInfo, startTime, false); | 87 notifier.notifyDownloadProgress(downloadInfo, startTime, false); |
91 } | 88 } |
92 | 89 |
93 /** | 90 /** |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 public static void showDownloadingToast() { | 145 public static void showDownloadingToast() { |
149 Toast.makeText(ContextUtils.getApplicationContext(), R.string.download_s
tarted, | 146 Toast.makeText(ContextUtils.getApplicationContext(), R.string.download_s
tarted, |
150 Toast.LENGTH_SHORT) | 147 Toast.LENGTH_SHORT) |
151 .show(); | 148 .show(); |
152 } | 149 } |
153 | 150 |
154 private static DownloadNotifier getDownloadNotifier() { | 151 private static DownloadNotifier getDownloadNotifier() { |
155 return DownloadManagerService.getDownloadManagerService().getDownloadNot
ifier(); | 152 return DownloadManagerService.getDownloadManagerService().getDownloadNot
ifier(); |
156 } | 153 } |
157 } | 154 } |
OLD | NEW |