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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/SelectionPopupController.java

Issue 2721813002: Make SelectionPopupController.ShowPastePopup only be triggered by Blink (Closed)
Patch Set: Rebased for Bo Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/java/src/org/chromium/content/browser/SelectionPopupController.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/SelectionPopupController.java b/content/public/android/java/src/org/chromium/content/browser/SelectionPopupController.java
index 9471abf0c9d7d40125ddd096fca0449df7121518..6185019a20a809bc3ebd74f2cecdf663ff1c57e7 100644
--- a/content/public/android/java/src/org/chromium/content/browser/SelectionPopupController.java
+++ b/content/public/android/java/src/org/chromium/content/browser/SelectionPopupController.java
@@ -223,23 +223,43 @@ public class SelectionPopupController extends ActionModeCallbackHelper {
return actionMode;
}
- void showPastePopup(int x, int y) {
+ void createAndShowPastePopup(int x, int y) {
if (mView.getParent() == null || mView.getVisibility() != View.VISIBLE) {
return;
}
if (!supportsFloatingActionMode() && !canPaste()) return;
+ PastePopupMenuDelegate delegate = new PastePopupMenuDelegate() {
boliu 2017/03/17 22:54:20 does it matter if mPastePopupMenu already exists h
amaralp 2017/03/21 00:26:24 Addressed in crrev.com/2757313003.
+ @Override
+ public void paste() {
+ mWebContents.paste();
+ mWebContents.dismissTextHandles();
+ }
- PastePopupMenu pastePopupMenu = getPastePopup();
- if (pastePopupMenu == null) return;
+ @Override
+ public boolean canPaste() {
+ return SelectionPopupController.this.canPaste();
+ }
+ };
+ Context windowContext = mWindowAndroid.getContext().get();
+ if (windowContext == null) return;
+ if (supportsFloatingActionMode()) {
+ mPastePopupMenu = new FloatingPastePopupMenu(windowContext, mView, delegate);
+ } else {
+ mPastePopupMenu = new LegacyPastePopupMenu(windowContext, mView, delegate);
+ }
+ showPastePopup(x, y);
+ }
+ private void showPastePopup(int x, int y) {
+ if (mPastePopupMenu == null) return;
// Coordinates are in DIP.
final float deviceScale = mRenderCoordinates.getDeviceScaleFactor();
final int xPix = (int) (x * deviceScale);
final int yPix = (int) (y * deviceScale);
final float browserControlsShownPix = mRenderCoordinates.getContentOffsetYPix();
try {
- pastePopupMenu.show(xPix, (int) (yPix + browserControlsShownPix));
+ mPastePopupMenu.show(xPix, (int) (yPix + browserControlsShownPix));
} catch (WindowManager.BadTokenException e) {
}
}
@@ -253,31 +273,6 @@ public class SelectionPopupController extends ActionModeCallbackHelper {
if (mPastePopupMenu != null) mPastePopupMenu.hide();
}
- private PastePopupMenu getPastePopup() {
- if (mPastePopupMenu == null) {
- PastePopupMenuDelegate delegate = new PastePopupMenuDelegate() {
- @Override
- public void paste() {
- mWebContents.paste();
- mWebContents.dismissTextHandles();
- }
-
- @Override
- public boolean canPaste() {
- return SelectionPopupController.this.canPaste();
- }
- };
- Context windowContext = mWindowAndroid.getContext().get();
- if (windowContext == null) return null;
- if (supportsFloatingActionMode()) {
- mPastePopupMenu = new FloatingPastePopupMenu(windowContext, mView, delegate);
- } else {
- mPastePopupMenu = new LegacyPastePopupMenu(windowContext, mView, delegate);
- }
- }
- return mPastePopupMenu;
- }
-
void destroyPastePopup() {
hidePastePopup();
mPastePopupMenu = null;
@@ -798,7 +793,7 @@ public class SelectionPopupController extends ActionModeCallbackHelper {
case SelectionEventType.INSERTION_HANDLE_MOVED:
mSelectionRect.set(left, top, right, bottom);
if (!isScrollInProgress && isPastePopupShowing()) {
- mWebContents.showContextMenuAtPoint(xAnchor, yAnchor);
+ showPastePopup(xAnchor, yAnchor);
} else {
hidePastePopup();
}
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698