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

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

Issue 11093080: <webview>: First stab at implementing media permission request for guests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add todo for auto deny when no listeners attached. 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
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 WEB_VIEW_ATTRIBUTES = ['src', 'partition']; 10 var WEB_VIEW_ATTRIBUTES = ['src', 'partition'];
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 return objectNode[attributeName]; 121 return objectNode[attributeName];
122 }, 122 },
123 // No setter. 123 // No setter.
124 enumerable: true 124 enumerable: true
125 }) 125 })
126 }, this); 126 }, this);
127 127
128 for (var eventName in WEB_VIEW_EVENTS) { 128 for (var eventName in WEB_VIEW_EVENTS) {
129 this.setupEvent_(eventName, WEB_VIEW_EVENTS[eventName]); 129 this.setupEvent_(eventName, WEB_VIEW_EVENTS[eventName]);
130 } 130 }
131 this.maybeSetupPermissionEvent_();
131 } 132 }
132 133
133 /** 134 /**
134 * @private 135 * @private
135 */ 136 */
136 WebView.prototype.handleMutation_ = function(mutation) { 137 WebView.prototype.handleMutation_ = function(mutation) {
137 this.objectNode_[mutation.attributeName] = 138 this.objectNode_[mutation.attributeName] =
138 this.node_.getAttribute(mutation.attributeName); 139 this.node_.getAttribute(mutation.attributeName);
139 }; 140 };
140 141
141 /** 142 /**
142 * @private 143 * @private
143 */ 144 */
144 WebView.prototype.handleObjectMutation_ = function(mutation) { 145 WebView.prototype.handleObjectMutation_ = function(mutation) {
145 this.node_.setAttribute(mutation.attributeName, 146 this.node_.setAttribute(mutation.attributeName,
146 this.objectNode_.getAttribute(mutation.attributeName)); 147 this.objectNode_.getAttribute(mutation.attributeName));
147 }; 148 };
148 149
149 /** 150 /**
150 * @private 151 * @private
151 */ 152 */
152 WebView.prototype.setupEvent_ = function(eventname, attribs) { 153 WebView.prototype.setupEvent_ = function(eventname, attribs, opt_prepareEvent) {
153 var node = this.node_; 154 var node = this.node_;
154 this.objectNode_.addEventListener('-internal-' + eventname, function(e) { 155 this.objectNode_.addEventListener('-internal-' + eventname, function(e) {
155 var evt = new Event(eventname); 156 var evt = new Event(eventname);
156 var detail = e.detail ? JSON.parse(e.detail) : {}; 157 var detail = e.detail ? JSON.parse(e.detail) : {};
157 attribs.forEach(function(attribName) { 158 attribs.forEach(function(attribName) {
158 evt[attribName] = detail[attribName]; 159 evt[attribName] = detail[attribName];
159 }); 160 });
161 if (opt_prepareEvent) {
162 opt_prepareEvent(evt, detail);
163 }
160 node.dispatchEvent(evt); 164 node.dispatchEvent(evt);
161 }); 165 });
162 } 166 };
167
168 /**
169 * Implemented when webview.permissionAPI permission is available.
170 * @private
171 */
172 WebView.prototype.maybeSetupPermissionEvent_ = function() {};
173
174 exports.WebView = WebView;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698