| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // Custom binding for <webview> contextMenus API. | 5 // Custom binding for <webview> contextMenus API. |
| 6 // Note that this file mimics custom bindings for chrome.contextMenus API | 6 // Note that this file mimics custom bindings for chrome.contextMenus API |
| 7 // which resides in context_menus_custom_bindings.js. The functions in this file | 7 // which resides in context_menus_custom_bindings.js. The functions in this file |
| 8 // have an extra instanceId parameter in the beginning, which corresponds to the | 8 // have an extra instanceId parameter in the beginning, which corresponds to the |
| 9 // id of the <webview>. | 9 // id of the <webview>. |
| 10 // | 10 // |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 webviewContextMenus.ensureListenerSetup = function() { | 49 webviewContextMenus.ensureListenerSetup = function() { |
| 50 if (webviewContextMenus.listening) { | 50 if (webviewContextMenus.listening) { |
| 51 return; | 51 return; |
| 52 } | 52 } |
| 53 webviewContextMenus.listening = true; | 53 webviewContextMenus.listening = true; |
| 54 webviewContextMenus.event.addListener(function() { | 54 webviewContextMenus.event.addListener(function() { |
| 55 // An extension context menu item has been clicked on - fire the onclick | 55 // An extension context menu item has been clicked on - fire the onclick |
| 56 // if there is one. | 56 // if there is one. |
| 57 var id = arguments[0].menuItemId; | 57 var id = arguments[0].menuItemId; |
| 58 var instanceId = arguments[0].webviewInstanceId; | 58 var instanceId = arguments[0].webviewInstanceId; |
| 59 delete arguments[0].webviewInstanceId; |
| 59 var onclick = webviewContextMenus.handlersForId(instanceId, id)[id]; | 60 var onclick = webviewContextMenus.handlersForId(instanceId, id)[id]; |
| 60 if (onclick) { | 61 if (onclick) { |
| 61 $Function.apply(onclick, null, arguments); | 62 $Function.apply(onclick, null, arguments); |
| 62 } | 63 } |
| 63 }); | 64 }); |
| 64 }; | 65 }; |
| 65 | 66 |
| 66 apiFunctions.setHandleRequest('contextMenusCreate', function() { | 67 apiFunctions.setHandleRequest('contextMenusCreate', function() { |
| 67 var args = arguments; | 68 var args = arguments; |
| 68 var id = contextMenuNatives.GetNextContextMenuId(); | 69 var id = contextMenuNatives.GetNextContextMenuId(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 return; | 121 return; |
| 121 } | 122 } |
| 122 var instanceId = request.args[0]; | 123 var instanceId = request.args[0]; |
| 123 webviewContextMenus.stringIdHandlers[instanceId] = {}; | 124 webviewContextMenus.stringIdHandlers[instanceId] = {}; |
| 124 webviewContextMenus.generatedIdHandlers[instanceId] = {}; | 125 webviewContextMenus.generatedIdHandlers[instanceId] = {}; |
| 125 }); | 126 }); |
| 126 | 127 |
| 127 }); | 128 }); |
| 128 | 129 |
| 129 exports.WebView = binding.generate(); | 130 exports.WebView = binding.generate(); |
| OLD | NEW |