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

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

Issue 11515016: <webview>: Workaround to enable webview.contentWindow.postMessage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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;
11 11
12 var WEB_VIEW_ATTRIBUTES = ['src', 'partition']; 12 var WEB_VIEW_ATTRIBUTES = ['src', 'partition'];
13 13
14 var WEB_VIEW_READONLY_ATTRIBUTES = ['contentWindow'];
15
16 // All exposed api methods for <webview>, these are forwarded to the browser 14 // All exposed api methods for <webview>, these are forwarded to the browser
17 // plugin. 15 // plugin.
18 var WEB_VIEW_API_METHODS = [ 16 var WEB_VIEW_API_METHODS = [
19 'back', 17 'back',
20 'canGoBack', 18 'canGoBack',
21 'canGoForward', 19 'canGoForward',
22 'forward', 20 'forward',
23 'getProcessId', 21 'getProcessId',
24 'go', 22 'go',
25 'reload', 23 'reload',
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 }, 91 },
94 set: function(value) { 92 set: function(value) {
95 objectNode[attributeName] = value; 93 objectNode[attributeName] = value;
96 }, 94 },
97 enumerable: true 95 enumerable: true
98 }); 96 });
99 }, this); 97 }, this);
100 98
101 // We cannot use {writable: true} property descriptor because we want dynamic 99 // We cannot use {writable: true} property descriptor because we want dynamic
102 // getter value. 100 // getter value.
103 WEB_VIEW_READONLY_ATTRIBUTES.forEach(function(attributeName) { 101 Object.defineProperty(this.node_, 'contentWindow', {
lazyboy 2012/12/11 16:20:15 Hopefully this doesn't break other properties with
Charlie Reis 2012/12/11 21:30:12 I'm a bit nervous about this, but maybe it's the r
Fady Samuel 2012/12/11 21:46:01 My understanding of the WebKit bug is we're creati
104 Object.defineProperty(this.node_, attributeName, { 102 get: function() {
105 get: function() { 103 // TODO(fsamuel): This is a workaround to enable
106 // Read these attributes from the plugin <object>. 104 // contentWindow.postMessage until http://crbug.com/152006 is fixed.
107 return objectNode[attributeName]; 105 return objectNode.contentWindow.frames;
sadrul 2012/12/11 01:48:56 Hm. I don't know enough about contentWindow to kno
108 }, 106 },
109 // No setter. 107 // No setter.
110 enumerable: true 108 enumerable: true
111 }) 109 });
112 }, this);
113 110
114 for (var eventName in WEB_VIEW_EVENTS) { 111 for (var eventName in WEB_VIEW_EVENTS) {
115 this.setupEvent_(eventName, WEB_VIEW_EVENTS[eventName]); 112 this.setupEvent_(eventName, WEB_VIEW_EVENTS[eventName]);
116 } 113 }
117 } 114 }
118 115
119 /** 116 /**
120 * @private 117 * @private
121 */ 118 */
122 WebView.prototype.handleMutation_ = function(mutation) { 119 WebView.prototype.handleMutation_ = function(mutation) {
(...skipping 16 matching lines...) Expand all
139 var node = this.node_; 136 var node = this.node_;
140 this.objectNode_.addEventListener('-internal-' + eventname, function(e) { 137 this.objectNode_.addEventListener('-internal-' + eventname, function(e) {
141 var evt = new Event(eventname); 138 var evt = new Event(eventname);
142 var detail = e.detail ? JSON.parse(e.detail) : {}; 139 var detail = e.detail ? JSON.parse(e.detail) : {};
143 attribs.forEach(function(attribName) { 140 attribs.forEach(function(attribName) {
144 evt[attribName] = detail[attribName]; 141 evt[attribName] = detail[attribName];
145 }); 142 });
146 node.dispatchEvent(evt); 143 node.dispatchEvent(evt);
147 }); 144 });
148 } 145 }
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