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

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

Issue 11820029: <webview>: BrowserPlugin methods are not defined immediately after the shadow object is appended to… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed nit Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // The <object> node fills in the <browser> container. 51 // The <object> node fills in the <browser> container.
52 this.objectNode_.style.width = '100%'; 52 this.objectNode_.style.width = '100%';
53 this.objectNode_.style.height = '100%'; 53 this.objectNode_.style.height = '100%';
54 WEB_VIEW_ATTRIBUTES.forEach(function(attributeName) { 54 WEB_VIEW_ATTRIBUTES.forEach(function(attributeName) {
55 this.objectNode_.setAttribute( 55 this.objectNode_.setAttribute(
56 attributeName, this.node_.getAttribute(attributeName)); 56 attributeName, this.node_.getAttribute(attributeName));
57 }, this); 57 }, this);
58 58
59 shadowRoot.appendChild(this.objectNode_); 59 shadowRoot.appendChild(this.objectNode_);
60 60
61 // this.objectNode_[apiMethod] are defined after the shadow object is appended 61 // this.objectNode_[apiMethod] are not necessarily defined immediately after
62 // to the shadow root. 62 // the shadow object is appended to the shadow root.
63 var self = this;
63 WEB_VIEW_API_METHODS.forEach(function(apiMethod) { 64 WEB_VIEW_API_METHODS.forEach(function(apiMethod) {
64 node[apiMethod] = this.objectNode_[apiMethod].bind(this.objectNode_); 65 node[apiMethod] = function(var_args) {
66 return self.objectNode_[apiMethod].apply(self.objectNode_, arguments);
67 };
65 }, this); 68 }, this);
66 69
67 // Map attribute modifications on the <webview> tag to property changes in 70 // Map attribute modifications on the <webview> tag to property changes in
68 // the underlying <object> node. 71 // the underlying <object> node.
69 var handleMutation = this.handleMutation_.bind(this); 72 var handleMutation = this.handleMutation_.bind(this);
70 var observer = new WebKitMutationObserver(function(mutations) { 73 var observer = new WebKitMutationObserver(function(mutations) {
71 mutations.forEach(handleMutation); 74 mutations.forEach(handleMutation);
72 }); 75 });
73 observer.observe( 76 observer.observe(
74 this.node_, 77 this.node_,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 var node = this.node_; 153 var node = this.node_;
151 this.objectNode_.addEventListener('-internal-' + eventname, function(e) { 154 this.objectNode_.addEventListener('-internal-' + eventname, function(e) {
152 var evt = new Event(eventname); 155 var evt = new Event(eventname);
153 var detail = e.detail ? JSON.parse(e.detail) : {}; 156 var detail = e.detail ? JSON.parse(e.detail) : {};
154 attribs.forEach(function(attribName) { 157 attribs.forEach(function(attribName) {
155 evt[attribName] = detail[attribName]; 158 evt[attribName] = detail[attribName];
156 }); 159 });
157 node.dispatchEvent(evt); 160 node.dispatchEvent(evt);
158 }); 161 });
159 } 162 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698