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

Issue 1026383003: <webview>: make context menus cancellable using JS API (Closed)

Created:
5 years, 9 months ago by lazyboy
Modified:
5 years, 9 months ago
Reviewers:
Fady Samuel, Yoyo Zhou
CC:
chromium-reviews, chromium-apps-reviews_chromium.org, extensions-reviews_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

<webview>: make context menus cancellable using JS API. Expose <webview>.contextMenus.onShow chrome EventTarget like object so one can "addListener" that can preventDefault() to cancel bringing up <webview> context menu. BUG=465733 Test=Open a chrome app with <webview>. E.g. Load a <webview> in a chrome app, e.g. the browser sample app: https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/webview-samples/browser Right click on the <webview>, context menu is expected to be shown. Now open the app's inspector: from chrome://inspect, switch to "Apps" then select to inspect "Browser sample". Register a listener to disable context menu: document.querySelector('webview').contextMenus.onShow.addListener(function(e) { e.preventDefault(); }); Right click on the <webview> again, context menu should not show up. Committed: https://crrev.com/514286582142e26e93a09f5aeefb538259ad1f41 Cr-Commit-Position: refs/heads/master@{#322477}

Patch Set 1 #

Patch Set 2 : Cleaned up. #

Patch Set 3 : remove unused require #

Total comments: 3

Patch Set 4 : Object -> $Object #

Patch Set 5 : rename onContextMenu -> onShow, rename other internal constant values #

Patch Set 6 : add todo for documentation #

Total comments: 2

Patch Set 7 : address comments from yoz@ #

Total comments: 2

Patch Set 8 : address comments from yoz@ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+189 lines, -72 lines) Patch
M chrome/browser/apps/guest_view/web_view_browsertest.cc View 1 4 chunks +75 lines, -9 lines 0 comments Download
M chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M chrome/common/extensions/api/chrome_web_view_internal.json View 1 2 3 4 5 6 7 1 chunk +19 lines, -0 lines 0 comments Download
M chrome/renderer/resources/extensions/web_view/chrome_web_view.js View 1 2 3 4 5 6 chunks +60 lines, -59 lines 0 comments Download
M chrome/test/data/extensions/platform_apps/web_view/context_menus/basic/embedder.js View 1 2 3 4 3 chunks +32 lines, -1 line 0 comments Download
M extensions/browser/guest_view/web_view/web_view_constants.h View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M extensions/browser/guest_view/web_view/web_view_constants.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 18 (4 generated)
lazyboy
There's another easier route we can go though, <webview>.addEventListener('some-name-for-onContextMenu', function(e) { e.preventDefault(); }); Problem with ...
5 years, 9 months ago (2015-03-25 23:49:34 UTC) #2
Fady Samuel
This seems pretty reasonable to me. I have no objections. If you're comfortable with it, ...
5 years, 9 months ago (2015-03-26 02:40:28 UTC) #3
lazyboy
1) My worry is if this somehow precludes us from using this event/function in the ...
5 years, 9 months ago (2015-03-26 04:16:26 UTC) #4
Fady Samuel
On 2015/03/26 04:16:26, lazyboy wrote: > 1) My worry is if this somehow precludes us ...
5 years, 9 months ago (2015-03-26 17:44:05 UTC) #5
lazyboy
Comments addressed in patchset #5 https://chromiumcodereview.appspot.com/1026383003/diff/40001/chrome/renderer/resources/extensions/web_view/chrome_web_view.js File chrome/renderer/resources/extensions/web_view/chrome_web_view.js (right): https://chromiumcodereview.appspot.com/1026383003/diff/40001/chrome/renderer/resources/extensions/web_view/chrome_web_view.js#newcode160 chrome/renderer/resources/extensions/web_view/chrome_web_view.js:160: Object.defineProperty( On 2015/03/26 04:16:26, ...
5 years, 9 months ago (2015-03-26 19:18:02 UTC) #6
Fady Samuel
lgtm
5 years, 9 months ago (2015-03-26 19:21:11 UTC) #7
lazyboy
+Yoyo for OWNERS review: chrome/common/extensions/api/chrome_web_view_internal.json
5 years, 9 months ago (2015-03-26 19:36:52 UTC) #9
Yoyo Zhou
https://codereview.chromium.org/1026383003/diff/90001/chrome/common/extensions/api/chrome_web_view_internal.json File chrome/common/extensions/api/chrome_web_view_internal.json (right): https://codereview.chromium.org/1026383003/diff/90001/chrome/common/extensions/api/chrome_web_view_internal.json#newcode295 chrome/common/extensions/api/chrome_web_view_internal.json:295: "description": "Event fired when context menu is about to ...
5 years, 9 months ago (2015-03-26 19:50:44 UTC) #10
lazyboy
https://codereview.chromium.org/1026383003/diff/90001/chrome/common/extensions/api/chrome_web_view_internal.json File chrome/common/extensions/api/chrome_web_view_internal.json (right): https://codereview.chromium.org/1026383003/diff/90001/chrome/common/extensions/api/chrome_web_view_internal.json#newcode295 chrome/common/extensions/api/chrome_web_view_internal.json:295: "description": "Event fired when context menu is about to ...
5 years, 9 months ago (2015-03-26 20:13:07 UTC) #11
Yoyo Zhou
LGTM https://codereview.chromium.org/1026383003/diff/110001/chrome/common/extensions/api/chrome_web_view_internal.json File chrome/common/extensions/api/chrome_web_view_internal.json (right): https://codereview.chromium.org/1026383003/diff/110001/chrome/common/extensions/api/chrome_web_view_internal.json#newcode295 chrome/common/extensions/api/chrome_web_view_internal.json:295: "description": "Fired when context menu is about to ...
5 years, 9 months ago (2015-03-26 20:19:47 UTC) #12
lazyboy
https://codereview.chromium.org/1026383003/diff/110001/chrome/common/extensions/api/chrome_web_view_internal.json File chrome/common/extensions/api/chrome_web_view_internal.json (right): https://codereview.chromium.org/1026383003/diff/110001/chrome/common/extensions/api/chrome_web_view_internal.json#newcode295 chrome/common/extensions/api/chrome_web_view_internal.json:295: "description": "Fired when context menu is about to be ...
5 years, 9 months ago (2015-03-26 20:32:21 UTC) #13
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1026383003/130001
5 years, 9 months ago (2015-03-26 21:41:51 UTC) #16
commit-bot: I haz the power
Committed patchset #8 (id:130001)
5 years, 9 months ago (2015-03-26 21:45:28 UTC) #17
commit-bot: I haz the power
5 years, 9 months ago (2015-03-26 21:46:23 UTC) #18
Message was sent while issue was closed.
Patchset 8 (id:??) landed as
https://crrev.com/514286582142e26e93a09f5aeefb538259ad1f41
Cr-Commit-Position: refs/heads/master@{#322477}

Powered by Google App Engine
This is Rietveld 408576698