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 // 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 appWindowNatives = requireNative('app_window_natives'); | |
|
not at google - send to devlin
2013/06/14 16:45:27
don't need this anymore
lazyboy
2013/06/14 18:17:34
Done.
| |
| 11 var renderViewObserverNatives = requireNative('renderViewObserverNatives'); | |
| 12 | |
| 10 var forEach = require('utils').forEach; | 13 var forEach = require('utils').forEach; |
| 11 var watchForTag = require('tagWatcher').watchForTag; | 14 var watchForTag = require('tagWatcher').watchForTag; |
| 12 | 15 |
| 13 /** @type {Array.<string>} */ | 16 /** @type {Array.<string>} */ |
| 14 var WEB_VIEW_ATTRIBUTES = ['name', 'src', 'partition', 'autosize', 'minheight', | 17 var WEB_VIEW_ATTRIBUTES = ['name', 'src', 'partition', 'autosize', 'minheight', |
| 15 'minwidth', 'maxheight', 'maxwidth']; | 18 'minwidth', 'maxheight', 'maxwidth']; |
| 16 | 19 |
| 17 | 20 |
| 18 // All exposed api methods for <webview>, these are forwarded to the browser | 21 // All exposed api methods for <webview>, these are forwarded to the browser |
| 19 // plugin. | 22 // plugin. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 37 'loadabort' : ['url', 'isTopLevel', 'reason'], | 40 'loadabort' : ['url', 'isTopLevel', 'reason'], |
| 38 'loadcommit' : ['url', 'isTopLevel'], | 41 'loadcommit' : ['url', 'isTopLevel'], |
| 39 'loadredirect' : ['oldUrl', 'newUrl', 'isTopLevel'], | 42 'loadredirect' : ['oldUrl', 'newUrl', 'isTopLevel'], |
| 40 'loadstart' : ['url', 'isTopLevel'], | 43 'loadstart' : ['url', 'isTopLevel'], |
| 41 'loadstop' : [], | 44 'loadstop' : [], |
| 42 'responsive' : ['processId'], | 45 'responsive' : ['processId'], |
| 43 'sizechanged': ['oldHeight', 'oldWidth', 'newHeight', 'newWidth'], | 46 'sizechanged': ['oldHeight', 'oldWidth', 'newHeight', 'newWidth'], |
| 44 'unresponsive' : ['processId'] | 47 'unresponsive' : ['processId'] |
| 45 }; | 48 }; |
| 46 | 49 |
| 47 window.addEventListener('DOMContentLoaded', function() { | 50 var documentA = document; |
| 48 watchForTag('WEBVIEW', function(addedNode) { new WebView(addedNode); }); | 51 renderViewObserverNatives.OnDocumentCreatedForCurrentContext(function() { |
| 52 var documentB = document; | |
| 53 if (documentA == documentB) { | |
| 54 window.console.log('both document are equal'); | |
| 55 } else { | |
| 56 window.console.log('documents are different'); | |
| 57 } | |
| 58 // At this point we have a new document where app's content would go | |
| 59 // (document.readyState == 'loading'), run watchForTag() once document's | |
| 60 // OnDOMContentLoaded fires. | |
| 61 document.addEventListener('DOMContentLoaded', function(e) { | |
| 62 window.console.log('shim: document.DOMContentLoaded'); | |
| 63 watchForTag('WEBVIEW', function(addedNode) { new WebView(addedNode); }); | |
| 64 }); | |
| 49 }); | 65 }); |
| 50 | 66 |
| 51 /** | 67 /** |
| 52 * @constructor | 68 * @constructor |
| 53 */ | 69 */ |
| 54 function WebView(webviewNode) { | 70 function WebView(webviewNode) { |
| 55 this.webviewNode_ = webviewNode; | 71 this.webviewNode_ = webviewNode; |
| 56 this.browserPluginNode_ = this.createBrowserPluginNode_(); | 72 this.browserPluginNode_ = this.createBrowserPluginNode_(); |
| 57 var shadowRoot = this.webviewNode_.webkitCreateShadowRoot(); | 73 var shadowRoot = this.webviewNode_.webkitCreateShadowRoot(); |
| 58 shadowRoot.appendChild(this.browserPluginNode_); | 74 shadowRoot.appendChild(this.browserPluginNode_); |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 } | 393 } |
| 378 }; | 394 }; |
| 379 | 395 |
| 380 /** | 396 /** |
| 381 * Implemented when the experimental API is available. | 397 * Implemented when the experimental API is available. |
| 382 * @private | 398 * @private |
| 383 */ | 399 */ |
| 384 WebView.prototype.maybeSetupExperimentalAPI_ = function() {}; | 400 WebView.prototype.maybeSetupExperimentalAPI_ = function() {}; |
| 385 | 401 |
| 386 exports.WebView = WebView; | 402 exports.WebView = WebView; |
| OLD | NEW |