OLD | NEW |
(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.contextualsearch.action; |
| 6 |
| 7 import org.chromium.chrome.browser.contextualsearch.gesture.SearchGestureHost; |
| 8 |
| 9 /** |
| 10 * Represents a Search Action that will gather and examine surrounding text in o
rder to |
| 11 * "resolve" what to search for. |
| 12 * Right now this class is just being used to extract surrounding context for a
tap |
| 13 * action before issuing the resolution request to determine if we want to suppr
ess |
| 14 * the tap. Longer term it will actually do the resolution request & search requ
est. |
| 15 * This is part of the 2016-refactoring (crbug.com/624609, go/cs-refactoring-201
6). |
| 16 */ |
| 17 public class ResolvedSearchAction extends SearchAction { |
| 18 // =========================================================================
=================== |
| 19 // Constructor |
| 20 // =========================================================================
=================== |
| 21 |
| 22 /** |
| 23 * Constructs a Search Action that extracts context for a Tap, using the giv
en listener and |
| 24 * host. Current implementation is limited to gathering the text surrounding
a Tap gesture in |
| 25 * order to determine whether a search should be done or not. |
| 26 * @param listener The object to notify when the {@link SearchAction} state
changes. |
| 27 * @param host The host that provides environment data to the {@link SearchA
ction}. |
| 28 */ |
| 29 public ResolvedSearchAction(SearchActionListener listener, SearchGestureHost
host) { |
| 30 super(listener, host); |
| 31 } |
| 32 |
| 33 // =========================================================================
=================== |
| 34 // Abstract implementations |
| 35 // =========================================================================
=================== |
| 36 |
| 37 @Override |
| 38 public void extractContext() { |
| 39 requestSurroundingText(); |
| 40 } |
| 41 |
| 42 // =========================================================================
=================== |
| 43 // State handling |
| 44 // =========================================================================
=================== |
| 45 |
| 46 @Override |
| 47 protected void onSurroundingTextReady() { |
| 48 super.onSurroundingTextReady(); |
| 49 |
| 50 notifyContextReady(); |
| 51 } |
| 52 } |
OLD | NEW |