Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3554)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageBridge.java

Issue 1969233002: [OfflinePages] Make website settings popup rely on asynchronous API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolving code review comments and running git cl format Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/pageinfo/WebsiteSettingsPopup.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageBridge.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageBridge.java
index e15e901b282ecccb34cdc1daedcf31757850d780..9701c3c4f5738da26440f4d50794b33048cca4a4 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageBridge.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageBridge.java
@@ -24,6 +24,8 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import javax.annotation.Nullable;
+
/**
* Access gate to C++ side offline pages functionalities.
*/
@@ -98,6 +100,16 @@ public class OfflinePageBridge {
}
/**
+ * Callback that delivers information about one offline page entry.
+ *
+ * The returned item will be null if no items are found.
+ */
+ public interface SingleOfflinePageItemCallback {
+ @CalledByNative("SingleOfflinePageItemCallback")
+ void onResult(@Nullable OfflinePageItem item);
+ }
+
+ /**
* Callback used when determining whether we have any offline pages.
*/
public interface HasPagesCallback {
@@ -336,44 +348,14 @@ public class OfflinePageBridge {
}
/**
- * Gets the offline pages associated with the provided offline URL.
- *
- * @param string URL pointing to the offline copy of the web page.
- * @return An {@link OfflinePageItem} matching the offline URL or
- * <code>null</code> if not found.
- * found.
- */
- @VisibleForTesting
- public void getPagesByOfflineUrl(
- final String offlineUrl, final MultipleOfflinePageItemCallback callback) {
- runWhenLoaded(new Runnable() {
- @Override
- public void run() {
- List<OfflinePageItem> result = new ArrayList<>();
-
- // TODO(http://crbug.com/589526) This native API returns only one item, but in the
- // future will return a list.
- OfflinePageItem item =
- nativeGetPageByOfflineUrl(mNativeOfflinePageBridge, offlineUrl);
- if (item != null) {
- result.add(item);
- }
-
- callback.onResult(result);
- }
- });
- }
-
- /**
- * Gets an offline page associated with a provided offline URL.
- * This method is deprecated. Use OfflinePageBridge#getPagesByOnlineUrl.
+ * Get the offline page associated with the provided offline URL.
*
* @param string URL pointing to the offline copy of the web page.
- * @return An {@link OfflinePageItem} matching the offline URL or
- * <code>null</code> if not found.
+ * @param SingleOfflinePageItemCallback callback to pass back the
+ * matching {@link OfflinePageItem} if found. Will pass back <code>null</code> if not.
*/
- public OfflinePageItem getPageByOfflineUrl(String offlineUrl) {
- return nativeGetPageByOfflineUrl(mNativeOfflinePageBridge, offlineUrl);
+ public void getPageByOfflineUrl(String offlineUrl, SingleOfflinePageItemCallback callback) {
+ nativeGetPageByOfflineUrl(mNativeOfflinePageBridge, offlineUrl, callback);
}
/**
@@ -628,8 +610,8 @@ public class OfflinePageBridge {
native OfflinePageItem nativeGetPageByOfflineId(long nativeOfflinePageBridge, long offlineId);
private native OfflinePageItem nativeGetBestPageForOnlineURL(
long nativeOfflinePageBridge, String onlineURL);
- private native OfflinePageItem nativeGetPageByOfflineUrl(
- long nativeOfflinePageBridge, String offlineUrl);
+ private native void nativeGetPageByOfflineUrl(long nativeOfflinePageBridge, String offlineUrl,
+ SingleOfflinePageItemCallback callback);
private native void nativeSavePage(long nativeOfflinePageBridge, SavePageCallback callback,
WebContents webContents, String clientNamespace, String clientId);
private native void nativeSavePageLater(
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/pageinfo/WebsiteSettingsPopup.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698