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

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

Issue 2873953003: [Offline Pages] Adds the DeletePagesByOfflineId. (Closed)
Patch Set: Null check. Created 3 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/javatests/src/org/chromium/chrome/browser/offlinepages/OfflinePageBridgeTest.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 8c09c2a4d51bd8ba7455415f6c40af00fd05c976..11d6a27c4e09cd29f215205510604c927d293cdd 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
@@ -11,6 +11,7 @@ import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.chrome.browser.profiles.Profile;
+import org.chromium.components.offlinepages.DeletePageResult;
import org.chromium.content_public.browser.WebContents;
import java.util.ArrayList;
@@ -380,6 +381,29 @@ public class OfflinePageBridge {
nativeDeletePagesByClientId(mNativeOfflinePageBridge, namespaces, ids, callback);
}
+ /**
+ * Deletes offline pages based on the list of offline IDs. Calls the callback
+ * when operation is complete. Note that offline IDs are not intended to be saved across
+ * restarts of Chrome; they should be obtained by querying the model for the appropriate client
+ * ID.
+ *
+ * @param offlineIds A list of offline IDs of pages that will be deleted.
+ * @param callback A callback that will be called once operation is completed, called with the
+ * DeletePageResult of the operation..
+ */
+ public void deletePagesByOfflineId(List<Long> offlineIdList, Callback<Integer> callback) {
+ if (offlineIdList == null) {
+ callback.onResult(Integer.valueOf(DeletePageResult.SUCCESS));
+ return;
+ }
+
+ long[] offlineIds = new long[offlineIdList.size()];
+ for (int i = 0; i < offlineIdList.size(); i++) {
+ offlineIds[i] = offlineIdList.get(i).longValue();
+ }
+ nativeDeletePagesByOfflineId(mNativeOfflinePageBridge, offlineIds, callback);
+ }
+
/**
* Whether or not the underlying offline page model is loaded.
*/
@@ -564,6 +588,7 @@ public class OfflinePageBridge {
private native void nativeRegisterRecentTab(long nativeOfflinePageBridge, int tabId);
private native void nativeWillCloseTab(long nativeOfflinePageBridge, WebContents webContents);
private native void nativeUnregisterRecentTab(long nativeOfflinePageBridge, int tabId);
+
@VisibleForTesting
native void nativeGetRequestsInQueue(
long nativeOfflinePageBridge, Callback<SavePageRequest[]> callback);
@@ -579,6 +604,10 @@ public class OfflinePageBridge {
@VisibleForTesting
native void nativeDeletePagesByClientId(long nativeOfflinePageBridge, String[] namespaces,
String[] ids, Callback<Integer> callback);
+ @VisibleForTesting
+ native void nativeDeletePagesByOfflineId(
+ long nativeOfflinePageBridge, long[] offlineIds, Callback<Integer> callback);
+
private native void nativeSelectPageForOnlineUrl(
long nativeOfflinePageBridge, String onlineUrl, int tabId,
Callback<OfflinePageItem> callback);
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/offlinepages/OfflinePageBridgeTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698