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 // Shim that simulates a <webview> tag via Mutation Observers. | 5 // Shim that simulates a <webview> tag via Mutation Observers. |
6 // | 6 // |
7 // The actual tag is implemented via the browser plugin. The internals of this | 7 // The actual tag is implemented via the browser plugin. The internals of this |
8 // are hidden via Shadow DOM. | 8 // are hidden via Shadow DOM. |
9 | 9 |
10 var watchForTag = require('tagWatcher').watchForTag; | 10 var watchForTag = require('tagWatcher').watchForTag; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 131 |
132 /** | 132 /** |
133 * @private | 133 * @private |
134 */ | 134 */ |
135 WebView.prototype.setupWebviewNodeMethods_ = function() { | 135 WebView.prototype.setupWebviewNodeMethods_ = function() { |
136 // this.browserPluginNode_[apiMethod] are not necessarily defined immediately | 136 // this.browserPluginNode_[apiMethod] are not necessarily defined immediately |
137 // after the shadow object is appended to the shadow root. | 137 // after the shadow object is appended to the shadow root. |
138 var self = this; | 138 var self = this; |
139 $Array.forEach(WEB_VIEW_API_METHODS, function(apiMethod) { | 139 $Array.forEach(WEB_VIEW_API_METHODS, function(apiMethod) { |
140 self.webviewNode_[apiMethod] = function(var_args) { | 140 self.webviewNode_[apiMethod] = function(var_args) { |
141 return self.browserPluginNode_[apiMethod].apply( | 141 return $Function.apply(self.browserPluginNode_[apiMethod], |
142 self.browserPluginNode_, arguments); | 142 self.browserPluginNode_, arguments); |
143 }; | 143 }; |
144 }, this); | 144 }, this); |
145 this.setupExecuteCodeAPI_(); | 145 this.setupExecuteCodeAPI_(); |
146 }; | 146 }; |
147 | 147 |
148 /** | 148 /** |
149 * @private | 149 * @private |
150 */ | 150 */ |
151 WebView.prototype.setupWebviewNodeProperties_ = function() { | 151 WebView.prototype.setupWebviewNodeProperties_ = function() { |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 | 381 |
382 var self = this; | 382 var self = this; |
383 var validateCall = function() { | 383 var validateCall = function() { |
384 if (!self.browserPluginNode_.getGuestInstanceId()) { | 384 if (!self.browserPluginNode_.getGuestInstanceId()) { |
385 throw new Error(ERROR_MSG_CANNOT_INJECT_SCRIPT); | 385 throw new Error(ERROR_MSG_CANNOT_INJECT_SCRIPT); |
386 } | 386 } |
387 }; | 387 }; |
388 | 388 |
389 this.webviewNode_['executeScript'] = function(var_args) { | 389 this.webviewNode_['executeScript'] = function(var_args) { |
390 validateCall(); | 390 validateCall(); |
391 var args = [self.browserPluginNode_.getGuestInstanceId()].concat( | 391 var args = $Array.concat([self.browserPluginNode_.getGuestInstanceId()], |
392 Array.prototype.slice.call(arguments)); | 392 $Array.slice(arguments)); |
393 chrome.webview.executeScript.apply(null, args); | 393 $Function.apply(chrome.webview.executeScript, null, args); |
394 } | 394 } |
395 this.webviewNode_['insertCSS'] = function(var_args) { | 395 this.webviewNode_['insertCSS'] = function(var_args) { |
396 validateCall(); | 396 validateCall(); |
397 var args = [self.browserPluginNode_.getGuestInstanceId()].concat( | 397 var args = $Array.concat([self.browserPluginNode_.getGuestInstanceId()], |
398 Array.prototype.slice.call(arguments)); | 398 $Array.slice(arguments)); |
399 chrome.webview.insertCSS.apply(null, args); | 399 $Function.apply(chrome.webview.insertCSS, null, args); |
400 } | 400 } |
401 }; | 401 }; |
402 | 402 |
403 /** | 403 /** |
404 * @private | 404 * @private |
405 */ | 405 */ |
406 WebView.prototype.getPermissionTypes_ = function() { | 406 WebView.prototype.getPermissionTypes_ = function() { |
407 var PERMISSION_TYPES = ['media', 'geolocation', 'pointerLock']; | 407 var PERMISSION_TYPES = ['media', 'geolocation', 'pointerLock']; |
408 return PERMISSION_TYPES.concat(this.maybeGetExperimentalPermissionTypes_()); | 408 return PERMISSION_TYPES.concat(this.maybeGetExperimentalPermissionTypes_()); |
409 }; | 409 }; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 return []; | 485 return []; |
486 }; | 486 }; |
487 | 487 |
488 /** | 488 /** |
489 * Implemented when the experimental API is available. | 489 * Implemented when the experimental API is available. |
490 * @private | 490 * @private |
491 */ | 491 */ |
492 WebView.prototype.maybeSetupExperimentalAPI_ = function() {}; | 492 WebView.prototype.maybeSetupExperimentalAPI_ = function() {}; |
493 | 493 |
494 exports.WebView = WebView; | 494 exports.WebView = WebView; |
OLD | NEW |