| 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 org.chromium.base.Callback; | 7 import org.chromium.base.Callback; |
| 8 import org.chromium.base.ObserverList; | 8 import org.chromium.base.ObserverList; |
| 9 import org.chromium.base.ThreadUtils; | 9 import org.chromium.base.ThreadUtils; |
| 10 import org.chromium.base.VisibleForTesting; | 10 import org.chromium.base.VisibleForTesting; |
| 11 import org.chromium.base.annotations.CalledByNative; | 11 import org.chromium.base.annotations.CalledByNative; |
| 12 import org.chromium.base.annotations.JNINamespace; | 12 import org.chromium.base.annotations.JNINamespace; |
| 13 import org.chromium.chrome.browser.profiles.Profile; | 13 import org.chromium.chrome.browser.profiles.Profile; |
| 14 import org.chromium.content_public.browser.WebContents; | 14 import org.chromium.content_public.browser.WebContents; |
| 15 | 15 |
| 16 import java.util.ArrayList; | 16 import java.util.ArrayList; |
| 17 import java.util.Collections; | 17 import java.util.Collections; |
| 18 import java.util.HashSet; | 18 import java.util.HashSet; |
| 19 import java.util.List; | 19 import java.util.List; |
| 20 import java.util.Set; | 20 import java.util.Set; |
| 21 | 21 |
| 22 /** | 22 /** |
| 23 * Access gate to C++ side offline pages functionalities. | 23 * Access gate to C++ side offline pages functionalities. |
| 24 */ | 24 */ |
| 25 @JNINamespace("offline_pages::android") | 25 @JNINamespace("offline_pages::android") |
| 26 public class OfflinePageBridge { | 26 public class OfflinePageBridge { |
| 27 public static final String ASYNC_NAMESPACE = "async_loading"; |
| 27 public static final String BOOKMARK_NAMESPACE = "bookmark"; | 28 public static final String BOOKMARK_NAMESPACE = "bookmark"; |
| 28 public static final String SHARE_NAMESPACE = "share"; | 29 public static final String SHARE_NAMESPACE = "share"; |
| 29 | 30 |
| 30 /** | 31 /** |
| 31 * Retrieves the OfflinePageBridge for the given profile, creating it the fi
rst time | 32 * Retrieves the OfflinePageBridge for the given profile, creating it the fi
rst time |
| 32 * getForProfile is called for a given profile. Must be called on the UI th
read. | 33 * getForProfile is called for a given profile. Must be called on the UI th
read. |
| 33 * | 34 * |
| 34 * @param profile The profile associated with the OfflinePageBridge to get. | 35 * @param profile The profile associated with the OfflinePageBridge to get. |
| 35 */ | 36 */ |
| 36 public static OfflinePageBridge getForProfile(Profile profile) { | 37 public static OfflinePageBridge getForProfile(Profile profile) { |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 } | 392 } |
| 392 | 393 |
| 393 /** | 394 /** |
| 394 * @return True if an offline preview is being shown. | 395 * @return True if an offline preview is being shown. |
| 395 * @param webContents Contents of the page to check. | 396 * @param webContents Contents of the page to check. |
| 396 */ | 397 */ |
| 397 public boolean isShowingOfflinePreview(WebContents webContents) { | 398 public boolean isShowingOfflinePreview(WebContents webContents) { |
| 398 return nativeIsShowingOfflinePreview(mNativeOfflinePageBridge, webConten
ts); | 399 return nativeIsShowingOfflinePreview(mNativeOfflinePageBridge, webConten
ts); |
| 399 } | 400 } |
| 400 | 401 |
| 402 /** |
| 403 * @return True if download button is being shown in the error page. |
| 404 * @param webContents Contents of the page to check. |
| 405 */ |
| 406 public boolean isShowingDownloadButtonInErrorPage(WebContents webContents) { |
| 407 return nativeIsShowingDownloadButtonInErrorPage(mNativeOfflinePageBridge
, webContents); |
| 408 } |
| 409 |
| 401 private static class CheckPagesExistOfflineCallbackInternal { | 410 private static class CheckPagesExistOfflineCallbackInternal { |
| 402 private Callback<Set<String>> mCallback; | 411 private Callback<Set<String>> mCallback; |
| 403 | 412 |
| 404 CheckPagesExistOfflineCallbackInternal(Callback<Set<String>> callback) { | 413 CheckPagesExistOfflineCallbackInternal(Callback<Set<String>> callback) { |
| 405 mCallback = callback; | 414 mCallback = callback; |
| 406 } | 415 } |
| 407 | 416 |
| 408 @CalledByNative("CheckPagesExistOfflineCallbackInternal") | 417 @CalledByNative("CheckPagesExistOfflineCallbackInternal") |
| 409 public void onResult(String[] results) { | 418 public void onResult(String[] results) { |
| 410 Set<String> resultSet = new HashSet<>(); | 419 Set<String> resultSet = new HashSet<>(); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 long nativeOfflinePageBridge, String onlineUrl, int tabId, | 527 long nativeOfflinePageBridge, String onlineUrl, int tabId, |
| 519 Callback<OfflinePageItem> callback); | 528 Callback<OfflinePageItem> callback); |
| 520 private native void nativeSavePage(long nativeOfflinePageBridge, SavePageCal
lback callback, | 529 private native void nativeSavePage(long nativeOfflinePageBridge, SavePageCal
lback callback, |
| 521 WebContents webContents, String clientNamespace, String clientId); | 530 WebContents webContents, String clientNamespace, String clientId); |
| 522 private native void nativeSavePageLater(long nativeOfflinePageBridge, String
url, | 531 private native void nativeSavePageLater(long nativeOfflinePageBridge, String
url, |
| 523 String clientNamespace, String clientId, boolean userRequested); | 532 String clientNamespace, String clientId, boolean userRequested); |
| 524 private native String nativeGetOfflinePageHeaderForReload( | 533 private native String nativeGetOfflinePageHeaderForReload( |
| 525 long nativeOfflinePageBridge, WebContents webContents); | 534 long nativeOfflinePageBridge, WebContents webContents); |
| 526 private native boolean nativeIsShowingOfflinePreview( | 535 private native boolean nativeIsShowingOfflinePreview( |
| 527 long nativeOfflinePageBridge, WebContents webContents); | 536 long nativeOfflinePageBridge, WebContents webContents); |
| 537 private native boolean nativeIsShowingDownloadButtonInErrorPage( |
| 538 long nativeOfflinePageBridge, WebContents webContents); |
| 528 } | 539 } |
| OLD | NEW |