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 13 matching lines...) Expand all Loading... |
24 | 24 |
25 WebViewImpl.prototype.__proto__ = GuestViewContainer.prototype; | 25 WebViewImpl.prototype.__proto__ = GuestViewContainer.prototype; |
26 | 26 |
27 WebViewImpl.VIEW_TYPE = 'WebView'; | 27 WebViewImpl.VIEW_TYPE = 'WebView'; |
28 | 28 |
29 // Add extra functionality to |this.element|. | 29 // Add extra functionality to |this.element|. |
30 WebViewImpl.setupElement = function(proto) { | 30 WebViewImpl.setupElement = function(proto) { |
31 // Public-facing API methods. | 31 // Public-facing API methods. |
32 var apiMethods = WebViewImpl.getApiMethods(); | 32 var apiMethods = WebViewImpl.getApiMethods(); |
33 | 33 |
| 34 // Add the experimental API methods, if available. |
| 35 var experimentalApiMethods = |
| 36 WebViewImpl.maybeGetExperimentalApiMethods(); |
| 37 apiMethods = $Array.concat(apiMethods, experimentalApiMethods); |
| 38 |
34 // Create default implementations for undefined API methods. | 39 // Create default implementations for undefined API methods. |
35 var createDefaultApiMethod = function(m) { | 40 var createDefaultApiMethod = function(m) { |
36 return function(var_args) { | 41 return function(var_args) { |
37 if (!this.guest.getId()) { | 42 if (!this.guest.getId()) { |
38 return false; | 43 return false; |
39 } | 44 } |
40 var args = $Array.concat([this.guest.getId()], $Array.slice(arguments)); | 45 var args = $Array.concat([this.guest.getId()], $Array.slice(arguments)); |
41 $Function.apply(WebViewInternal[m], null, args); | 46 $Function.apply(WebViewInternal[m], null, args); |
42 return true; | 47 return true; |
43 }; | 48 }; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 // Requests the <webview> element wihtin the embedder to enter fullscreen. | 218 // Requests the <webview> element wihtin the embedder to enter fullscreen. |
214 WebViewImpl.prototype.makeElementFullscreen = function() { | 219 WebViewImpl.prototype.makeElementFullscreen = function() { |
215 GuestViewInternalNatives.RunWithGesture(function() { | 220 GuestViewInternalNatives.RunWithGesture(function() { |
216 this.element.webkitRequestFullScreen(); | 221 this.element.webkitRequestFullScreen(); |
217 }.bind(this)); | 222 }.bind(this)); |
218 }; | 223 }; |
219 | 224 |
220 // Implemented when the ChromeWebView API is available. | 225 // Implemented when the ChromeWebView API is available. |
221 WebViewImpl.prototype.maybeSetupContextMenus = function() {}; | 226 WebViewImpl.prototype.maybeSetupContextMenus = function() {}; |
222 | 227 |
| 228 // Implemented when the experimental WebView API is available. |
| 229 WebViewImpl.maybeGetExperimentalApiMethods = function() { return []; }; |
| 230 |
223 GuestViewContainer.registerElement(WebViewImpl); | 231 GuestViewContainer.registerElement(WebViewImpl); |
224 | 232 |
225 // Exports. | 233 // Exports. |
226 exports.$set('WebViewImpl', WebViewImpl); | 234 exports.$set('WebViewImpl', WebViewImpl); |
OLD | NEW |