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

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: Sync and reup patch for review. Created 8 years, 1 month 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 return objectNode[attributeName]; 113 return objectNode[attributeName];
114 }, 114 },
115 // No setter. 115 // No setter.
116 enumerable: true 116 enumerable: true
117 }) 117 })
118 }, this); 118 }, this);
119 119
120 for (var eventName in WEB_VIEW_EVENTS) { 120 for (var eventName in WEB_VIEW_EVENTS) {
121 this.setupEvent_(eventName, WEB_VIEW_EVENTS[eventName]); 121 this.setupEvent_(eventName, WEB_VIEW_EVENTS[eventName]);
122 } 122 }
123 this.setupEvent_('permissionrequest',
124 ['reason'],
Charlie Reis 2012/11/20 01:54:00 The API called for 'type', but if that's not avail
lazyboy 2012/11/20 02:55:20 This should be easy to change later (before m25 cu
125 this.preparePremissionEvent_.bind(this));
123 } 126 }
124 127
125 /** 128 /**
126 * @private 129 * @private
127 */ 130 */
128 WebView.prototype.handleMutation_ = function(mutation) { 131 WebView.prototype.handleMutation_ = function(mutation) {
129 this.node_[mutation.attributeName] = 132 this.node_[mutation.attributeName] =
130 this.node_.getAttribute(mutation.attributeName); 133 this.node_.getAttribute(mutation.attributeName);
131 }; 134 };
132 135
133 /** 136 /**
134 * @private 137 * @private
135 */ 138 */
136 WebView.prototype.setupEvent_ = function(eventname, attribs) { 139 WebView.prototype.setupEvent_ = function(eventname, attribs, opt_prepareEvent) {
Charlie Reis 2012/11/20 01:54:00 I'm not familiar with our JS style guide rules. A
lazyboy 2012/11/20 02:55:20 I don't know about chromium js style guide. Google
Charlie Reis 2012/12/07 19:16:25 Ok. Make sure you get a chrome/ reviewer to appro
137 var node = this.node_; 140 var node = this.node_;
138 this.objectNode_.addEventListener('-internal-' + eventname, function(e) { 141 this.objectNode_.addEventListener('-internal-' + eventname, function(e) {
139 var evt = new Event(eventname); 142 var evt = new Event(eventname);
140 var detail = e.detail ? JSON.parse(e.detail) : {}; 143 var detail = e.detail ? JSON.parse(e.detail) : {};
141 attribs.forEach(function(attribName) { 144 attribs.forEach(function(attribName) {
142 evt[attribName] = detail[attribName]; 145 evt[attribName] = detail[attribName];
143 }); 146 });
147 if (opt_prepareEvent) {
148 opt_prepareEvent(evt, detail);
149 }
144 node.dispatchEvent(evt); 150 node.dispatchEvent(evt);
145 }); 151 });
146 } 152 };
153
154 /**
155 * @param {Event} webViewEvt The event to be dispatched to <webview>.
156 * @param {!Object} detail The event details, originated from <object>.
157 * @private
158 */
159 WebView.prototype.preparePremissionEvent_ = function(webViewEvt, detail) {
160 if (detail.reason == 'media' && detail.request_id !== undefined) {
161 // TODO(lazyboy): Also fill in webViewEvt.url and webViewEvt.details (see
162 // webview specs).
Charlie Reis 2012/11/20 01:54:00 Are we still happy with the spec, or should it be
lazyboy 2012/11/20 02:55:20 Details can be made useful, probably noting that w
163 var objectNode = this.objectNode_;
164 var requestId = detail.request_id;
165 webViewEvt.allow = function() {
166 objectNode.setMediaPermission(requestId, true /* allow */);
Charlie Reis 2012/11/20 01:54:00 nit: Don't need the /* allow */, since it's clear
lazyboy 2012/11/20 02:55:20 Done.
167 };
168 webViewEvt.deny = function() {
169 objectNode.setMediaPermission(requestId, false /* allow */);
170 };
171 }
172 };
173
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698