Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package org.chromium.chrome.browser.history; | |
| 6 | |
| 7 import org.chromium.base.Callback; | |
| 8 import org.chromium.base.annotations.CalledByNative; | |
| 9 import org.chromium.chrome.browser.profiles.Profile; | |
| 10 | |
| 11 import java.util.ArrayList; | |
| 12 import java.util.List; | |
| 13 | |
| 14 /** The JNI bridge for Android to fetch and manipulate browsing history. **/ | |
|
gone
2016/12/02 19:34:37
Single asterisk to close
Theresa
2016/12/02 20:49:32
Done.
| |
| 15 public class BrowsingHistoryBridge { | |
| 16 | |
| 17 private long mNativeHistoryBridge; | |
| 18 private Callback<List<HistoryItem>> mCallback; | |
| 19 | |
| 20 public BrowsingHistoryBridge() { | |
| 21 mNativeHistoryBridge = nativeInit(Profile.getLastUsedProfile()); | |
| 22 } | |
| 23 | |
| 24 public void destroy() { | |
| 25 if (mNativeHistoryBridge != 0) { | |
| 26 nativeDestroy(mNativeHistoryBridge); | |
| 27 mNativeHistoryBridge = 0; | |
| 28 } | |
| 29 } | |
| 30 | |
| 31 /** | |
| 32 * Query browsing history. Only one query may be in-flight at any time. See | |
| 33 * BrowsingHistoryService::QueryHistory. | |
| 34 * @param callback The callback that will receive query results. | |
| 35 * @param query The query search text. May be empty. | |
| 36 * @param endQueryTime The end of the time range to search. A value of 0 ind icates that there | |
| 37 * is no limit on the end time. See the native QueryOpti ons. | |
| 38 */ | |
| 39 public void queryHistory(Callback<List<HistoryItem>> callback, String query, | |
| 40 long endQueryTime) { | |
| 41 mCallback = callback; | |
| 42 List<HistoryItem> historyItems = new ArrayList<>(); | |
|
gone
2016/12/02 19:34:37
Is this needed just to make the call? Doesn't see
Theresa
2016/12/02 20:49:32
This is the list that gets passed back to the call
| |
| 43 nativeQueryHistory(mNativeHistoryBridge, historyItems, query, endQueryTi me); | |
| 44 } | |
| 45 | |
| 46 @CalledByNative | |
| 47 public static void createHistoryItemAndAddToList( | |
| 48 List<HistoryItem> items, String url, String domain, String title, lo ng timestamp) { | |
| 49 items.add(new HistoryItem(url, domain, title, timestamp)); | |
| 50 } | |
| 51 | |
| 52 @CalledByNative | |
| 53 public void onQueryHistoryComplete(List<HistoryItem> items) { | |
| 54 mCallback.onResult(items); | |
| 55 } | |
| 56 | |
| 57 private native long nativeInit(Profile profile); | |
| 58 private native void nativeDestroy(long nativeBrowsingHistoryBridge); | |
| 59 private native void nativeQueryHistory(long nativeBrowsingHistoryBridge, | |
| 60 List<HistoryItem> historyItems, String query, long queryEndTime); | |
| 61 } | |
| OLD | NEW |