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"); | 178 headers.put("X-Chrome-offline", "persist=1 reason=download"); |
179 params.setExtraHeaders(headers); | 179 params.setExtraHeaders(headers); |
180 AsyncTabCreationParams asyncParams = componentName == null | 180 AsyncTabCreationParams asyncParams = componentName == null |
181 ? new AsyncTabCreationParams(params) | 181 ? new AsyncTabCreationParams(params) |
182 : new AsyncTabCreationParams(params, componentName); | 182 : new AsyncTabCreationParams(params, componentName); |
183 final TabDelegate tabDelegate = new TabDelegate(false); | 183 final TabDelegate tabDelegate = new TabDelegate(false); |
184 tabDelegate.createNewTab(asyncParams, TabLaunchType.FROM_LINK, Tab.INVAL
ID_TAB_ID); | 184 tabDelegate.createNewTab(asyncParams, TabLaunchType.FROM_LINK, Tab.INVAL
ID_TAB_ID); |
185 } | 185 } |
186 | 186 |
187 /** | 187 /** |
188 * Starts download of the page currently open in the specified Tab. | 188 * Starts download of the page currently open in the specified Tab. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 long nativeOfflinePageDownloadBridge, List<OfflinePageDownloadItem>
items); | 276 long nativeOfflinePageDownloadBridge, List<OfflinePageDownloadItem>
items); |
277 native OfflinePageDownloadItem nativeGetItemByGuid( | 277 native OfflinePageDownloadItem nativeGetItemByGuid( |
278 long nativeOfflinePageDownloadBridge, String guid); | 278 long nativeOfflinePageDownloadBridge, String guid); |
279 native void nativeCancelDownload(long nativeOfflinePageDownloadBridge, Strin
g guid); | 279 native void nativeCancelDownload(long nativeOfflinePageDownloadBridge, Strin
g guid); |
280 native void nativePauseDownload(long nativeOfflinePageDownloadBridge, String
guid); | 280 native void nativePauseDownload(long nativeOfflinePageDownloadBridge, String
guid); |
281 native void nativeResumeDownload(long nativeOfflinePageDownloadBridge, Strin
g guid); | 281 native void nativeResumeDownload(long nativeOfflinePageDownloadBridge, Strin
g guid); |
282 native void nativeDeleteItemByGuid(long nativeOfflinePageDownloadBridge, Str
ing guid); | 282 native void nativeDeleteItemByGuid(long nativeOfflinePageDownloadBridge, Str
ing guid); |
283 native String nativeGetOfflineUrlByGuid(long nativeOfflinePageDownloadBridge
, String guid); | 283 native String nativeGetOfflineUrlByGuid(long nativeOfflinePageDownloadBridge
, String guid); |
284 native void nativeStartDownload(long nativeOfflinePageDownloadBridge, Tab ta
b); | 284 native void nativeStartDownload(long nativeOfflinePageDownloadBridge, Tab ta
b); |
285 } | 285 } |
OLD | NEW |