OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // This module implements experimental API for <webview>. | 5 // This module implements experimental API for <webview>. |
6 // See web_view.js for details. | 6 // See web_view.js for details. |
7 // | 7 // |
8 // <webview> Experimental API is only available on canary and dev channels of | 8 // <webview> Experimental API is only available on canary and dev channels of |
9 // Chrome. | 9 // Chrome. |
10 | 10 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 if (actionTaken) { | 104 if (actionTaken) { |
105 throw new Error(ERROR_MSG_CONTEXT_MENU_ACTION_ALREADY_TAKEN); | 105 throw new Error(ERROR_MSG_CONTEXT_MENU_ACTION_ALREADY_TAKEN); |
106 } | 106 } |
107 actionTaken = true; | 107 actionTaken = true; |
108 }; | 108 }; |
109 var menu = { | 109 var menu = { |
110 show: function(items) { | 110 show: function(items) { |
111 validateCall(); | 111 validateCall(); |
112 // TODO(lazyboy): WebViewShowContextFunction doesn't do anything useful | 112 // TODO(lazyboy): WebViewShowContextFunction doesn't do anything useful |
113 // with |items|, implement. | 113 // with |items|, implement. |
114 WebView.showContextMenu(self.instanceId, requestId, items); | 114 WebView.showContextMenu(self.guestInstanceId, requestId, items); |
115 } | 115 } |
116 }; | 116 }; |
117 webViewEvent.menu = menu; | 117 webViewEvent.menu = menu; |
118 var webviewNode = this.webviewNode; | 118 var webviewNode = this.webviewNode; |
119 var defaultPrevented = !webviewNode.dispatchEvent(webViewEvent); | 119 var defaultPrevented = !webviewNode.dispatchEvent(webViewEvent); |
120 if (actionTaken) { | 120 if (actionTaken) { |
121 return; | 121 return; |
122 } | 122 } |
123 if (!defaultPrevented) { | 123 if (!defaultPrevented) { |
124 actionTaken = true; | 124 actionTaken = true; |
125 // The default action is equivalent to just showing the context menu as is. | 125 // The default action is equivalent to just showing the context menu as is. |
126 WebView.showContextMenu(self.instanceId, requestId, undefined); | 126 WebView.showContextMenu(self.guestInstanceId, requestId, undefined); |
127 | 127 |
128 // TODO(lazyboy): Figure out a way to show warning message only when | 128 // TODO(lazyboy): Figure out a way to show warning message only when |
129 // listeners are registered for this event. | 129 // listeners are registered for this event. |
130 } // else we will ignore showing the context menu completely. | 130 } // else we will ignore showing the context menu completely. |
131 }; | 131 }; |
132 | 132 |
133 WebViewInternal.prototype.maybeGetExperimentalEvents = function() { | 133 WebViewInternal.prototype.maybeGetExperimentalEvents = function() { |
134 return {}; | 134 return {}; |
135 }; | 135 }; |
136 | 136 |
137 /** @private */ | 137 /** @private */ |
138 WebViewInternal.prototype.maybeGetExperimentalPermissions = function() { | 138 WebViewInternal.prototype.maybeGetExperimentalPermissions = function() { |
139 return []; | 139 return []; |
140 }; | 140 }; |
141 | 141 |
142 /** @private */ | 142 /** @private */ |
143 WebViewInternal.prototype.captureVisibleRegion = function(spec, callback) { | 143 WebViewInternal.prototype.captureVisibleRegion = function(spec, callback) { |
144 WebView.captureVisibleRegion(this.instanceId, spec, callback); | 144 WebView.captureVisibleRegion(this.guestInstanceId, spec, callback); |
145 }; | 145 }; |
146 | 146 |
147 WebViewInternal.maybeRegisterExperimentalAPIs = function(proto) { | 147 WebViewInternal.maybeRegisterExperimentalAPIs = function(proto) { |
148 proto.captureVisibleRegion = function(spec, callback) { | 148 proto.captureVisibleRegion = function(spec, callback) { |
149 privates(this).internal.captureVisibleRegion(spec, callback); | 149 privates(this).internal.captureVisibleRegion(spec, callback); |
150 }; | 150 }; |
151 }; | 151 }; |
152 | 152 |
153 /** @private */ | 153 /** @private */ |
154 WebViewInternal.prototype.setupExperimentalContextMenus = function() { | 154 WebViewInternal.prototype.setupExperimentalContextMenus = function() { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 188 |
189 // Expose <webview>.contextMenus object. | 189 // Expose <webview>.contextMenus object. |
190 Object.defineProperty( | 190 Object.defineProperty( |
191 this.webviewNode, | 191 this.webviewNode, |
192 'contextMenus', | 192 'contextMenus', |
193 { | 193 { |
194 get: createContextMenus(), | 194 get: createContextMenus(), |
195 enumerable: true | 195 enumerable: true |
196 }); | 196 }); |
197 }; | 197 }; |
OLD | NEW |