Chromium Code Reviews| Index: content/public/android/java/src/org/chromium/content/browser/ContextSelectionProvider.java |
| diff --git a/content/public/android/java/src/org/chromium/content/browser/ContextSelectionProvider.java b/content/public/android/java/src/org/chromium/content/browser/ContextSelectionProvider.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a64a13a53d2cfeb7015180e2eee4c11339e4eafe |
| --- /dev/null |
| +++ b/content/public/android/java/src/org/chromium/content/browser/ContextSelectionProvider.java |
| @@ -0,0 +1,81 @@ |
| +// Copyright 2017 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.content.browser; |
| + |
| +import android.content.Intent; |
| +import android.graphics.drawable.Drawable; |
| +import android.view.View.OnClickListener; |
| + |
| +import org.chromium.base.annotations.SuppressFBWarnings; |
| + |
| +/** |
| + * The interface that controls contextual text selection. |
| + */ |
| + |
|
boliu
2017/03/03 18:19:09
nit: no empty line
Tima Vaisburd
2017/03/04 02:25:07
Done.
|
| +@SuppressFBWarnings("UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD") |
| +public interface ContextSelectionProvider { |
| + /** |
| + * The result of the text analysis. |
| + */ |
| + public static class Result { |
| + /** |
| + * The number of characters that the left selection bound of the original |
| + * selection should be moved. Negative number means moving left. |
|
boliu
2017/03/03 18:19:09
"Negative number means moving left." one of these
Tima Vaisburd
2017/03/03 18:59:44
M-mm, not sure how to explain it better. If leftAd
boliu
2017/03/03 19:44:00
I mean vs the comment on rightAdjust?
Tima Vaisburd
2017/03/03 20:57:48
But... rightAdjust can also be negative. For insta
boliu
2017/03/03 22:04:12
hmm, yeah, start/end might be better var names the
Tima Vaisburd
2017/03/04 02:25:07
Done.
|
| + */ |
| + public int leftAdjust; |
| + |
| + /** |
| + * The number of characters that the right selection bound of the original |
| + * selection should be moved. Negative number means moving left. |
| + */ |
| + public int rightAdjust; |
| + |
| + /** |
| + * Label for the suggested menu item. |
| + */ |
| + public CharSequence label; |
| + |
| + /** |
| + * Icon for the suggested menu item. |
| + */ |
| + public Drawable icon; |
| + |
| + /** |
| + * Intent for the suggested menu item. |
| + */ |
| + public Intent intent; |
| + |
| + /** |
| + * OnClickListener for the suggested menu item. |
| + */ |
| + public OnClickListener onClickListener; |
| + } |
| + |
| + /** |
| + * The interface that returns the result of the selected text analysis. |
| + */ |
| + public interface Callback { |
|
boliu
2017/03/03 18:19:09
nit: ResultCallback?
Tima Vaisburd
2017/03/03 18:30:29
Thank you for prompt review, I was waiting for you
boliu
2017/03/03 18:34:54
I don't know how similar those two will be, but wh
Tima Vaisburd
2017/03/04 02:25:07
Done.
|
| + /** |
| + * The result is delivered with this method. |
| + */ |
| + void onClassified(Result result); |
| + } |
| + |
| + /** |
| + * Sends asynchronous request to obtain the selection, analyze its type and suggest |
| + * better selection boundaries. |
| + */ |
| + public void sendSuggestAndClassifyRequest(); |
|
boliu
2017/03/03 18:19:09
same question as before, how does provider get the
Tima Vaisburd
2017/03/03 18:59:44
Provider will issue the IPC request to blink::WebS
boliu
2017/03/03 19:44:00
Don't do that. Just pass whatever provider needs h
Tima Vaisburd
2017/03/03 20:57:48
Yes, that also answers my question about reusing C
Tima Vaisburd
2017/03/04 02:25:07
Added the text and selection within it as argument
|
| + |
| + /** |
| + * Sends asynchronous request to obtain the selection and analyze its type. |
| + */ |
| + public void sendClassifyRequest(); |
| + |
| + /** |
| + * Cancel all asynchronous requests. |
| + */ |
| + public void cancelAllRequests(); |
| +} |