OLD | NEW |
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.bookmarks; | 5 package org.chromium.chrome.browser.bookmarks; |
6 | 6 |
7 import android.text.TextUtils; | 7 import android.text.TextUtils; |
8 import android.util.Pair; | 8 import android.util.Pair; |
9 | 9 |
10 import org.chromium.base.ObserverList; | 10 import org.chromium.base.ObserverList; |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 public BookmarkId getChildAt(BookmarkId folderId, int index) { | 474 public BookmarkId getChildAt(BookmarkId folderId, int index) { |
475 assert mIsNativeBookmarkModelLoaded; | 475 assert mIsNativeBookmarkModelLoaded; |
476 return nativeGetChildAt(mNativeBookmarkBridge, folderId.getId(), folderI
d.getType(), | 476 return nativeGetChildAt(mNativeBookmarkBridge, folderId.getId(), folderI
d.getType(), |
477 index); | 477 index); |
478 } | 478 } |
479 | 479 |
480 /** | 480 /** |
481 * Synchronously gets a list of bookmarks that match the specified search qu
ery. | 481 * Synchronously gets a list of bookmarks that match the specified search qu
ery. |
482 * @param query Keyword used for searching bookmarks. | 482 * @param query Keyword used for searching bookmarks. |
483 * @param maxNumberOfResult Maximum number of result to fetch. | 483 * @param maxNumberOfResult Maximum number of result to fetch. |
484 * @return List of bookmarks that are related to the given query. | 484 * @return List of bookmark IDs that are related to the given query. |
485 */ | 485 */ |
486 public List<BookmarkMatch> searchBookmarks(String query, int maxNumberOfResu
lt) { | 486 public List<BookmarkId> searchBookmarks(String query, int maxNumberOfResult)
{ |
487 List<BookmarkMatch> bookmarkMatches = new ArrayList<BookmarkMatch>(); | 487 List<BookmarkId> bookmarkMatches = new ArrayList<BookmarkId>(); |
488 nativeSearchBookmarks(mNativeBookmarkBridge, bookmarkMatches, query, | 488 nativeSearchBookmarks(mNativeBookmarkBridge, bookmarkMatches, query, |
489 maxNumberOfResult); | 489 maxNumberOfResult); |
490 return bookmarkMatches; | 490 return bookmarkMatches; |
491 } | 491 } |
492 | 492 |
493 | 493 |
494 /** | 494 /** |
495 * Set title of the given bookmark. | 495 * Set title of the given bookmark. |
496 */ | 496 */ |
497 public void setBookmarkTitle(BookmarkId id, String title) { | 497 public void setBookmarkTitle(BookmarkId id, String title) { |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 bookmarkIdList.add(new BookmarkId(id, type)); | 803 bookmarkIdList.add(new BookmarkId(id, type)); |
804 } | 804 } |
805 | 805 |
806 @CalledByNative | 806 @CalledByNative |
807 private static void addToBookmarkIdListWithDepth(List<BookmarkId> folderList
, long id, | 807 private static void addToBookmarkIdListWithDepth(List<BookmarkId> folderList
, long id, |
808 int type, List<Integer> depthList, int depth) { | 808 int type, List<Integer> depthList, int depth) { |
809 folderList.add(new BookmarkId(id, type)); | 809 folderList.add(new BookmarkId(id, type)); |
810 depthList.add(depth); | 810 depthList.add(depth); |
811 } | 811 } |
812 | 812 |
813 @CalledByNative | |
814 private static void addToBookmarkMatchList(List<BookmarkMatch> bookmarkMatch
List, | |
815 long id, int type, int[] titleMatchStartPositions, | |
816 int[] titleMatchEndPositions, int[] urlMatchStartPositions, | |
817 int[] urlMatchEndPositions) { | |
818 bookmarkMatchList.add(new BookmarkMatch(new BookmarkId(id, type), | |
819 createPairsList(titleMatchStartPositions, titleMatchEndPositions
), | |
820 createPairsList(urlMatchStartPositions, urlMatchEndPositions))); | |
821 } | |
822 | |
823 private static List<Pair<Integer, Integer>> createPairsList(int[] left, int[
] right) { | 813 private static List<Pair<Integer, Integer>> createPairsList(int[] left, int[
] right) { |
824 List<Pair<Integer, Integer>> pairList = new ArrayList<Pair<Integer, Inte
ger>>(); | 814 List<Pair<Integer, Integer>> pairList = new ArrayList<Pair<Integer, Inte
ger>>(); |
825 for (int i = 0; i < left.length; i++) { | 815 for (int i = 0; i < left.length; i++) { |
826 pairList.add(new Pair<Integer, Integer>(left[i], right[i])); | 816 pairList.add(new Pair<Integer, Integer>(left[i], right[i])); |
827 } | 817 } |
828 return pairList; | 818 return pairList; |
829 } | 819 } |
830 | 820 |
831 /** | 821 /** |
832 * Details about callbacks that need to be called once the bookmark model ha
s loaded. | 822 * Details about callbacks that need to be called once the bookmark model ha
s loaded. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 private native void nativeRemoveAllUserBookmarks(long nativeBookmarkBridge); | 894 private native void nativeRemoveAllUserBookmarks(long nativeBookmarkBridge); |
905 private native void nativeMoveBookmark(long nativeBookmarkBridge, BookmarkId
bookmarkId, | 895 private native void nativeMoveBookmark(long nativeBookmarkBridge, BookmarkId
bookmarkId, |
906 BookmarkId newParentId, int index); | 896 BookmarkId newParentId, int index); |
907 private native BookmarkId nativeAddBookmark(long nativeBookmarkBridge, Bookm
arkId parent, | 897 private native BookmarkId nativeAddBookmark(long nativeBookmarkBridge, Bookm
arkId parent, |
908 int index, String title, String url); | 898 int index, String title, String url); |
909 private native void nativeUndo(long nativeBookmarkBridge); | 899 private native void nativeUndo(long nativeBookmarkBridge); |
910 private native void nativeStartGroupingUndos(long nativeBookmarkBridge); | 900 private native void nativeStartGroupingUndos(long nativeBookmarkBridge); |
911 private native void nativeEndGroupingUndos(long nativeBookmarkBridge); | 901 private native void nativeEndGroupingUndos(long nativeBookmarkBridge); |
912 private native void nativeLoadEmptyPartnerBookmarkShimForTesting(long native
BookmarkBridge); | 902 private native void nativeLoadEmptyPartnerBookmarkShimForTesting(long native
BookmarkBridge); |
913 private native void nativeSearchBookmarks(long nativeBookmarkBridge, | 903 private native void nativeSearchBookmarks(long nativeBookmarkBridge, |
914 List<BookmarkMatch> bookmarkMatches, String query, int maxNumber); | 904 List<BookmarkId> bookmarkMatches, String query, int maxNumber); |
915 private native long nativeInit(Profile profile); | 905 private native long nativeInit(Profile profile); |
916 private native boolean nativeIsDoingExtensiveChanges(long nativeBookmarkBrid
ge); | 906 private native boolean nativeIsDoingExtensiveChanges(long nativeBookmarkBrid
ge); |
917 private native void nativeDestroy(long nativeBookmarkBridge); | 907 private native void nativeDestroy(long nativeBookmarkBridge); |
918 private static native boolean nativeIsEditBookmarksEnabled(long nativeBookma
rkBridge); | 908 private static native boolean nativeIsEditBookmarksEnabled(long nativeBookma
rkBridge); |
919 } | 909 } |
OLD | NEW |