OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // Implementation of custom bindings for the contextMenus API. | 5 // Implementation of custom bindings for the contextMenus API. |
6 // This is used to implement the contextMenus API for extensions and for the | 6 // This is used to implement the contextMenus API for extensions and for the |
7 // <webview> tag (see chrome_web_view_experimental.js). | 7 // <webview> tag (see chrome_web_view_experimental.js). |
8 | 8 |
9 var contextMenuNatives = requireNative('context_menus'); | 9 var contextMenuNatives = requireNative('context_menus'); |
10 var sendRequest = require('sendRequest').sendRequest; | 10 var sendRequest = require('sendRequest').sendRequest; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 var id = info.menuItemId; | 82 var id = info.menuItemId; |
83 var onclick = contextMenus.handlersForId(instanceId, id)[id]; | 83 var onclick = contextMenus.handlersForId(instanceId, id)[id]; |
84 if (onclick) { | 84 if (onclick) { |
85 $Function.apply(onclick, null, arguments); | 85 $Function.apply(onclick, null, arguments); |
86 } | 86 } |
87 }); | 87 }); |
88 }; | 88 }; |
89 | 89 |
90 // To be used with apiFunctions.setHandleRequest | 90 // To be used with apiFunctions.setHandleRequest |
91 var requestHandlers = {}; | 91 var requestHandlers = { __proto__: null }; |
92 // To be used with apiFunctions.setCustomCallback | 92 // To be used with apiFunctions.setCustomCallback |
93 var callbacks = {}; | 93 var callbacks = { __proto__: null }; |
94 | 94 |
95 requestHandlers.create = function() { | 95 requestHandlers.create = function() { |
96 var createProperties = isWebview ? arguments[1] : arguments[0]; | 96 var createProperties = isWebview ? arguments[1] : arguments[0]; |
97 createProperties.generatedId = contextMenuNatives.GetNextContextMenuId(); | 97 createProperties.generatedId = contextMenuNatives.GetNextContextMenuId(); |
98 var optArgs = { | 98 var optArgs = { |
| 99 __proto__: null, |
99 customCallback: this.customCallback, | 100 customCallback: this.customCallback, |
100 }; | 101 }; |
101 sendRequest(this.name, arguments, this.definition.parameters, optArgs); | 102 sendRequest(this.name, arguments, this.definition.parameters, optArgs); |
102 return contextMenus.getIdFromCreateProperties(createProperties); | 103 return contextMenus.getIdFromCreateProperties(createProperties); |
103 }; | 104 }; |
104 | 105 |
105 callbacks.create = | 106 callbacks.create = |
106 createCustomCallback(function(instanceId, createProperties) { | 107 createCustomCallback(function(instanceId, createProperties) { |
107 var id = contextMenus.getIdFromCreateProperties(createProperties); | 108 var id = contextMenus.getIdFromCreateProperties(createProperties); |
108 var onclick = createProperties.onclick; | 109 var onclick = createProperties.onclick; |
(...skipping 23 matching lines...) Expand all Loading... |
132 delete contextMenus.handlers[instanceId]; | 133 delete contextMenus.handlers[instanceId]; |
133 }); | 134 }); |
134 | 135 |
135 return { | 136 return { |
136 requestHandlers: requestHandlers, | 137 requestHandlers: requestHandlers, |
137 callbacks: callbacks | 138 callbacks: callbacks |
138 }; | 139 }; |
139 } | 140 } |
140 | 141 |
141 exports.$set('create', createContextMenusHandlers); | 142 exports.$set('create', createContextMenusHandlers); |
OLD | NEW |