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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/history/BrowsingHistoryBridge.java

Issue 2603403003: [Android History] Add tests for removing items (Closed)
Patch Set: Changes from dfalcantara@ review Created 3 years, 11 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/history/HistoryActivity.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/history/BrowsingHistoryBridge.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/history/BrowsingHistoryBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/history/BrowsingHistoryBridge.java
index c9f0e1dc4627f0099d18e916bba704cdef378d61..e2cd12474bd6c29a6e92644635867f526ef0ec40 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/history/BrowsingHistoryBridge.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/history/BrowsingHistoryBridge.java
@@ -11,50 +11,22 @@ import java.util.ArrayList;
import java.util.List;
/** The JNI bridge for Android to fetch and manipulate browsing history. */
-public class BrowsingHistoryBridge {
-
- /**
- * Observer to be notified of browsing history events.
- */
- public interface BrowsingHistoryObserver {
- /**
- * Called after {@link BrowsingHistoryBridge#queryHistory(String, long)} is complete.
- * @param items The items that matched the #queryHistory() parameters.
- * @param hasMorePotentialMatches Whether there are more items that match the query text.
- * This will be false once the entire local history database
- * has been searched.
- */
- public void onQueryHistoryComplete(List<HistoryItem> items,
- boolean hasMorePotentialMatches);
-
- /**
- * Called when history has been deleted through something other than a call to
- * BrowsingHistoryBridge#removeItems(). For example, if two instances of the history page
- * are open and the user removes items in one instance, the other instance will be notified
- * via this method.
- */
- public void onHistoryDeleted();
-
- /**
- * Called after querying history to indicate whether other forms of browsing history were
- * found.
- * @param hasOtherForms Whether other forms of browsing history were found.
- * @param hasSyncedResults Whether synced results were found.
- */
- public void hasOtherFormsOfBrowsingData(boolean hasOtherForms, boolean hasSyncedResults);
- }
-
- private final BrowsingHistoryObserver mObserver;
-
+public class BrowsingHistoryBridge implements HistoryProvider {
+ private BrowsingHistoryObserver mObserver;
private long mNativeHistoryBridge;
private boolean mRemovingItems;
private boolean mHasPendingRemoveRequest;
- public BrowsingHistoryBridge(BrowsingHistoryObserver observer) {
+ public BrowsingHistoryBridge() {
mNativeHistoryBridge = nativeInit(Profile.getLastUsedProfile());
+ }
+
+ @Override
+ public void setObserver(BrowsingHistoryObserver observer) {
mObserver = observer;
}
+ @Override
public void destroy() {
if (mNativeHistoryBridge != 0) {
nativeDestroy(mNativeHistoryBridge);
@@ -62,29 +34,17 @@ public class BrowsingHistoryBridge {
}
}
- /**
- * Query browsing history. Only one query may be in-flight at any time. See
- * BrowsingHistoryService::QueryHistory.
- * @param query The query search text. May be empty.
- * @param endQueryTime The end of the time range to search. A value of 0 indicates that there
- * is no limit on the end time. See the native QueryOptions.
- */
+ @Override
public void queryHistory(String query, long endQueryTime) {
nativeQueryHistory(mNativeHistoryBridge, new ArrayList<HistoryItem>(), query, endQueryTime);
}
- /**
- * Adds the HistoryItem to the list of items being removed. The removal will not be committed
- * until {@link #removeItems()} is called.
- * @param item The item to mark for removal.
- */
+ @Override
public void markItemForRemoval(HistoryItem item) {
nativeMarkItemForRemoval(mNativeHistoryBridge, item.getUrl(), item.getTimestamps());
}
- /**
- * Removes all items that have been marked for removal through #markItemForRemoval().
- */
+ @Override
public void removeItems() {
// Only one remove request may be in-flight at any given time. If items are currently being
// removed, queue the new request and return early.
@@ -105,7 +65,7 @@ public class BrowsingHistoryBridge {
@CalledByNative
public void onQueryHistoryComplete(List<HistoryItem> items, boolean hasMorePotentialMatches) {
- mObserver.onQueryHistoryComplete(items, hasMorePotentialMatches);
+ if (mObserver != null) mObserver.onQueryHistoryComplete(items, hasMorePotentialMatches);
}
@CalledByNative
@@ -123,12 +83,14 @@ public class BrowsingHistoryBridge {
@CalledByNative
public void onHistoryDeleted() {
- mObserver.onHistoryDeleted();
+ if (mObserver != null) mObserver.onHistoryDeleted();
}
@CalledByNative
public void hasOtherFormsOfBrowsingData(boolean hasOtherForms, boolean hasSyncedResults) {
- mObserver.hasOtherFormsOfBrowsingData(hasOtherForms, hasSyncedResults);
+ if (mObserver != null) {
+ mObserver.hasOtherFormsOfBrowsingData(hasOtherForms, hasSyncedResults);
+ }
}
private native long nativeInit(Profile profile);
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/history/HistoryActivity.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698