Commit 58c94e45 authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

Android: Remove text selection APIs from WebContents

Handles the TODO's in the class spotted while working on
other refactoring. The public APIs are not necessary.

Change-Id: Ia4d07e5f3eab828125bb8146d7f46e2a9bbe9d31
Reviewed-on: https://chromium-review.googlesource.com/979734Reviewed-by: default avatarBo <boliu@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarPedro Amaral <amaralp@chromium.org>
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546055}
parent 635bc2d2
......@@ -40,6 +40,7 @@ import org.chromium.blink_public.web.WebInputEventType;
import org.chromium.blink_public.web.WebTextInputMode;
import org.chromium.content.browser.WindowEventObserver;
import org.chromium.content.browser.picker.InputDialogContainer;
import org.chromium.content.browser.webcontents.WebContentsImpl;
import org.chromium.content.browser.webcontents.WebContentsUserData;
import org.chromium.content.browser.webcontents.WebContentsUserData.UserDataFactory;
import org.chromium.content_public.browser.ImeAdapter;
......@@ -99,7 +100,7 @@ public class ImeAdapterImpl implements ImeAdapter, WindowEventObserver {
// ResultReceiver in the InputMethodService (IME app) gets gc'ed.
private ShowKeyboardResultReceiver mShowKeyboardResultReceiver;
private final WebContents mWebContents;
private final WebContentsImpl mWebContents;
private View mContainerView;
// This holds the information necessary for constructing CursorAnchorInfo, and notifies to
......@@ -207,7 +208,7 @@ public class ImeAdapterImpl implements ImeAdapter, WindowEventObserver {
* @param webContents WebContents instance.
*/
public ImeAdapterImpl(WebContents webContents) {
mWebContents = webContents;
mWebContents = (WebContentsImpl) webContents;
}
/**
......
......@@ -42,7 +42,7 @@ public class SelectPopup implements HideablePopup {
public void hide(boolean sendsCancelMessage);
}
private final WebContents mWebContents;
private final WebContentsImpl mWebContents;
private Context mContext;
private View mContainerView;
private Ui mPopupView;
......
......@@ -305,37 +305,51 @@ public class WebContentsImpl implements WebContents, RenderFrameHostDelegate {
nativeStop(mNativeWebContentsAndroid);
}
@Override
/**
* Cut the selected content.
*/
public void cut() {
nativeCut(mNativeWebContentsAndroid);
}
@Override
/**
* Copy the selected content.
*/
public void copy() {
nativeCopy(mNativeWebContentsAndroid);
}
@Override
/**
* Paste content from the clipboard.
*/
public void paste() {
nativePaste(mNativeWebContentsAndroid);
}
@Override
/**
* Paste content from the clipboard without format.
*/
public void pasteAsPlainText() {
nativePasteAsPlainText(mNativeWebContentsAndroid);
}
@Override
/**
* Replace the selected text with the {@code word}.
*/
public void replace(String word) {
nativeReplace(mNativeWebContentsAndroid, word);
}
@Override
/**
* Select all content.
*/
public void selectAll() {
nativeSelectAll(mNativeWebContentsAndroid);
}
@Override
/**
* Collapse the selection to the end of selection range.
*/
public void collapseSelection() {
// collapseSelection may get triggered when certain selection-related widgets
// are destroyed. As the timing for such destruction is unpredictable,
......@@ -634,12 +648,16 @@ public class WebContentsImpl implements WebContents, RenderFrameHostDelegate {
callback.onFinishDownloadImage(id, httpStatusCode, imageUrl, bitmaps, sizes);
}
@Override
/**
* Removes handles used in text selection.
*/
public void dismissTextHandles() {
nativeDismissTextHandles(mNativeWebContentsAndroid);
}
@Override
/**
* Shows paste popup menu at the touch handle at specified location.
*/
public void showContextMenuAtTouchHandle(int x, int y) {
nativeShowContextMenuAtTouchHandle(mNativeWebContentsAndroid, x, y);
}
......
......@@ -123,48 +123,6 @@ public interface WebContents extends Parcelable {
*/
void stop();
// TODO (amaralp): Only used in content. Should be moved out of public interface.
/**
* Cut the selected content.
*/
void cut();
// TODO (amaralp): Only used in content. Should be moved out of public interface.
/**
* Copy the selected content.
*/
void copy();
// TODO (amaralp): Only used in content. Should be moved out of public interface.
/**
* Paste content from the clipboard.
*/
void paste();
// TODO (amaralp): Only used in content. Should be moved out of public interface.
/**
* Paste content from the clipboard without format.
*/
void pasteAsPlainText();
// TODO (amaralp): Only used in content. Should be moved out of public interface.
/**
* Replace the selected text with the {@code word}.
*/
void replace(String word);
// TODO (amaralp): Only used in content. Should be moved out of public interface.
/**
* Select all content.
*/
void selectAll();
// TODO (amaralp): Only used in content. Should be moved out of public interface.
/**
* Collapse the selection to the end of selection range.
*/
void collapseSelection();
/**
* To be called when the ContentView is hidden.
*/
......@@ -181,18 +139,6 @@ public interface WebContents extends Parcelable {
*/
void setImportance(@ChildProcessImportance int importance);
// TODO (amaralp): Only used in content. Should be moved out of public interface.
/**
* Removes handles used in text selection.
*/
void dismissTextHandles();
// TODO (amaralp): Only used in content. Should be moved out of public interface.
/**
* Shows paste popup menu at the touch handle at specified location.
*/
void showContextMenuAtTouchHandle(int x, int y);
/**
* Suspends all media players for this WebContents. Note: There may still
* be activities generating audio, so setAudioMuted() should also be called
......
......@@ -23,7 +23,7 @@ import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.UrlUtils;
import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper;
import org.chromium.content_public.browser.WebContents;
import org.chromium.content.browser.webcontents.WebContentsImpl;
import org.chromium.content_shell_apk.ContentShellActivityTestRule;
import org.chromium.content_shell_apk.ContentShellActivityTestRule.RerunWithUpdatedContainerView;
......@@ -78,7 +78,8 @@ public class ClipboardTest {
clipboardManager.setPrimaryClip(ClipData.newPlainText(null, ""));
Assert.assertFalse(hasPrimaryClip(clipboardManager));
final WebContents webContents = mActivityTestRule.getContentViewCore().getWebContents();
final WebContentsImpl webContents =
(WebContentsImpl) mActivityTestRule.getContentViewCore().getWebContents();
selectAll(webContents);
copy(webContents);
......@@ -106,7 +107,7 @@ public class ClipboardTest {
});
}
private void copy(final WebContents webContents) {
private void copy(final WebContentsImpl webContents) {
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
......@@ -115,7 +116,7 @@ public class ClipboardTest {
});
}
private void selectAll(final WebContents webContents) {
private void selectAll(final WebContentsImpl webContents) {
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
......
......@@ -29,9 +29,9 @@ import org.chromium.content.browser.test.util.JavaScriptUtils;
import org.chromium.content.browser.test.util.TestCallbackHelperContainer;
import org.chromium.content.browser.test.util.TestInputMethodManagerWrapper;
import org.chromium.content.browser.test.util.TestInputMethodManagerWrapper.InputConnectionProvider;
import org.chromium.content.browser.webcontents.WebContentsImpl;
import org.chromium.content_public.browser.ContentViewCore;
import org.chromium.content_public.browser.ImeAdapter;
import org.chromium.content_public.browser.WebContents;
import org.chromium.content_shell_apk.ContentShellActivityTestRule;
import org.chromium.ui.base.ime.TextInputType;
......@@ -343,7 +343,7 @@ class ImeActivityTestRule extends ContentShellActivityTestRule {
// After calling this method, we should call assertClipboardContents() to wait for the clipboard
// to get updated. See cubug.com/621046
void copy() {
final WebContents webContents = getWebContents();
final WebContentsImpl webContents = (WebContentsImpl) getWebContents();
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
......@@ -353,7 +353,7 @@ class ImeActivityTestRule extends ContentShellActivityTestRule {
}
void cut() {
final WebContents webContents = getWebContents();
final WebContentsImpl webContents = (WebContentsImpl) getWebContents();
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
......@@ -375,7 +375,7 @@ class ImeActivityTestRule extends ContentShellActivityTestRule {
}
void paste() {
final WebContents webContents = getWebContents();
final WebContentsImpl webContents = (WebContentsImpl) getWebContents();
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
......@@ -385,7 +385,7 @@ class ImeActivityTestRule extends ContentShellActivityTestRule {
}
void selectAll() {
final WebContents webContents = getWebContents();
final WebContentsImpl webContents = (WebContentsImpl) getWebContents();
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
......@@ -395,7 +395,7 @@ class ImeActivityTestRule extends ContentShellActivityTestRule {
}
void collapseSelection() {
final WebContents webContents = getWebContents();
final WebContentsImpl webContents = (WebContentsImpl) getWebContents();
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
......
......@@ -91,27 +91,6 @@ public class MockWebContents implements WebContents {
@Override
public void stop() {}
@Override
public void cut() {}
@Override
public void copy() {}
@Override
public void paste() {}
@Override
public void pasteAsPlainText() {}
@Override
public void replace(String word) {}
@Override
public void selectAll() {}
@Override
public void collapseSelection() {}
@Override
public void onHide() {}
......@@ -121,12 +100,6 @@ public class MockWebContents implements WebContents {
@Override
public void setImportance(int importance) {}
@Override
public void dismissTextHandles() {}
@Override
public void showContextMenuAtTouchHandle(int x, int y) {}
@Override
public void suspendAllMediaPlayers() {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment