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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 118 |
119 /** | 119 /** |
120 * @private | 120 * @private |
121 */ | 121 */ |
122 WebView.prototype.setupWebviewNodeMethods_ = function() { | 122 WebView.prototype.setupWebviewNodeMethods_ = function() { |
123 // this.browserPluginNode_[apiMethod] are not necessarily defined immediately | 123 // this.browserPluginNode_[apiMethod] are not necessarily defined immediately |
124 // after the shadow object is appended to the shadow root. | 124 // after the shadow object is appended to the shadow root. |
125 var self = this; | 125 var self = this; |
126 $Array.forEach(WEB_VIEW_API_METHODS, function(apiMethod) { | 126 $Array.forEach(WEB_VIEW_API_METHODS, function(apiMethod) { |
127 self.webviewNode_[apiMethod] = function(var_args) { | 127 self.webviewNode_[apiMethod] = function(var_args) { |
128 return self.browserPluginNode_[apiMethod].apply( | 128 return $Function.apply(self.browserPluginNode_[apiMethod], |
129 self.browserPluginNode_, arguments); | 129 self.browserPluginNode_, arguments); |
130 }; | 130 }; |
131 }, this); | 131 }, this); |
132 this.setupExecuteCodeAPI_(); | 132 this.setupExecuteCodeAPI_(); |
133 }; | 133 }; |
134 | 134 |
135 /** | 135 /** |
136 * @private | 136 * @private |
137 */ | 137 */ |
138 WebView.prototype.setupWebviewNodeProperties_ = function() { | 138 WebView.prototype.setupWebviewNodeProperties_ = function() { |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 | 360 |
361 var self = this; | 361 var self = this; |
362 var validateCall = function() { | 362 var validateCall = function() { |
363 if (!self.browserPluginNode_.getGuestInstanceId()) { | 363 if (!self.browserPluginNode_.getGuestInstanceId()) { |
364 throw new Error(ERROR_MSG_CANNOT_INJECT_SCRIPT); | 364 throw new Error(ERROR_MSG_CANNOT_INJECT_SCRIPT); |
365 } | 365 } |
366 }; | 366 }; |
367 | 367 |
368 this.webviewNode_['executeScript'] = function(var_args) { | 368 this.webviewNode_['executeScript'] = function(var_args) { |
369 validateCall(); | 369 validateCall(); |
370 var args = [self.browserPluginNode_.getGuestInstanceId()].concat( | 370 var args = $Array.concat([self.browserPluginNode_.getGuestInstanceId()], |
371 Array.prototype.slice.call(arguments)); | 371 $Array.slice(arguments)); |
372 chrome.webview.executeScript.apply(null, args); | 372 $Function.apply(chrome.webview.executeScript, null, args); |
373 } | 373 } |
374 this.webviewNode_['insertCSS'] = function(var_args) { | 374 this.webviewNode_['insertCSS'] = function(var_args) { |
375 validateCall(); | 375 validateCall(); |
376 var args = [self.browserPluginNode_.getGuestInstanceId()].concat( | 376 var args = $Array.concat([self.browserPluginNode_.getGuestInstanceId()], |
377 Array.prototype.slice.call(arguments)); | 377 $Array.slice(arguments)); |
378 chrome.webview.insertCSS.apply(null, args); | 378 $Function.apply(chrome.webview.insertCSS, null, args); |
379 } | 379 } |
380 }; | 380 }; |
381 | 381 |
382 /** | 382 /** |
383 * Implemented when the experimental API is available. | 383 * Implemented when the experimental API is available. |
384 * @private | 384 * @private |
385 */ | 385 */ |
386 WebView.prototype.maybeSetupExperimentalAPI_ = function() {}; | 386 WebView.prototype.maybeSetupExperimentalAPI_ = function() {}; |
387 | 387 |
388 exports.WebView = WebView; | 388 exports.WebView = WebView; |
OLD | NEW |