Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/action/ResolvedSearchAction.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/action/ResolvedSearchAction.java b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/action/ResolvedSearchAction.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dea1eb876f46a5ef82558cc1c1354d96156d721a |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/action/ResolvedSearchAction.java |
| @@ -0,0 +1,51 @@ |
| +// Copyright 2016 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.chrome.browser.contextualsearch.action; |
| + |
| +import android.text.TextUtils; |
| + |
| +import org.chromium.chrome.browser.contextualsearch.gesture.SearchGestureHost; |
| + |
| +/** |
| + * Represents a Search Action that will gather and examine surrounding text in order to |
| + * "resolve" what to search for. |
| + */ |
| +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
|
| + // ============================================================================================ |
| + // Constructor |
| + // ============================================================================================ |
| + |
| + public ResolvedSearchAction(SearchActionListener listener) { |
| + super(listener); |
| + } |
| + |
| + // ============================================================================================ |
| + // Abstract implementations |
| + // ============================================================================================ |
| + |
| + @Override |
| + public void extractContext(SearchGestureHost host) { |
| + 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
|
| + requestSurroundingText(); |
| + } |
| + |
| + // ============================================================================================ |
| + // State handling |
| + // ============================================================================================ |
| + |
| + @Override |
| + protected void onSurroundingTextResponse(String surroundingTextSample, int sampleStart, |
| + int focusStart, int focusEnd, int focusedWordStart, int focusedWordEnd) { |
| + super.onSurroundingTextResponse(surroundingTextSample, sampleStart, focusStart, focusEnd, |
| + focusedWordStart, focusedWordEnd); |
| + |
| + String focusedWord = getFocusedWord(); |
| + if (!TextUtils.isEmpty(focusedWord) && focusStart == focusEnd) { |
| + notifyContextReady(); |
| + } else { |
| + dismissAction(); |
| + } |
| + } |
| +} |