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 android.content.ComponentName; | 7 import android.content.ComponentName; |
8 import android.support.annotation.Nullable; | 8 import android.support.annotation.Nullable; |
9 | 9 |
10 import org.chromium.base.ContextUtils; | |
11 import org.chromium.base.ObserverList; | 10 import org.chromium.base.ObserverList; |
12 import org.chromium.base.annotations.CalledByNative; | 11 import org.chromium.base.annotations.CalledByNative; |
13 import org.chromium.base.annotations.JNINamespace; | 12 import org.chromium.base.annotations.JNINamespace; |
14 import org.chromium.chrome.R; | |
15 import org.chromium.chrome.browser.download.DownloadItem; | 13 import org.chromium.chrome.browser.download.DownloadItem; |
16 import org.chromium.chrome.browser.download.DownloadServiceDelegate; | 14 import org.chromium.chrome.browser.download.DownloadServiceDelegate; |
17 import org.chromium.chrome.browser.download.ui.BackendProvider.OfflinePageDelega
te; | 15 import org.chromium.chrome.browser.download.ui.BackendProvider.OfflinePageDelega
te; |
18 import org.chromium.chrome.browser.profiles.Profile; | 16 import org.chromium.chrome.browser.profiles.Profile; |
19 import org.chromium.chrome.browser.tab.Tab; | 17 import org.chromium.chrome.browser.tab.Tab; |
20 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; | 18 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; |
21 import org.chromium.chrome.browser.tabmodel.document.AsyncTabCreationParams; | 19 import org.chromium.chrome.browser.tabmodel.document.AsyncTabCreationParams; |
22 import org.chromium.chrome.browser.tabmodel.document.TabDelegate; | 20 import org.chromium.chrome.browser.tabmodel.document.TabDelegate; |
23 import org.chromium.content_public.browser.LoadUrlParams; | 21 import org.chromium.content_public.browser.LoadUrlParams; |
24 | 22 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 /** | 189 /** |
192 * Starts download of the page currently open in the specified Tab. | 190 * Starts download of the page currently open in the specified Tab. |
193 * If tab's contents are not yet loaded completely, we'll wait for it | 191 * If tab's contents are not yet loaded completely, we'll wait for it |
194 * to load enough for snapshot to be reasonable. If the Chrome is made | 192 * to load enough for snapshot to be reasonable. If the Chrome is made |
195 * background and killed, the background request remains that will | 193 * background and killed, the background request remains that will |
196 * eventually load the page in background and obtain its offline | 194 * eventually load the page in background and obtain its offline |
197 * snapshot. | 195 * snapshot. |
198 * @param tab a tab contents of which will be saved locally. | 196 * @param tab a tab contents of which will be saved locally. |
199 */ | 197 */ |
200 public void startDownload(Tab tab) { | 198 public void startDownload(Tab tab) { |
201 nativeStartDownload(mNativeOfflinePageDownloadBridge, tab, | 199 nativeStartDownload(mNativeOfflinePageDownloadBridge, tab); |
202 ContextUtils.getApplicationContext().getString(R.string.menu_dow
nloads)); | |
203 } | 200 } |
204 | 201 |
205 /** | 202 /** |
206 * Method to ensure that the bridge is created for tests without calling the
native portion of | 203 * Method to ensure that the bridge is created for tests without calling the
native portion of |
207 * initialization. | 204 * initialization. |
208 * @param isTesting flag indicating whether the constructor will initialize
native code. | 205 * @param isTesting flag indicating whether the constructor will initialize
native code. |
209 */ | 206 */ |
210 static void setIsTesting(boolean isTesting) { | 207 static void setIsTesting(boolean isTesting) { |
211 sIsTesting = isTesting; | 208 sIsTesting = isTesting; |
212 } | 209 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 private native void nativeDestroy(long nativeOfflinePageDownloadBridge); | 276 private native void nativeDestroy(long nativeOfflinePageDownloadBridge); |
280 native void nativeGetAllItems( | 277 native void nativeGetAllItems( |
281 long nativeOfflinePageDownloadBridge, List<OfflinePageDownloadItem>
items); | 278 long nativeOfflinePageDownloadBridge, List<OfflinePageDownloadItem>
items); |
282 native OfflinePageDownloadItem nativeGetItemByGuid( | 279 native OfflinePageDownloadItem nativeGetItemByGuid( |
283 long nativeOfflinePageDownloadBridge, String guid); | 280 long nativeOfflinePageDownloadBridge, String guid); |
284 native void nativeCancelDownload(long nativeOfflinePageDownloadBridge, Strin
g guid); | 281 native void nativeCancelDownload(long nativeOfflinePageDownloadBridge, Strin
g guid); |
285 native void nativePauseDownload(long nativeOfflinePageDownloadBridge, String
guid); | 282 native void nativePauseDownload(long nativeOfflinePageDownloadBridge, String
guid); |
286 native void nativeResumeDownload(long nativeOfflinePageDownloadBridge, Strin
g guid); | 283 native void nativeResumeDownload(long nativeOfflinePageDownloadBridge, Strin
g guid); |
287 native void nativeDeleteItemByGuid(long nativeOfflinePageDownloadBridge, Str
ing guid); | 284 native void nativeDeleteItemByGuid(long nativeOfflinePageDownloadBridge, Str
ing guid); |
288 native long nativeGetOfflineIdByGuid(long nativeOfflinePageDownloadBridge, S
tring guid); | 285 native long nativeGetOfflineIdByGuid(long nativeOfflinePageDownloadBridge, S
tring guid); |
289 native void nativeStartDownload( | 286 native void nativeStartDownload(long nativeOfflinePageDownloadBridge, Tab ta
b); |
290 long nativeOfflinePageDownloadBridge, Tab tab, String downloadsLabel
); | |
291 } | 287 } |
OLD | NEW |