OLD | NEW |
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 const std::string& device_id) { | 48 const std::string& device_id) { |
49 content::MediaStreamDevices::const_iterator iter = devices.begin(); | 49 content::MediaStreamDevices::const_iterator iter = devices.begin(); |
50 for (; iter != devices.end(); ++iter) { | 50 for (; iter != devices.end(); ++iter) { |
51 if (iter->id == device_id) { | 51 if (iter->id == device_id) { |
52 return &(*iter); | 52 return &(*iter); |
53 } | 53 } |
54 } | 54 } |
55 return NULL; | 55 return NULL; |
56 }; | 56 }; |
57 | 57 |
| 58 // This is a short-term solution to grant microphone access to virtual keyboard |
| 59 // extension for voice input. Once http://crbug.com/292856 is fixed, remove this |
| 60 // whitelist. |
| 61 bool IsMediaRequestWhitelistedForExtension( |
| 62 const extensions::Extension* extension) { |
| 63 return extension->id() == "mppnpdlheglhdfmldimlhpnegondlapf"; |
| 64 } |
| 65 |
58 // This is a short-term solution to allow testing of the the Screen Capture API | 66 // This is a short-term solution to allow testing of the the Screen Capture API |
59 // with Google Hangouts in M27. | 67 // with Google Hangouts in M27. |
60 // TODO(sergeyu): Remove this whitelist as soon as possible. | 68 // TODO(sergeyu): Remove this whitelist as soon as possible. |
61 bool IsOriginWhitelistedForScreenCapture(const GURL& origin) { | 69 bool IsOriginWhitelistedForScreenCapture(const GURL& origin) { |
62 #if defined(OFFICIAL_BUILD) | 70 #if defined(OFFICIAL_BUILD) |
63 if (// Google Hangouts. | 71 if (// Google Hangouts. |
64 (origin.SchemeIs("https") && | 72 (origin.SchemeIs("https") && |
65 EndsWith(origin.spec(), ".talkgadget.google.com/", true)) || | 73 EndsWith(origin.spec(), ".talkgadget.google.com/", true)) || |
66 origin.spec() == "https://plus.google.com/" || | 74 origin.spec() == "https://plus.google.com/" || |
67 origin.spec() == "chrome-extension://pkedcjkdefgpdelpbcmbmeomcjbeemfm/" || | 75 origin.spec() == "chrome-extension://pkedcjkdefgpdelpbcmbmeomcjbeemfm/" || |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 200 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
193 | 201 |
194 if (request.video_type == content::MEDIA_DESKTOP_VIDEO_CAPTURE || | 202 if (request.video_type == content::MEDIA_DESKTOP_VIDEO_CAPTURE || |
195 request.audio_type == content::MEDIA_SYSTEM_AUDIO_CAPTURE) { | 203 request.audio_type == content::MEDIA_SYSTEM_AUDIO_CAPTURE) { |
196 ProcessDesktopCaptureAccessRequest( | 204 ProcessDesktopCaptureAccessRequest( |
197 web_contents, request, callback, extension); | 205 web_contents, request, callback, extension); |
198 } else if (request.video_type == content::MEDIA_TAB_VIDEO_CAPTURE || | 206 } else if (request.video_type == content::MEDIA_TAB_VIDEO_CAPTURE || |
199 request.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE) { | 207 request.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE) { |
200 ProcessTabCaptureAccessRequest( | 208 ProcessTabCaptureAccessRequest( |
201 web_contents, request, callback, extension); | 209 web_contents, request, callback, extension); |
202 } else if (extension && extension->is_platform_app()) { | 210 } else if (extension && (extension->is_platform_app() || |
| 211 IsMediaRequestWhitelistedForExtension(extension))) { |
203 // For extensions access is approved based on extension permissions. | 212 // For extensions access is approved based on extension permissions. |
204 ProcessMediaAccessRequestFromPlatformApp( | 213 ProcessMediaAccessRequestFromPlatformAppOrExtension( |
205 web_contents, request, callback, extension); | 214 web_contents, request, callback, extension); |
206 } else { | 215 } else { |
207 ProcessRegularMediaAccessRequest(web_contents, request, callback); | 216 ProcessRegularMediaAccessRequest(web_contents, request, callback); |
208 } | 217 } |
209 } | 218 } |
210 | 219 |
211 void MediaCaptureDevicesDispatcher::ProcessDesktopCaptureAccessRequest( | 220 void MediaCaptureDevicesDispatcher::ProcessDesktopCaptureAccessRequest( |
212 content::WebContents* web_contents, | 221 content::WebContents* web_contents, |
213 const content::MediaStreamRequest& request, | 222 const content::MediaStreamRequest& request, |
214 const content::MediaResponseCallback& callback, | 223 const content::MediaResponseCallback& callback, |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 } | 406 } |
398 | 407 |
399 if (!devices.empty()) { | 408 if (!devices.empty()) { |
400 ui = media_stream_capture_indicator_->RegisterMediaStream( | 409 ui = media_stream_capture_indicator_->RegisterMediaStream( |
401 web_contents, devices); | 410 web_contents, devices); |
402 } | 411 } |
403 callback.Run(devices, ui.Pass()); | 412 callback.Run(devices, ui.Pass()); |
404 #endif // !defined(OS_ANDROID) | 413 #endif // !defined(OS_ANDROID) |
405 } | 414 } |
406 | 415 |
407 void MediaCaptureDevicesDispatcher::ProcessMediaAccessRequestFromPlatformApp( | 416 void MediaCaptureDevicesDispatcher:: |
408 content::WebContents* web_contents, | 417 ProcessMediaAccessRequestFromPlatformAppOrExtension( |
409 const content::MediaStreamRequest& request, | 418 content::WebContents* web_contents, |
410 const content::MediaResponseCallback& callback, | 419 const content::MediaStreamRequest& request, |
411 const extensions::Extension* extension) { | 420 const content::MediaResponseCallback& callback, |
| 421 const extensions::Extension* extension) { |
412 content::MediaStreamDevices devices; | 422 content::MediaStreamDevices devices; |
413 Profile* profile = | 423 Profile* profile = |
414 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 424 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
415 | 425 |
416 if (request.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE && | 426 if (request.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE && |
417 extension->HasAPIPermission(extensions::APIPermission::kAudioCapture)) { | 427 extension->HasAPIPermission(extensions::APIPermission::kAudioCapture)) { |
418 GetDefaultDevicesForProfile(profile, true, false, &devices); | 428 GetDefaultDevicesForProfile(profile, true, false, &devices); |
419 } | 429 } |
420 | 430 |
421 if (request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE && | 431 if (request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE && |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 state)); | 702 state)); |
693 } | 703 } |
694 | 704 |
695 void MediaCaptureDevicesDispatcher::OnCreatingAudioStreamOnUIThread( | 705 void MediaCaptureDevicesDispatcher::OnCreatingAudioStreamOnUIThread( |
696 int render_process_id, | 706 int render_process_id, |
697 int render_view_id) { | 707 int render_view_id) { |
698 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 708 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
699 FOR_EACH_OBSERVER(Observer, observers_, | 709 FOR_EACH_OBSERVER(Observer, observers_, |
700 OnCreatingAudioStream(render_process_id, render_view_id)); | 710 OnCreatingAudioStream(render_process_id, render_view_id)); |
701 } | 711 } |
OLD | NEW |