OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 WebView (<webview>) as a custom element that wraps a | 5 // This module implements WebView (<webview>) as a custom element that wraps a |
6 // BrowserPlugin object element. The object element is hidden within | 6 // BrowserPlugin object element. The object element is hidden within |
7 // the shadow DOM of the WebView element. | 7 // the shadow DOM of the WebView element. |
8 | 8 |
9 var DocumentNatives = requireNative('document_natives'); | 9 var DocumentNatives = requireNative('document_natives'); |
10 var GuestView = require('guestView').GuestView; | 10 var GuestView = require('guestView').GuestView; |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 WebViewImpl.prototype.__proto__ = GuestViewContainer.prototype; | 26 WebViewImpl.prototype.__proto__ = GuestViewContainer.prototype; |
27 | 27 |
28 WebViewImpl.VIEW_TYPE = 'WebView'; | 28 WebViewImpl.VIEW_TYPE = 'WebView'; |
29 | 29 |
30 // Add extra functionality to |this.element|. | 30 // Add extra functionality to |this.element|. |
31 WebViewImpl.setupElement = function(proto) { | 31 WebViewImpl.setupElement = function(proto) { |
32 // Public-facing API methods. | 32 // Public-facing API methods. |
33 var apiMethods = WebViewImpl.getApiMethods(); | 33 var apiMethods = WebViewImpl.getApiMethods(); |
34 | 34 |
35 // Add the experimental API methods, if available. | |
36 var experimentalApiMethods = | |
37 WebViewImpl.maybeGetExperimentalApiMethods(); | |
38 apiMethods = $Array.concat(apiMethods, experimentalApiMethods); | |
39 | |
40 // Create default implementations for undefined API methods. | 35 // Create default implementations for undefined API methods. |
41 var createDefaultApiMethod = function(m) { | 36 var createDefaultApiMethod = function(m) { |
42 return function(var_args) { | 37 return function(var_args) { |
43 if (!this.guest.getId()) { | 38 if (!this.guest.getId()) { |
44 return false; | 39 return false; |
45 } | 40 } |
46 var args = $Array.concat([this.guest.getId()], $Array.slice(arguments)); | 41 var args = $Array.concat([this.guest.getId()], $Array.slice(arguments)); |
47 $Function.apply(WebViewInternal[m], null, args); | 42 $Function.apply(WebViewInternal[m], null, args); |
48 return true; | 43 return true; |
49 }; | 44 }; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 webviewSrc = this.baseUrlForDataUrl; | 210 webviewSrc = this.baseUrlForDataUrl; |
216 } | 211 } |
217 | 212 |
218 args = $Array.concat([this.guest.getId(), webviewSrc], | 213 args = $Array.concat([this.guest.getId(), webviewSrc], |
219 $Array.slice(args)); | 214 $Array.slice(args)); |
220 $Function.apply(func, null, args); | 215 $Function.apply(func, null, args); |
221 return true; | 216 return true; |
222 } | 217 } |
223 | 218 |
224 // Implemented when the ChromeWebView API is available. | 219 // Implemented when the ChromeWebView API is available. |
225 WebViewImpl.prototype.maybeGetChromeWebViewEvents = function() {}; | 220 WebViewImpl.prototype.maybeSetupContextMenus = function() {}; |
226 | |
227 // Implemented when the experimental WebView API is available. | |
228 WebViewImpl.maybeGetExperimentalApiMethods = function() { return []; }; | |
229 WebViewImpl.prototype.setupExperimentalContextMenus = function() {}; | |
230 | 221 |
231 GuestViewContainer.registerElement(WebViewImpl); | 222 GuestViewContainer.registerElement(WebViewImpl); |
232 | 223 |
233 // Exports. | 224 // Exports. |
234 exports.WebViewImpl = WebViewImpl; | 225 exports.WebViewImpl = WebViewImpl; |
OLD | NEW |