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

Side by Side Diff: chrome/browser/media/media_capture_devices_dispatcher.cc

Issue 23454030: Whitelist virtual keyboard extension to accept audioCapture and videoCapture permissions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: whitelist vk extension to take audioCapture and videoCapture permission Created 7 years, 3 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/media/media_capture_devices_dispatcher.h" 5 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/sha1.h" 10 #include "base/sha1.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 const std::string& device_id) { 52 const std::string& device_id) {
53 content::MediaStreamDevices::const_iterator iter = devices.begin(); 53 content::MediaStreamDevices::const_iterator iter = devices.begin();
54 for (; iter != devices.end(); ++iter) { 54 for (; iter != devices.end(); ++iter) {
55 if (iter->id == device_id) { 55 if (iter->id == device_id) {
56 return &(*iter); 56 return &(*iter);
57 } 57 }
58 } 58 }
59 return NULL; 59 return NULL;
60 }; 60 };
61 61
62 // This is a short-term solution to grant microphone access to virtual keyboard
63 // extension for voice input. Once http://crbug.com/292856 is fixed, remove this
64 // whitelist.
65 bool IsMediaRequestWhitelistedForExtension(
66 const extensions::Extension* extension) {
67 return extension->id() == "mppnpdlheglhdfmldimlhpnegondlapf";
68 }
69
62 // This is a short-term solution to allow testing of the the Screen Capture API 70 // This is a short-term solution to allow testing of the the Screen Capture API
63 // with Google Hangouts in M27. 71 // with Google Hangouts in M27.
64 // TODO(sergeyu): Remove this whitelist as soon as possible. 72 // TODO(sergeyu): Remove this whitelist as soon as possible.
65 bool IsOriginWhitelistedForScreenCapture(const GURL& origin) { 73 bool IsOriginWhitelistedForScreenCapture(const GURL& origin) {
66 #if defined(OFFICIAL_BUILD) 74 #if defined(OFFICIAL_BUILD)
67 if (// Google Hangouts. 75 if (// Google Hangouts.
68 (origin.SchemeIs("https") && 76 (origin.SchemeIs("https") &&
69 EndsWith(origin.spec(), ".talkgadget.google.com/", true)) || 77 EndsWith(origin.spec(), ".talkgadget.google.com/", true)) ||
70 origin.spec() == "https://plus.google.com/" || 78 origin.spec() == "https://plus.google.com/" ||
71 origin.spec() == "chrome-extension://pkedcjkdefgpdelpbcmbmeomcjbeemfm/" || 79 origin.spec() == "chrome-extension://pkedcjkdefgpdelpbcmbmeomcjbeemfm/" ||
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 204 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
197 205
198 if (request.video_type == content::MEDIA_DESKTOP_VIDEO_CAPTURE || 206 if (request.video_type == content::MEDIA_DESKTOP_VIDEO_CAPTURE ||
199 request.audio_type == content::MEDIA_SYSTEM_AUDIO_CAPTURE) { 207 request.audio_type == content::MEDIA_SYSTEM_AUDIO_CAPTURE) {
200 ProcessDesktopCaptureAccessRequest( 208 ProcessDesktopCaptureAccessRequest(
201 web_contents, request, callback, extension); 209 web_contents, request, callback, extension);
202 } else if (request.video_type == content::MEDIA_TAB_VIDEO_CAPTURE || 210 } else if (request.video_type == content::MEDIA_TAB_VIDEO_CAPTURE ||
203 request.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE) { 211 request.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE) {
204 ProcessTabCaptureAccessRequest( 212 ProcessTabCaptureAccessRequest(
205 web_contents, request, callback, extension); 213 web_contents, request, callback, extension);
206 } else if (extension && extension->is_platform_app()) { 214 } else if (extension && (extension->is_platform_app() ||
215 IsMediaRequestWhitelistedForExtension(extension))) {
207 // For extensions access is approved based on extension permissions. 216 // For extensions access is approved based on extension permissions.
208 ProcessMediaAccessRequestFromPlatformApp( 217 ProcessMediaAccessRequestFromPlatformAppOrExtension(
209 web_contents, request, callback, extension); 218 web_contents, request, callback, extension);
210 } else { 219 } else {
211 ProcessRegularMediaAccessRequest(web_contents, request, callback); 220 ProcessRegularMediaAccessRequest(web_contents, request, callback);
212 } 221 }
213 } 222 }
214 223
215 void MediaCaptureDevicesDispatcher::ProcessDesktopCaptureAccessRequest( 224 void MediaCaptureDevicesDispatcher::ProcessDesktopCaptureAccessRequest(
216 content::WebContents* web_contents, 225 content::WebContents* web_contents,
217 const content::MediaStreamRequest& request, 226 const content::MediaStreamRequest& request,
218 const content::MediaResponseCallback& callback, 227 const content::MediaResponseCallback& callback,
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 } 410 }
402 411
403 if (!devices.empty()) { 412 if (!devices.empty()) {
404 ui = media_stream_capture_indicator_->RegisterMediaStream( 413 ui = media_stream_capture_indicator_->RegisterMediaStream(
405 web_contents, devices); 414 web_contents, devices);
406 } 415 }
407 callback.Run(devices, ui.Pass()); 416 callback.Run(devices, ui.Pass());
408 #endif // !defined(OS_ANDROID) 417 #endif // !defined(OS_ANDROID)
409 } 418 }
410 419
411 void MediaCaptureDevicesDispatcher::ProcessMediaAccessRequestFromPlatformApp( 420 void MediaCaptureDevicesDispatcher::
412 content::WebContents* web_contents, 421 ProcessMediaAccessRequestFromPlatformAppOrExtension(
413 const content::MediaStreamRequest& request, 422 content::WebContents* web_contents,
414 const content::MediaResponseCallback& callback, 423 const content::MediaStreamRequest& request,
415 const extensions::Extension* extension) { 424 const content::MediaResponseCallback& callback,
425 const extensions::Extension* extension) {
416 content::MediaStreamDevices devices; 426 content::MediaStreamDevices devices;
417 Profile* profile = 427 Profile* profile =
418 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 428 Profile::FromBrowserContext(web_contents->GetBrowserContext());
419 429
420 if (request.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE && 430 if (request.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE &&
421 extension->HasAPIPermission(extensions::APIPermission::kAudioCapture)) { 431 extension->HasAPIPermission(extensions::APIPermission::kAudioCapture)) {
422 GetDefaultDevicesForProfile(profile, true, false, &devices); 432 GetDefaultDevicesForProfile(profile, true, false, &devices);
423 } 433 }
424 434
425 if (request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE && 435 if (request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE &&
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 state)); 707 state));
698 } 708 }
699 709
700 void MediaCaptureDevicesDispatcher::OnCreatingAudioStreamOnUIThread( 710 void MediaCaptureDevicesDispatcher::OnCreatingAudioStreamOnUIThread(
701 int render_process_id, 711 int render_process_id,
702 int render_view_id) { 712 int render_view_id) {
703 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 713 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
704 FOR_EACH_OBSERVER(Observer, observers_, 714 FOR_EACH_OBSERVER(Observer, observers_,
705 OnCreatingAudioStream(render_process_id, render_view_id)); 715 OnCreatingAudioStream(render_process_id, render_view_id));
706 } 716 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698