Chromium Code Reviews| 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 GuestViewInternal = | 10 var GuestViewInternal = |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 */ | 281 */ |
| 282 WebViewInternal.prototype.validateExecuteCodeCall = function() { | 282 WebViewInternal.prototype.validateExecuteCodeCall = function() { |
| 283 var ERROR_MSG_CANNOT_INJECT_SCRIPT = '<webview>: ' + | 283 var ERROR_MSG_CANNOT_INJECT_SCRIPT = '<webview>: ' + |
| 284 'Script cannot be injected into content until the page has loaded.'; | 284 'Script cannot be injected into content until the page has loaded.'; |
| 285 if (!this.guestInstanceId) { | 285 if (!this.guestInstanceId) { |
| 286 throw new Error(ERROR_MSG_CANNOT_INJECT_SCRIPT); | 286 throw new Error(ERROR_MSG_CANNOT_INJECT_SCRIPT); |
| 287 } | 287 } |
| 288 }; | 288 }; |
| 289 | 289 |
| 290 /** | 290 /** |
| 291 * @private | 291 * @private |
| 292 */ | 292 */ |
|
Fady Samuel
2014/09/25 20:09:03
Just remove this comment. We don't use this style
paulmeyer
2014/09/25 20:39:51
Done.
| |
| 293 WebViewInternal.prototype.executeScript = function(var_args) { | 293 WebViewInternal.prototype.executeScript = function(var_args) { |
| 294 this.validateExecuteCodeCall(); | 294 this.validateExecuteCodeCall(); |
| 295 var args = $Array.concat([this.guestInstanceId, this.src], | 295 var webview_src = this.src; |
| 296 if (this.baseURLForDataURL != '') { | |
|
Fady Samuel
2014/09/25 20:09:03
s/URL/Url preferred in Javascript.
paulmeyer
2014/09/25 20:39:51
Done.
| |
| 297 webview_src = this.baseURLForDataURL; | |
| 298 } | |
| 299 var args = $Array.concat([this.guestInstanceId, webview_src], | |
| 296 $Array.slice(arguments)); | 300 $Array.slice(arguments)); |
| 297 $Function.apply(WebView.executeScript, null, args); | 301 $Function.apply(WebView.executeScript, null, args); |
| 298 }; | 302 }; |
| 299 | 303 |
| 300 /** | 304 /** |
| 301 * @private | 305 * @private |
| 302 */ | 306 */ |
|
Fady Samuel
2014/09/25 20:09:03
Just remove this comment. we don't use this style
paulmeyer
2014/09/25 20:39:51
Done.
| |
| 303 WebViewInternal.prototype.insertCSS = function(var_args) { | 307 WebViewInternal.prototype.insertCSS = function(var_args) { |
| 304 this.validateExecuteCodeCall(); | 308 this.validateExecuteCodeCall(); |
| 305 var args = $Array.concat([this.guestInstanceId, this.src], | 309 var webview_src = this.src; |
| 310 if (this.baseURLForDataURL != '') { | |
|
Fady Samuel
2014/09/25 20:09:03
s/URL/Url preferred in Javascript.
paulmeyer
2014/09/25 20:39:51
Done.
| |
| 311 webview_src = this.baseURLForDataURL; | |
| 312 } | |
| 313 var args = $Array.concat([this.guestInstanceId, webview_src], | |
| 306 $Array.slice(arguments)); | 314 $Array.slice(arguments)); |
| 307 $Function.apply(WebView.insertCSS, null, args); | 315 $Function.apply(WebView.insertCSS, null, args); |
| 308 }; | 316 }; |
| 309 | 317 |
| 310 WebViewInternal.prototype.setupAutoSizeProperties = function() { | 318 WebViewInternal.prototype.setupAutoSizeProperties = function() { |
| 311 $Array.forEach(AUTO_SIZE_ATTRIBUTES, function(attributeName) { | 319 $Array.forEach(AUTO_SIZE_ATTRIBUTES, function(attributeName) { |
| 312 this[attributeName] = this.webviewNode.getAttribute(attributeName); | 320 this[attributeName] = this.webviewNode.getAttribute(attributeName); |
| 313 Object.defineProperty(this.webviewNode, attributeName, { | 321 Object.defineProperty(this.webviewNode, attributeName, { |
| 314 get: function() { | 322 get: function() { |
| 315 return this[attributeName]; | 323 return this[attributeName]; |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 719 this.on[propertyName] = value; | 727 this.on[propertyName] = value; |
| 720 if (value) | 728 if (value) |
| 721 this.webviewNode.addEventListener(eventName, value); | 729 this.webviewNode.addEventListener(eventName, value); |
| 722 }.bind(this), | 730 }.bind(this), |
| 723 enumerable: true | 731 enumerable: true |
| 724 }); | 732 }); |
| 725 }; | 733 }; |
| 726 | 734 |
| 727 // Updates state upon loadcommit. | 735 // Updates state upon loadcommit. |
| 728 WebViewInternal.prototype.onLoadCommit = function( | 736 WebViewInternal.prototype.onLoadCommit = function( |
| 729 currentEntryIndex, entryCount, processId, url, isTopLevel) { | 737 baseURLForDataURL, currentEntryIndex, entryCount, |
| 738 processId, url, isTopLevel) { | |
| 739 this.baseURLForDataURL = baseURLForDataURL; | |
| 730 this.currentEntryIndex = currentEntryIndex; | 740 this.currentEntryIndex = currentEntryIndex; |
| 731 this.entryCount = entryCount; | 741 this.entryCount = entryCount; |
| 732 this.processId = processId; | 742 this.processId = processId; |
| 733 var oldValue = this.webviewNode.getAttribute('src'); | 743 var oldValue = this.webviewNode.getAttribute('src'); |
| 734 var newValue = url; | 744 var newValue = url; |
| 735 if (isTopLevel && (oldValue != newValue)) { | 745 if (isTopLevel && (oldValue != newValue)) { |
| 736 // Touching the src attribute triggers a navigation. To avoid | 746 // Touching the src attribute triggers a navigation. To avoid |
| 737 // triggering a page reload on every guest-initiated navigation, | 747 // triggering a page reload on every guest-initiated navigation, |
| 738 // we use the flag ignoreNextSrcAttributeChange here. | 748 // we use the flag ignoreNextSrcAttributeChange here. |
| 739 this.ignoreNextSrcAttributeChange = true; | 749 this.ignoreNextSrcAttributeChange = true; |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 996 | 1006 |
| 997 /** | 1007 /** |
| 998 * Implemented when the experimental API is available. | 1008 * Implemented when the experimental API is available. |
| 999 * @private | 1009 * @private |
| 1000 */ | 1010 */ |
| 1001 WebViewInternal.prototype.setupExperimentalContextMenus = function() { | 1011 WebViewInternal.prototype.setupExperimentalContextMenus = function() { |
| 1002 }; | 1012 }; |
| 1003 | 1013 |
| 1004 exports.WebView = WebView; | 1014 exports.WebView = WebView; |
| 1005 exports.WebViewInternal = WebViewInternal; | 1015 exports.WebViewInternal = WebViewInternal; |
| OLD | NEW |