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'); | |
| 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 16 matching lines...) Expand all Loading... | |
| 36 'exit' : ['processId', 'reason'], | 39 'exit' : ['processId', 'reason'], |
| 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 |
|
lazyboy
2013/06/14 00:30:10
If i refer to "document" here (in file's global sc
| |
| 47 window.addEventListener('DOMContentLoaded', function() { | 50 renderViewObserverNatives.OnDocumentCreatedForCurrentContext(function() { |
| 48 watchForTag('WEBVIEW', function(addedNode) { new WebView(addedNode); }); | 51 // At this point we have a new document where app's content would go |
| 52 // (document.readyState == 'loading'), run watchForTag() once document's | |
| 53 // OnDOMContentLoaded fires. | |
| 54 document.addEventListener('DOMContentLoaded', function(e) { | |
|
lazyboy
2013/06/14 00:30:10
(See this after next comment)
this "document" is d
| |
| 55 watchForTag('WEBVIEW', function(addedNode) { new WebView(addedNode); }); | |
| 56 }); | |
| 49 }); | 57 }); |
| 50 | 58 |
| 51 /** | 59 /** |
|
lazyboy
2013/06/14 00:30:10
(This is not about here)
Let's say I have an app
| |
| 52 * @constructor | 60 * @constructor |
| 53 */ | 61 */ |
| 54 function WebView(webviewNode) { | 62 function WebView(webviewNode) { |
| 55 this.webviewNode_ = webviewNode; | 63 this.webviewNode_ = webviewNode; |
| 56 this.browserPluginNode_ = this.createBrowserPluginNode_(); | 64 this.browserPluginNode_ = this.createBrowserPluginNode_(); |
| 57 var shadowRoot = this.webviewNode_.webkitCreateShadowRoot(); | 65 var shadowRoot = this.webviewNode_.webkitCreateShadowRoot(); |
| 58 shadowRoot.appendChild(this.browserPluginNode_); | 66 shadowRoot.appendChild(this.browserPluginNode_); |
| 59 | 67 |
| 60 this.setupFocusPropagation_(); | 68 this.setupFocusPropagation_(); |
| 61 this.setupWebviewNodeMethods_(); | 69 this.setupWebviewNodeMethods_(); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 } | 385 } |
| 378 }; | 386 }; |
| 379 | 387 |
| 380 /** | 388 /** |
| 381 * Implemented when the experimental API is available. | 389 * Implemented when the experimental API is available. |
| 382 * @private | 390 * @private |
| 383 */ | 391 */ |
| 384 WebView.prototype.maybeSetupExperimentalAPI_ = function() {}; | 392 WebView.prototype.maybeSetupExperimentalAPI_ = function() {}; |
| 385 | 393 |
| 386 exports.WebView = WebView; | 394 exports.WebView = WebView; |
| OLD | NEW |