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