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

Issue 2089933002: Context Menu Refactor (Closed)

Created:
4 years, 6 months ago by amaralp
Modified:
3 years, 9 months ago
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Context Menu Refactor Currently there are 3 different ways a context menu is generated: 1) The "Copy, Cut, Paste, ..." context menu is triggered by selection handles being shown in ContentViewCore.java. This context menu is then populated according to ContentViewCore's current state of the text (i.e. don't show "Copy" or "Cut" options if text is a password). I believe this state is mostly kept up to date through the ContentViewCore's updateImeAdapter method. 2) The "Paste" menu is triggered on long press. The long press event is converted to a right click event which triggers blink to show a context menu. Eventually this gets delegated to either "AwWebContentsViewDelegate" or "ChromeWebContentsViewDelegateAndroid." I believe this is done because WebView doesn't support Modal context menus (discussed in #3), but it is also duplicates code. 3) The Modal context menu has the same path as the Paste menu (#2) up until ChromeWebContentsViewDelegateAndroid. There ShowContextMenu checks the ContextMenuParams to see if a Modal or Paste Menu is appropriate. The goal of the CL is to make the first type of context menu be triggered in blink as a context menu. This would make it so a ContextMenuParams argument is passed during the creation meaning that creating the menu wouldn’t have to rely on state from updateImeAdapter. This also has the benefit that it unifies the first and second context menu types. My plan to accomplish this is to have long pressing or double tapping text not only select the text but also send a right click event. Then to avoid WebView and Chrome code duplication I handle the context menu in WebContentsDelegateAndroid::HandleContextMenu (to get this to work I had to add an extra parameter to this method and hence change many files). WebContentsDelegateAndroid then notifies RenderWidgetHostViewAndroid to show the menu. RenderWidgetHostViewAndroid creates a SelectActionMode object that communicates to its java counterpart when to show/hide/move/close the menu. BUG=598880, 623783

Patch Set 1 #

Patch Set 2 : removed unnecessary code #

Total comments: 27

Patch Set 3 : fixing nits #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+322 lines, -607 lines) Patch
M android_webview/native/aw_web_contents_view_delegate.cc View 1 1 chunk +0 lines, -14 lines 0 comments Download
M chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java View 1 chunk +1 line, -1 line 0 comments Download
M chrome/android/java/src/org/chromium/chrome/browser/omnibox/UrlBar.java View 2 chunks +0 lines, -8 lines 0 comments Download
M chrome/browser/chromeos/first_run/first_run_view.h View 1 1 chunk +2 lines, -1 line 0 comments Download
M chrome/browser/chromeos/first_run/first_run_view.cc View 1 1 chunk +2 lines, -2 lines 0 comments Download
M chrome/browser/chromeos/login/ui/webui_login_view.h View 1 chunk +2 lines, -1 line 0 comments Download
M chrome/browser/chromeos/login/ui/webui_login_view.cc View 1 2 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/extensions/api/tab_capture/offscreen_tab.h View 1 chunk +2 lines, -1 line 0 comments Download
M chrome/browser/extensions/api/tab_capture/offscreen_tab.cc View 1 chunk +2 lines, -1 line 0 comments Download
M chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.cc View 1 1 chunk +7 lines, -16 lines 0 comments Download
M chrome/browser/ui/panels/panel_extension_browsertest.cc View 5 chunks +10 lines, -5 lines 0 comments Download
M chrome/browser/ui/views/profiles/profile_chooser_view.h View 1 chunk +2 lines, -1 line 0 comments Download
M chrome/browser/ui/views/profiles/profile_chooser_view.cc View 1 chunk +1 line, -0 lines 0 comments Download
M components/web_contents_delegate_android/DEPS View 1 chunk +1 line, -0 lines 0 comments Download
M components/web_contents_delegate_android/web_contents_delegate_android.h View 1 chunk +2 lines, -1 line 0 comments Download
M components/web_contents_delegate_android/web_contents_delegate_android.cc View 3 chunks +26 lines, -0 lines 0 comments Download
M content/browser/android/browser_jni_registrar.cc View 2 chunks +2 lines, -0 lines 0 comments Download
M content/browser/android/content_view_core_impl.h View 2 chunks +1 line, -3 lines 0 comments Download
M content/browser/android/content_view_core_impl.cc View 2 chunks +3 lines, -22 lines 0 comments Download
M content/browser/renderer_host/render_widget_host_view_android.h View 3 chunks +4 lines, -0 lines 0 comments Download
M content/browser/renderer_host/render_widget_host_view_android.cc View 1 2 4 chunks +53 lines, -2 lines 0 comments Download
A content/browser/renderer_host/select_action_mode.h View 1 2 1 chunk +38 lines, -0 lines 0 comments Download
A content/browser/renderer_host/select_action_mode.cc View 1 2 1 chunk +84 lines, -0 lines 0 comments Download
M content/browser/site_per_process_browsertest.cc View 1 chunk +2 lines, -1 line 0 comments Download
M content/browser/web_contents/web_contents_impl.cc View 1 chunk +2 lines, -1 line 0 comments Download
M content/content_browser.gypi View 1 chunk +2 lines, -0 lines 0 comments Download
M content/content_jni.gypi View 1 chunk +1 line, -0 lines 0 comments Download
M content/public/android/BUILD.gn View 1 chunk +1 line, -0 lines 0 comments Download
M content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java View 26 chunks +6 lines, -513 lines 0 comments Download
A content/public/android/java/src/org/chromium/content/browser/input/SelectActionMode.java View 1 2 1 chunk +38 lines, -0 lines 1 comment Download
M content/public/browser/android/content_view_core.h View 1 chunk +0 lines, -1 line 0 comments Download
M content/public/browser/web_contents_delegate.h View 1 chunk +2 lines, -1 line 0 comments Download
M content/public/browser/web_contents_delegate.cc View 1 chunk +1 line, -0 lines 0 comments Download
M content/shell/browser/shell.h View 1 chunk +2 lines, -1 line 0 comments Download
M content/shell/browser/shell.cc View 1 chunk +2 lines, -1 line 0 comments Download
M extensions/browser/guest_view/app_view/app_view_guest.h View 1 chunk +2 lines, -1 line 0 comments Download
M extensions/browser/guest_view/app_view/app_view_guest.cc View 1 chunk +2 lines, -1 line 0 comments Download
M extensions/browser/guest_view/extension_options/extension_options_guest.h View 1 chunk +2 lines, -1 line 0 comments Download
M extensions/browser/guest_view/extension_options/extension_options_guest.cc View 1 chunk +1 line, -0 lines 0 comments Download
M extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h View 1 chunk +2 lines, -1 line 0 comments Download
M extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc View 1 chunk +1 line, -0 lines 0 comments Download
M extensions/browser/guest_view/web_view/web_view_guest.h View 1 chunk +2 lines, -1 line 0 comments Download
M extensions/browser/guest_view/web_view/web_view_guest.cc View 1 chunk +2 lines, -2 lines 0 comments Download
M ui/views/controls/webview/web_dialog_view.cc View 1 chunk +3 lines, -1 line 0 comments Download

Messages

Total messages: 14 (6 generated)
amaralp
On 2016/06/22 at 01:18:34, amaralp wrote: > amaralp@chromium.org changed reviewers: > + aelias@chromium.org This is ...
4 years, 6 months ago (2016-06-22 01:28:08 UTC) #4
aelias_OOO_until_Jul13
Could you summarize the scope and goal of this refactor in the patch description?
4 years, 6 months ago (2016-06-22 02:35:10 UTC) #5
amaralp
On 2016/06/22 at 02:35:10, aelias wrote: > Could you summarize the scope and goal of ...
4 years, 6 months ago (2016-06-22 19:12:38 UTC) #7
no sievers
very nice cleanup... and ContentViewCore.java -513 lines, yay! https://codereview.chromium.org/2089933002/diff/20001/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java File chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java (right): https://codereview.chromium.org/2089933002/diff/20001/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java#newcode1402 chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java:1402: contentViewCore.clearSelection(); ...
4 years, 6 months ago (2016-06-23 23:16:41 UTC) #9
amaralp
https://codereview.chromium.org/2089933002/diff/20001/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java File chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java (right): https://codereview.chromium.org/2089933002/diff/20001/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java#newcode1402 chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java:1402: contentViewCore.clearSelection(); On 2016/06/23 at 23:16:41, sievers wrote: > just ...
4 years, 6 months ago (2016-06-24 00:45:50 UTC) #10
aelias_OOO_until_Jul13
https://codereview.chromium.org/2089933002/diff/40001/content/public/android/java/src/org/chromium/content/browser/input/SelectActionMode.java File content/public/android/java/src/org/chromium/content/browser/input/SelectActionMode.java (right): https://codereview.chromium.org/2089933002/diff/40001/content/public/android/java/src/org/chromium/content/browser/input/SelectActionMode.java#newcode24 content/public/android/java/src/org/chromium/content/browser/input/SelectActionMode.java:24: private void show() { So I assume this patch ...
4 years, 6 months ago (2016-06-24 21:37:29 UTC) #11
no sievers
https://codereview.chromium.org/2089933002/diff/20001/chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.cc File chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.cc (right): https://codereview.chromium.org/2089933002/diff/20001/chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.cc#newcode34 chrome/browser/ui/android/tab_contents/chrome_web_contents_view_delegate_android.cc:34: // the same context menu code. On 2016/06/24 00:45:49, ...
4 years, 6 months ago (2016-06-24 22:17:25 UTC) #12
no sievers
4 years, 5 months ago (2016-06-28 00:33:49 UTC) #13
I've started a bug for how to configure the select action mode over here:
crbug.com/623783.

We can see which parts of that refactor help make this patch simpler (since like
you say in your description also: you have a better hook now at creation time to
configure things based on the content and can even let the embedder override
behavior there too) or what we could do as a follow up instead.
But it really seems convoluted and confusing of how this all came together over
time (see bug, took a bit to figure out what's even going on here).

Powered by Google App Engine
This is Rietveld 408576698