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

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

Issue 2542203002: [Android History] Add Android history manager UI and bridge (Closed)
Patch Set: Rebase, drop changes to time.* Created 4 years 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 unified diff | Download patch
OLDNEW
(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. */
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 nativeQueryHistory(mNativeHistoryBridge, new ArrayList<HistoryItem>(), q uery, endQueryTime);
43 }
44
45 @CalledByNative
46 public static void createHistoryItemAndAddToList(
47 List<HistoryItem> items, String url, String domain, String title, lo ng timestamp) {
48 items.add(new HistoryItem(url, domain, title, timestamp));
49 }
50
51 @CalledByNative
52 public void onQueryHistoryComplete(List<HistoryItem> items) {
53 mCallback.onResult(items);
54 }
55
56 private native long nativeInit(Profile profile);
57 private native void nativeDestroy(long nativeBrowsingHistoryBridge);
58 private native void nativeQueryHistory(long nativeBrowsingHistoryBridge,
59 List<HistoryItem> historyItems, String query, long queryEndTime);
60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698