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

Side by Side Diff: chrome/browser/ui/extensions/shell_window.cc

Issue 11198044: Make tab capture media stream requests verify that the request came from extension API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 8 years, 2 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
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 #include "chrome/browser/ui/extensions/shell_window.h" 5 #include "chrome/browser/ui/extensions/shell_window.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/extensions/extension_process_manager.h" 8 #include "chrome/browser/extensions/extension_process_manager.h"
9 #include "chrome/browser/extensions/extension_system.h" 9 #include "chrome/browser/extensions/extension_system.h"
10 #include "chrome/browser/extensions/shell_window_geometry_cache.h" 10 #include "chrome/browser/extensions/shell_window_geometry_cache.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 191 }
192 192
193 void ShellWindow::RequestMediaAccessPermission( 193 void ShellWindow::RequestMediaAccessPermission(
194 content::WebContents* web_contents, 194 content::WebContents* web_contents,
195 const content::MediaStreamRequest* request, 195 const content::MediaStreamRequest* request,
196 const content::MediaResponseCallback& callback) { 196 const content::MediaResponseCallback& callback) {
197 content::MediaStreamDevices devices; 197 content::MediaStreamDevices devices;
198 198
199 // Auto-accept the first audio device and the first video device from the 199 // Auto-accept the first audio device and the first video device from the
200 // request when the appropriate API permissions exist. 200 // request when the appropriate API permissions exist.
201 // For tab media types, we require the tab capture permission instead.
201 bool accepted_an_audio_device = false; 202 bool accepted_an_audio_device = false;
202 bool accepted_a_video_device = false; 203 bool accepted_a_video_device = false;
203 for (content::MediaStreamDeviceMap::const_iterator it = 204 for (content::MediaStreamDeviceMap::const_iterator it =
204 request->devices.begin(); 205 request->devices.begin(); it != request->devices.end(); ++it) {
205 it != request->devices.end(); ++it) { 206 if (!accepted_an_audio_device && content::IsAudioMediaType(it->first) &&
206 if (!accepted_an_audio_device &&
207 content::IsAudioMediaType(it->first) &&
208 extension()->HasAPIPermission(APIPermission::kAudioCapture) &&
209 !it->second.empty()) { 207 !it->second.empty()) {
210 devices.push_back(it->second.front()); 208 if ((it->first != content::MEDIA_TAB_AUDIO_CAPTURE &&
no longer working on chromium 2012/10/18 08:36:17 it should be it->first != content::MEDIA_DEVICE_AU
justinlin 2012/10/18 09:33:29 Sorry, tried to be clever and probably made it too
211 accepted_an_audio_device = true; 209 extension()->HasAPIPermission(APIPermission::kAudioCapture)) ||
210 extension()->HasAPIPermission(APIPermission::kTabCapture)) {
no longer working on chromium 2012/10/18 08:36:17 indentation.
no longer working on chromium 2012/10/18 08:36:17 Dont you need to it->first == content::MEDIA_TAB_
justinlin 2012/10/18 09:33:29 Done.
justinlin 2012/10/18 09:33:29 Done.
211 devices.push_back(it->second.front());
212 accepted_an_audio_device = true;
213 }
212 } else if (!accepted_a_video_device && 214 } else if (!accepted_a_video_device &&
213 content::IsVideoMediaType(it->first) && 215 content::IsVideoMediaType(it->first) && !it->second.empty()) {
214 extension()->HasAPIPermission(APIPermission::kVideoCapture) && 216 if ((it->first != content::MEDIA_TAB_VIDEO_CAPTURE &&
no longer working on chromium 2012/10/18 08:36:17 ditto
justinlin 2012/10/18 09:33:29 Same
215 !it->second.empty()) { 217 extension()->HasAPIPermission(APIPermission::kVideoCapture)) ||
216 devices.push_back(it->second.front()); 218 extension()->HasAPIPermission(APIPermission::kTabCapture)) {
217 accepted_a_video_device = true; 219 devices.push_back(it->second.front());
220 accepted_an_audio_device = true;
221 }
218 } 222 }
219 } 223 }
220 224
221 callback.Run(devices); 225 callback.Run(devices);
222 } 226 }
223 227
224 WebContents* ShellWindow::OpenURLFromTab(WebContents* source, 228 WebContents* ShellWindow::OpenURLFromTab(WebContents* source,
225 const content::OpenURLParams& params) { 229 const content::OpenURLParams& params) {
226 DCHECK(source == web_contents_); 230 DCHECK(source == web_contents_);
227 231
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 const extensions::DraggableRegion& region = *iter; 490 const extensions::DraggableRegion& region = *iter;
487 sk_region->op( 491 sk_region->op(
488 region.bounds.x(), 492 region.bounds.x(),
489 region.bounds.y(), 493 region.bounds.y(),
490 region.bounds.right(), 494 region.bounds.right(),
491 region.bounds.bottom(), 495 region.bounds.bottom(),
492 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); 496 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
493 } 497 }
494 return sk_region; 498 return sk_region;
495 } 499 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698