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

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

Issue 1270693004: Add bookmark search feature to enhanced bookmark (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser; 5 package org.chromium.chrome.browser;
6 6
7 import android.util.Pair;
8
7 import org.chromium.base.ObserverList; 9 import org.chromium.base.ObserverList;
8 import org.chromium.base.VisibleForTesting; 10 import org.chromium.base.VisibleForTesting;
9 import org.chromium.base.annotations.CalledByNative; 11 import org.chromium.base.annotations.CalledByNative;
12 import org.chromium.chrome.browser.enhancedbookmarks.BookmarkMatch;
10 import org.chromium.chrome.browser.profiles.Profile; 13 import org.chromium.chrome.browser.profiles.Profile;
11 import org.chromium.components.bookmarks.BookmarkId; 14 import org.chromium.components.bookmarks.BookmarkId;
12 import org.chromium.components.bookmarks.BookmarkType; 15 import org.chromium.components.bookmarks.BookmarkType;
13 16
14 import java.util.ArrayList; 17 import java.util.ArrayList;
15 import java.util.List; 18 import java.util.List;
16 19
17 /** 20 /**
18 * Provides the communication channel for Android to fetch and manipulate the 21 * Provides the communication channel for Android to fetch and manipulate the
19 * bookmark model stored in native. 22 * bookmark model stored in native.
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 * not included. 374 * not included.
372 */ 375 */
373 public List<BookmarkId> getAllBookmarkIDsOrderedByCreationDate() { 376 public List<BookmarkId> getAllBookmarkIDsOrderedByCreationDate() {
374 assert mIsNativeBookmarkModelLoaded; 377 assert mIsNativeBookmarkModelLoaded;
375 List<BookmarkId> result = new ArrayList<BookmarkId>(); 378 List<BookmarkId> result = new ArrayList<BookmarkId>();
376 nativeGetAllBookmarkIDsOrderedByCreationDate(mNativeBookmarksBridge, res ult); 379 nativeGetAllBookmarkIDsOrderedByCreationDate(mNativeBookmarksBridge, res ult);
377 return result; 380 return result;
378 } 381 }
379 382
380 /** 383 /**
384 * Synchronously gets a list of bookmarks that match the specified search qu ery.
385 * @param query Keyword used for searching bookmarks.
386 * @param maxNumberOfResult Maximum number of result to fetch.
387 * @return List of bookmarks that are related to the given query.
388 */
Kibeom Kim (inactive) 2015/08/10 09:02:47 Q: wasn't this an async API before?
Ian Wen 2015/08/12 00:09:26 This particular API has always been async. It uses
389 public List<BookmarkMatch> searchBookmarks(String query, int maxNumberOfResu lt) {
390 List<BookmarkMatch> bookmarkMatches = new ArrayList<BookmarkMatch>();
391 nativeSearchBookmarks(mNativeBookmarksBridge, bookmarkMatches, query,
392 maxNumberOfResult);
393 return bookmarkMatches;
394 }
395
396
397 /**
381 * Set title of the given bookmark. 398 * Set title of the given bookmark.
382 */ 399 */
383 public void setBookmarkTitle(BookmarkId id, String title) { 400 public void setBookmarkTitle(BookmarkId id, String title) {
384 assert mIsNativeBookmarkModelLoaded; 401 assert mIsNativeBookmarkModelLoaded;
385 nativeSetBookmarkTitle(mNativeBookmarksBridge, id.getId(), id.getType(), title); 402 nativeSetBookmarkTitle(mNativeBookmarksBridge, id.getId(), id.getType(), title);
386 } 403 }
387 404
388 /** 405 /**
389 * Set URL of the given bookmark. 406 * Set URL of the given bookmark.
390 */ 407 */
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 bookmarkIdList.add(new BookmarkId(id, type)); 676 bookmarkIdList.add(new BookmarkId(id, type));
660 } 677 }
661 678
662 @CalledByNative 679 @CalledByNative
663 private static void addToBookmarkIdListWithDepth(List<BookmarkId> folderList , long id, 680 private static void addToBookmarkIdListWithDepth(List<BookmarkId> folderList , long id,
664 int type, List<Integer> depthList, int depth) { 681 int type, List<Integer> depthList, int depth) {
665 folderList.add(new BookmarkId(id, type)); 682 folderList.add(new BookmarkId(id, type));
666 depthList.add(depth); 683 depthList.add(depth);
667 } 684 }
668 685
686 @CalledByNative
687 private static void addToBookmarkMatchList(List<BookmarkMatch> bookmarkMatch List,
688 long id, int type, int[] titleMatchStartPositions,
689 int[] titleMatchEndPositions, int[] urlMatchStartPositions,
690 int[] urlMatchEndPositions) {
691 bookmarkMatchList.add(new BookmarkMatch(new BookmarkId(id, type),
692 createPairsList(titleMatchStartPositions, titleMatchEndPositions ),
693 createPairsList(urlMatchStartPositions, urlMatchEndPositions)));
694 }
695
696 private static List<Pair<Integer, Integer>> createPairsList(int[] left, int[ ] right) {
697 List<Pair<Integer, Integer>> pairList = new ArrayList<Pair<Integer, Inte ger>>();
698 for (int i = 0; i < left.length; i++) {
699 pairList.add(new Pair<Integer, Integer>(left[i], right[i]));
700 }
701 return pairList;
702 }
703
704
669 private native BookmarkItem nativeGetBookmarkByID(long nativeBookmarksBridge , long id, 705 private native BookmarkItem nativeGetBookmarkByID(long nativeBookmarksBridge , long id,
670 int type); 706 int type);
671 private native void nativeGetPermanentNodeIDs(long nativeBookmarksBridge, 707 private native void nativeGetPermanentNodeIDs(long nativeBookmarksBridge,
672 List<BookmarkId> bookmarksList); 708 List<BookmarkId> bookmarksList);
673 private native void nativeGetTopLevelFolderParentIDs(long nativeBookmarksBri dge, 709 private native void nativeGetTopLevelFolderParentIDs(long nativeBookmarksBri dge,
674 List<BookmarkId> bookmarksList); 710 List<BookmarkId> bookmarksList);
675 private native void nativeGetTopLevelFolderIDs(long nativeBookmarksBridge, b oolean getSpecial, 711 private native void nativeGetTopLevelFolderIDs(long nativeBookmarksBridge, b oolean getSpecial,
676 boolean getNormal, List<BookmarkId> bookmarksList); 712 boolean getNormal, List<BookmarkId> bookmarksList);
677 private native void nativeGetAllFoldersWithDepths(long nativeBookmarksBridge , 713 private native void nativeGetAllFoldersWithDepths(long nativeBookmarksBridge ,
678 List<BookmarkId> folderList, List<Integer> depthList); 714 List<BookmarkId> folderList, List<Integer> depthList);
(...skipping 24 matching lines...) Expand all
703 private native void nativeDeleteBookmark(long nativeBookmarksBridge, Bookmar kId bookmarkId); 739 private native void nativeDeleteBookmark(long nativeBookmarksBridge, Bookmar kId bookmarkId);
704 private native void nativeMoveBookmark(long nativeBookmarksBridge, BookmarkI d bookmarkId, 740 private native void nativeMoveBookmark(long nativeBookmarksBridge, BookmarkI d bookmarkId,
705 BookmarkId newParentId, int index); 741 BookmarkId newParentId, int index);
706 private native BookmarkId nativeAddBookmark(long nativeBookmarksBridge, Book markId parent, 742 private native BookmarkId nativeAddBookmark(long nativeBookmarksBridge, Book markId parent,
707 int index, String title, String url); 743 int index, String title, String url);
708 private native void nativeUndo(long nativeBookmarksBridge); 744 private native void nativeUndo(long nativeBookmarksBridge);
709 private native void nativeStartGroupingUndos(long nativeBookmarksBridge); 745 private native void nativeStartGroupingUndos(long nativeBookmarksBridge);
710 private native void nativeEndGroupingUndos(long nativeBookmarksBridge); 746 private native void nativeEndGroupingUndos(long nativeBookmarksBridge);
711 private static native boolean nativeIsEnhancedBookmarksFeatureEnabled(Profil e profile); 747 private static native boolean nativeIsEnhancedBookmarksFeatureEnabled(Profil e profile);
712 private native void nativeLoadEmptyPartnerBookmarkShimForTesting(long native BookmarksBridge); 748 private native void nativeLoadEmptyPartnerBookmarkShimForTesting(long native BookmarksBridge);
713 749 private native void nativeSearchBookmarks(long nativeBookmarksBridge,
750 List<BookmarkMatch> bookmarkMatches, String query, int maxNumber);
714 private native long nativeInit(Profile profile); 751 private native long nativeInit(Profile profile);
715 private native boolean nativeIsDoingExtensiveChanges(long nativeBookmarksBri dge); 752 private native boolean nativeIsDoingExtensiveChanges(long nativeBookmarksBri dge);
716 private native void nativeDestroy(long nativeBookmarksBridge); 753 private native void nativeDestroy(long nativeBookmarksBridge);
717 private static native boolean nativeIsEditBookmarksEnabled(long nativeBookma rksBridge); 754 private static native boolean nativeIsEditBookmarksEnabled(long nativeBookma rksBridge);
718 755
719 /** 756 /**
720 * Simple object representing the bookmark item. 757 * Simple object representing the bookmark item.
721 */ 758 */
722 public static class BookmarkItem { 759 public static class BookmarkItem {
723 760
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 case GET_CURRENT_FOLDER_HIERARCHY: 845 case GET_CURRENT_FOLDER_HIERARCHY:
809 mHandler.getCurrentFolderHierarchy(mFolderId, mCallback); 846 mHandler.getCurrentFolderHierarchy(mFolderId, mCallback);
810 break; 847 break;
811 default: 848 default:
812 assert false; 849 assert false;
813 break; 850 break;
814 } 851 }
815 } 852 }
816 } 853 }
817 } 854 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698