diff options
author | twellington <twellington@chromium.org> | 2014-12-10 15:18:07 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-10 23:18:35 +0000 |
commit | cecf6e14ec375cb66e2816d67a574270dbc7705b (patch) | |
tree | 21af3cafa069f250527a388551360787e30a6c93 /components/bookmarks/common | |
parent | 1437062436f052c2ec5fb27437af07e1cf0717c5 (diff) | |
download | chromium_src-cecf6e14ec375cb66e2816d67a574270dbc7705b.zip chromium_src-cecf6e14ec375cb66e2816d67a574270dbc7705b.tar.gz chromium_src-cecf6e14ec375cb66e2816d67a574270dbc7705b.tar.bz2 |
Refactor BookmarksBridge#searchBookmarks to return a list of BookmarkMatches
BUG=433986
Review URL: https://codereview.chromium.org/787163002
Cr-Commit-Position: refs/heads/master@{#307785}
Diffstat (limited to 'components/bookmarks/common')
-rw-r--r-- | components/bookmarks/common/android/java/src/org/chromium/components/bookmarks/BookmarkMatch.java | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/components/bookmarks/common/android/java/src/org/chromium/components/bookmarks/BookmarkMatch.java b/components/bookmarks/common/android/java/src/org/chromium/components/bookmarks/BookmarkMatch.java new file mode 100644 index 0000000..8477091 --- /dev/null +++ b/components/bookmarks/common/android/java/src/org/chromium/components/bookmarks/BookmarkMatch.java @@ -0,0 +1,64 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.components.bookmarks; + +import android.util.Pair; + +import org.chromium.base.CalledByNative; + +import java.util.List; + +/** + * Object that associates a BookmarkId with search term matches found in the bookmark's title and + * url. + */ +public class BookmarkMatch { + + private final BookmarkId mBookmarkId; + private final List<Pair<Integer, Integer>> mTitleMatchPositions; + private final List<Pair<Integer, Integer>> mUrlMatchPositions; + + /** + * @param bookmarkId The BookmarkId fassociated with this match. + * @param titleMatchPositions A list of [begin, end) positions for matches in the title; + * may be null. + * @param urlMatchPositions A list of [begin, end) positions for matches in the url; + * may be null. + */ + public BookmarkMatch(BookmarkId bookmarkId, List<Pair<Integer, Integer>> titleMatchPositions, + List<Pair<Integer, Integer>> urlMatchPositions) { + mBookmarkId = bookmarkId; + mTitleMatchPositions = titleMatchPositions; + mUrlMatchPositions = urlMatchPositions; + } + + /** + * @return The BookmarkId associated with this match. + */ + public BookmarkId getBookmarkId() { + return mBookmarkId; + } + + /** + * @return A list of [begin, end) positions for matches in the title; may return null. + */ + public List<Pair<Integer, Integer>> getTitleMatchPositions() { + return mTitleMatchPositions; + } + + /** + * @return A list of [begin, end) positions for matches in the url; may return null. + */ + public List<Pair<Integer, Integer>> getUrlMatchPositions() { + return mUrlMatchPositions; + } + + @CalledByNative + private static BookmarkMatch createBookmarkMatch(BookmarkId bookmarkId, + List<Pair<Integer, Integer>> titleMatchPositions, + List<Pair<Integer, Integer>> urlMatchPositions) { + return new BookmarkMatch(bookmarkId, titleMatchPositions, urlMatchPositions); + } +} |