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.ObserverList; | 10 import org.chromium.base.ObserverList; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 * @param guid GUID of the item to open. | 168 * @param guid GUID of the item to open. |
169 * @param componentName If specified, targets a specific Activity to open th
e offline page in. | 169 * @param componentName If specified, targets a specific Activity to open th
e offline page in. |
170 */ | 170 */ |
171 @Override | 171 @Override |
172 public void openItem(String guid, @Nullable ComponentName componentName) { | 172 public void openItem(String guid, @Nullable ComponentName componentName) { |
173 OfflinePageDownloadItem item = getItem(guid); | 173 OfflinePageDownloadItem item = getItem(guid); |
174 if (item == null) return; | 174 if (item == null) return; |
175 | 175 |
176 LoadUrlParams params = new LoadUrlParams(item.getUrl()); | 176 LoadUrlParams params = new LoadUrlParams(item.getUrl()); |
177 Map<String, String> headers = new HashMap<String, String>(); | 177 Map<String, String> headers = new HashMap<String, String>(); |
178 headers.put("X-Chrome-offline", "reason=download id=" | 178 headers.put("X-Chrome-offline", "persist=1 reason=download id=" |
179 + Long.toString(nativeGetOfflineIdByGuid(mNativeOfflinePageDownl
oadBridge, guid))); | 179 + Long.toString(nativeGetOfflineIdByGuid( |
| 180 mNativeOfflinePageDownloadBridge, guid))); |
180 params.setExtraHeaders(headers); | 181 params.setExtraHeaders(headers); |
181 AsyncTabCreationParams asyncParams = componentName == null | 182 AsyncTabCreationParams asyncParams = componentName == null |
182 ? new AsyncTabCreationParams(params) | 183 ? new AsyncTabCreationParams(params) |
183 : new AsyncTabCreationParams(params, componentName); | 184 : new AsyncTabCreationParams(params, componentName); |
184 final TabDelegate tabDelegate = new TabDelegate(false); | 185 final TabDelegate tabDelegate = new TabDelegate(false); |
185 tabDelegate.createNewTab(asyncParams, TabLaunchType.FROM_CHROME_UI, Tab.
INVALID_TAB_ID); | 186 tabDelegate.createNewTab(asyncParams, TabLaunchType.FROM_CHROME_UI, Tab.
INVALID_TAB_ID); |
186 } | 187 } |
187 | 188 |
188 /** | 189 /** |
189 * Starts download of the page currently open in the specified Tab. | 190 * Starts download of the page currently open in the specified Tab. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 long nativeOfflinePageDownloadBridge, List<OfflinePageDownloadItem>
items); | 278 long nativeOfflinePageDownloadBridge, List<OfflinePageDownloadItem>
items); |
278 native OfflinePageDownloadItem nativeGetItemByGuid( | 279 native OfflinePageDownloadItem nativeGetItemByGuid( |
279 long nativeOfflinePageDownloadBridge, String guid); | 280 long nativeOfflinePageDownloadBridge, String guid); |
280 native void nativeCancelDownload(long nativeOfflinePageDownloadBridge, Strin
g guid); | 281 native void nativeCancelDownload(long nativeOfflinePageDownloadBridge, Strin
g guid); |
281 native void nativePauseDownload(long nativeOfflinePageDownloadBridge, String
guid); | 282 native void nativePauseDownload(long nativeOfflinePageDownloadBridge, String
guid); |
282 native void nativeResumeDownload(long nativeOfflinePageDownloadBridge, Strin
g guid); | 283 native void nativeResumeDownload(long nativeOfflinePageDownloadBridge, Strin
g guid); |
283 native void nativeDeleteItemByGuid(long nativeOfflinePageDownloadBridge, Str
ing guid); | 284 native void nativeDeleteItemByGuid(long nativeOfflinePageDownloadBridge, Str
ing guid); |
284 native long nativeGetOfflineIdByGuid(long nativeOfflinePageDownloadBridge, S
tring guid); | 285 native long nativeGetOfflineIdByGuid(long nativeOfflinePageDownloadBridge, S
tring guid); |
285 native void nativeStartDownload(long nativeOfflinePageDownloadBridge, Tab ta
b); | 286 native void nativeStartDownload(long nativeOfflinePageDownloadBridge, Tab ta
b); |
286 } | 287 } |
OLD | NEW |