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

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 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_DEVICE_AUDIO_CAPTURE &&
211 accepted_an_audio_device = true; 209 extension()->HasAPIPermission(APIPermission::kAudioCapture)) ||
210 (it->first == content::MEDIA_TAB_AUDIO_CAPTURE &&
211 extension()->HasAPIPermission(APIPermission::kTabCapture))) {
212 devices.push_back(it->second.front());
213 accepted_an_audio_device = true;
214 }
212 } else if (!accepted_a_video_device && 215 } else if (!accepted_a_video_device &&
213 content::IsVideoMediaType(it->first) && 216 content::IsVideoMediaType(it->first) && !it->second.empty()) {
214 extension()->HasAPIPermission(APIPermission::kVideoCapture) && 217 if ((it->first == content::MEDIA_DEVICE_VIDEO_CAPTURE &&
215 !it->second.empty()) { 218 extension()->HasAPIPermission(APIPermission::kVideoCapture)) ||
216 devices.push_back(it->second.front()); 219 (it->first == content::MEDIA_TAB_VIDEO_CAPTURE &&
217 accepted_a_video_device = true; 220 extension()->HasAPIPermission(APIPermission::kTabCapture))) {
221 devices.push_back(it->second.front());
222 accepted_an_audio_device = true;
223 }
218 } 224 }
219 } 225 }
220 226
221 callback.Run(devices); 227 callback.Run(devices);
222 } 228 }
223 229
224 WebContents* ShellWindow::OpenURLFromTab(WebContents* source, 230 WebContents* ShellWindow::OpenURLFromTab(WebContents* source,
225 const content::OpenURLParams& params) { 231 const content::OpenURLParams& params) {
226 DCHECK(source == web_contents_); 232 DCHECK(source == web_contents_);
227 233
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 const extensions::DraggableRegion& region = *iter; 492 const extensions::DraggableRegion& region = *iter;
487 sk_region->op( 493 sk_region->op(
488 region.bounds.x(), 494 region.bounds.x(),
489 region.bounds.y(), 495 region.bounds.y(),
490 region.bounds.right(), 496 region.bounds.right(),
491 region.bounds.bottom(), 497 region.bounds.bottom(),
492 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); 498 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
493 } 499 }
494 return sk_region; 500 return sk_region;
495 } 501 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698