| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 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.bookmarks; | |
| 6 | |
| 7 import android.content.Context; | |
| 8 import android.util.AttributeSet; | |
| 9 | |
| 10 import org.chromium.chrome.browser.bookmarks.BookmarkBridge.BookmarkItem; | |
| 11 import org.chromium.components.bookmarks.BookmarkId; | |
| 12 | |
| 13 /** | |
| 14 * A view representing each row shown in {@link BookmarkSearchRow}. Note this ty
pe of row is | |
| 15 * not selectable for now. | |
| 16 */ | |
| 17 public class BookmarkSearchRow extends BookmarkItemRow { | |
| 18 | |
| 19 /** | |
| 20 * A listener that is triggered when a search result is selected. | |
| 21 */ | |
| 22 interface SearchHistoryDelegate { | |
| 23 /** | |
| 24 * Save the current search term to search history. This is called when a
search result has | |
| 25 * been clicked. | |
| 26 */ | |
| 27 public void saveSearchHistory(); | |
| 28 } | |
| 29 | |
| 30 private SearchHistoryDelegate mHistoryDelegate; | |
| 31 | |
| 32 /** | |
| 33 * Constructor for xml inflation. | |
| 34 */ | |
| 35 public BookmarkSearchRow(Context context, AttributeSet attrs) { | |
| 36 super(context, attrs); | |
| 37 } | |
| 38 | |
| 39 @Override | |
| 40 protected void onFinishInflate() { | |
| 41 super.onFinishInflate(); | |
| 42 } | |
| 43 | |
| 44 @Override | |
| 45 BookmarkItem setBookmarkId(BookmarkId bookmarkId) { | |
| 46 BookmarkItem item = super.setBookmarkId(bookmarkId); | |
| 47 return item; | |
| 48 } | |
| 49 | |
| 50 @Override | |
| 51 protected boolean isSelectable() { | |
| 52 return false; | |
| 53 } | |
| 54 | |
| 55 @Override | |
| 56 public void onClick() { | |
| 57 mDelegate.openBookmark(mBookmarkId, BookmarkLaunchLocation.SEARCH); | |
| 58 mHistoryDelegate.saveSearchHistory(); | |
| 59 } | |
| 60 | |
| 61 /** | |
| 62 * Sets the delegate that handles saving search history. | |
| 63 */ | |
| 64 void setSearchHistoryDelegate(SearchHistoryDelegate delegate) { | |
| 65 mHistoryDelegate = delegate; | |
| 66 } | |
| 67 } | |
| OLD | NEW |