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 android.text.TextUtils; | |
8 | |
9 import org.chromium.chrome.browser.contextualsearch.gesture.SearchGestureHost; | |
10 | |
11 /** | |
12 * Represents a Search Action that will gather and examine surrounding text in o rder to | |
13 * "resolve" what to search for. | |
14 */ | |
15 public class ResolvedSearchAction extends SearchAction { | |
Theresa
2016/08/16 15:41:49
Right now this class is just being used to extract
Donn Denman
2016/08/17 04:35:22
Correct. Added your nice description to the heade
| |
16 // ========================================================================= =================== | |
17 // Constructor | |
18 // ========================================================================= =================== | |
19 | |
20 public ResolvedSearchAction(SearchActionListener listener) { | |
21 super(listener); | |
22 } | |
23 | |
24 // ========================================================================= =================== | |
25 // Abstract implementations | |
26 // ========================================================================= =================== | |
27 | |
28 @Override | |
29 public void extractContext(SearchGestureHost host) { | |
30 updateState(host); | |
pedro (no code reviews)
2016/08/22 20:54:17
Why is updateState() being exposed? I think it sho
Donn Denman
2016/08/23 23:21:46
Something needs to set the host, and I wondered wh
| |
31 requestSurroundingText(); | |
32 } | |
33 | |
34 // ========================================================================= =================== | |
35 // State handling | |
36 // ========================================================================= =================== | |
37 | |
38 @Override | |
39 protected void onSurroundingTextResponse(String surroundingTextSample, int s ampleStart, | |
40 int focusStart, int focusEnd, int focusedWordStart, int focusedWordE nd) { | |
41 super.onSurroundingTextResponse(surroundingTextSample, sampleStart, focu sStart, focusEnd, | |
42 focusedWordStart, focusedWordEnd); | |
43 | |
44 String focusedWord = getFocusedWord(); | |
45 if (!TextUtils.isEmpty(focusedWord) && focusStart == focusEnd) { | |
46 notifyContextReady(); | |
47 } else { | |
48 dismissAction(); | |
49 } | |
50 } | |
51 } | |
OLD | NEW |