Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(538)

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/ContextSelectionClient.java

Issue 2785853002: Selection Action mode triggered like a context menu (Closed)
Patch Set: Fixing rebase bug Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.support.annotation.IntDef; 7 import android.support.annotation.IntDef;
8 import android.text.TextUtils; 8 import android.text.TextUtils;
9 9
10 import org.chromium.base.annotations.CalledByNative; 10 import org.chromium.base.annotations.CalledByNative;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 mProvider.cancelAllRequests(); 72 mProvider.cancelAllRequests();
73 } 73 }
74 74
75 // SelectionClient implementation 75 // SelectionClient implementation
76 @Override 76 @Override
77 public void onSelectionChanged(String selection) {} 77 public void onSelectionChanged(String selection) {}
78 78
79 @Override 79 @Override
80 public void onSelectionEvent(int eventType, float posXPix, float posYPix) { 80 public void onSelectionEvent(int eventType, float posXPix, float posYPix) {
81 switch (eventType) { 81 switch (eventType) {
82 case SelectionEventType.SELECTION_HANDLES_SHOWN:
83 // This event is sent when the long press is detected which caus es
84 // selection to appear for the first time. Temporarily hiding th e
85 // handles that happens e.g. during scroll does not affect this event.
86 requestSurroundingText(SUGGEST_AND_CLASSIFY);
87 break;
88
89 case SelectionEventType.SELECTION_HANDLES_CLEARED: 82 case SelectionEventType.SELECTION_HANDLES_CLEARED:
90 // The ActionMode should be stopped when this event comes. 83 // The ActionMode should be stopped when this event comes.
91 cancelAllRequests(); 84 cancelAllRequests();
92 break; 85 break;
93 86
94 case SelectionEventType.SELECTION_HANDLE_DRAG_STOPPED:
95 // This event is sent after a user stopped dragging one of the
96 // selection handles, i.e. stopped modifying the selection.
97 requestSurroundingText(CLASSIFY);
98 break;
99
100 default: 87 default:
101 break; // ignore 88 break; // ignore
102 } 89 }
103 } 90 }
104 91
105 @Override 92 @Override
106 public void showUnhandledTapUIIfNeeded(int x, int y) {} 93 public void showUnhandledTapUIIfNeeded(int x, int y) {}
107 94
108 @Override 95 @Override
109 public boolean sendsSelectionPopupUpdates() { 96 public boolean sendsSelectionPopupUpdates(boolean shouldSuggest) {
97 requestSurroundingText(shouldSuggest ? SUGGEST_AND_CLASSIFY : CLASSIFY);
boliu 2017/04/21 21:20:18 this method right now is "does this client send se
110 return true; 98 return true;
111 } 99 }
112 100
113 private void cancelAllRequests() { 101 private void cancelAllRequests() {
114 if (mNativeContextSelectionClient != 0) { 102 if (mNativeContextSelectionClient != 0) {
115 nativeCancelAllRequests(mNativeContextSelectionClient); 103 nativeCancelAllRequests(mNativeContextSelectionClient);
116 } 104 }
117 105
118 mProvider.cancelAllRequests(); 106 mProvider.cancelAllRequests();
119 } 107 }
(...skipping 28 matching lines...) Expand all
148 assert false : "Unexpected callback data"; 136 assert false : "Unexpected callback data";
149 break; 137 break;
150 } 138 }
151 } 139 }
152 140
153 private native long nativeInit(WebContents webContents); 141 private native long nativeInit(WebContents webContents);
154 private native void nativeRequestSurroundingText( 142 private native void nativeRequestSurroundingText(
155 long nativeContextSelectionClient, int numExtraCharacters, int callb ackData); 143 long nativeContextSelectionClient, int numExtraCharacters, int callb ackData);
156 private native void nativeCancelAllRequests(long nativeContextSelectionClien t); 144 private native void nativeCancelAllRequests(long nativeContextSelectionClien t);
157 } 145 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698