Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: chrome/renderer/resources/extensions/web_view.js

Issue 16975007: Run shim's watchForTag on document.DOMContentLoaded (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from kalman@ Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/web_view/document_ready/embedder.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 25 matching lines...) Expand all
36 'loadabort' : ['url', 'isTopLevel', 'reason'], 36 'loadabort' : ['url', 'isTopLevel', 'reason'],
37 'loadcommit' : ['url', 'isTopLevel'], 37 'loadcommit' : ['url', 'isTopLevel'],
38 'loadredirect' : ['oldUrl', 'newUrl', 'isTopLevel'], 38 'loadredirect' : ['oldUrl', 'newUrl', 'isTopLevel'],
39 'loadstart' : ['url', 'isTopLevel'], 39 'loadstart' : ['url', 'isTopLevel'],
40 'loadstop' : [], 40 'loadstop' : [],
41 'responsive' : ['processId'], 41 'responsive' : ['processId'],
42 'sizechanged': ['oldHeight', 'oldWidth', 'newHeight', 'newWidth'], 42 'sizechanged': ['oldHeight', 'oldWidth', 'newHeight', 'newWidth'],
43 'unresponsive' : ['processId'] 43 'unresponsive' : ['processId']
44 }; 44 };
45 45
46 window.addEventListener('DOMContentLoaded', function() { 46 // The <webview> tags we wish to watch for (watchForTag) does not belong to the
47 watchForTag('WEBVIEW', function(addedNode) { new WebView(addedNode); }); 47 // current scope's "document" reference. We need to wait until the document
48 }); 48 // begins loading, since only then will the "document" reference
49 // point to the page's document (it will be reset between now and then).
50 // We can't listen for the "readystatechange" event on the document (because
51 // the object that it's dispatched on doesn't exist yet), but we can instead
52 // do it at the window level in the capturing phase.
53 window.addEventListener('readystatechange', function(e) {
54 if (document.readyState != 'loading') {
55 return;
56 }
57
58 document.addEventListener('DOMContentLoaded', function(e) {
59 watchForTag('WEBVIEW', function(addedNode) { new WebView(addedNode); });
60 });
61 }, true /* useCapture */);
49 62
50 /** 63 /**
51 * @constructor 64 * @constructor
52 */ 65 */
53 function WebView(webviewNode) { 66 function WebView(webviewNode) {
54 this.webviewNode_ = webviewNode; 67 this.webviewNode_ = webviewNode;
55 this.browserPluginNode_ = this.createBrowserPluginNode_(); 68 this.browserPluginNode_ = this.createBrowserPluginNode_();
56 var shadowRoot = this.webviewNode_.webkitCreateShadowRoot(); 69 var shadowRoot = this.webviewNode_.webkitCreateShadowRoot();
57 shadowRoot.appendChild(this.browserPluginNode_); 70 shadowRoot.appendChild(this.browserPluginNode_);
58 71
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 return []; 485 return [];
473 }; 486 };
474 487
475 /** 488 /**
476 * Implemented when the experimental API is available. 489 * Implemented when the experimental API is available.
477 * @private 490 * @private
478 */ 491 */
479 WebView.prototype.maybeSetupExperimentalAPI_ = function() {}; 492 WebView.prototype.maybeSetupExperimentalAPI_ = function() {};
480 493
481 exports.WebView = WebView; 494 exports.WebView = WebView;
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/web_view/document_ready/embedder.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698