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