| 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 "apps/app_window.h" | 7 #include "apps/app_window.h" |
| 8 #include "apps/app_window_registry.h" | 8 #include "apps/app_window_registry.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "content/public/browser/desktop_media_id.h" | 34 #include "content/public/browser/desktop_media_id.h" |
| 35 #include "content/public/browser/media_capture_devices.h" | 35 #include "content/public/browser/media_capture_devices.h" |
| 36 #include "content/public/browser/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
| 37 #include "content/public/browser/notification_source.h" | 37 #include "content/public/browser/notification_source.h" |
| 38 #include "content/public/browser/notification_types.h" | 38 #include "content/public/browser/notification_types.h" |
| 39 #include "content/public/browser/render_frame_host.h" | 39 #include "content/public/browser/render_frame_host.h" |
| 40 #include "content/public/browser/web_contents.h" | 40 #include "content/public/browser/web_contents.h" |
| 41 #include "content/public/common/media_stream_request.h" | 41 #include "content/public/common/media_stream_request.h" |
| 42 #include "extensions/common/constants.h" | 42 #include "extensions/common/constants.h" |
| 43 #include "extensions/common/extension.h" | 43 #include "extensions/common/extension.h" |
| 44 #include "extensions/common/permissions/permissions_data.h" |
| 44 #include "grit/generated_resources.h" | 45 #include "grit/generated_resources.h" |
| 45 #include "media/audio/audio_manager_base.h" | 46 #include "media/audio/audio_manager_base.h" |
| 46 #include "media/base/media_switches.h" | 47 #include "media/base/media_switches.h" |
| 47 #include "net/base/net_util.h" | 48 #include "net/base/net_util.h" |
| 48 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_types.h" | 49 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_types.h" |
| 49 #include "ui/base/l10n/l10n_util.h" | 50 #include "ui/base/l10n/l10n_util.h" |
| 50 | 51 |
| 51 #if defined(OS_CHROMEOS) | 52 #if defined(OS_CHROMEOS) |
| 52 #include "ash/shell.h" | 53 #include "ash/shell.h" |
| 53 #endif // defined(OS_CHROMEOS) | 54 #endif // defined(OS_CHROMEOS) |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 NOTREACHED(); | 544 NOTREACHED(); |
| 544 callback.Run(devices, content::MEDIA_DEVICE_INVALID_STATE, ui.Pass()); | 545 callback.Run(devices, content::MEDIA_DEVICE_INVALID_STATE, ui.Pass()); |
| 545 return; | 546 return; |
| 546 } | 547 } |
| 547 bool tab_capture_allowed = | 548 bool tab_capture_allowed = |
| 548 tab_capture_registry->VerifyRequest(request.render_process_id, | 549 tab_capture_registry->VerifyRequest(request.render_process_id, |
| 549 request.render_view_id); | 550 request.render_view_id); |
| 550 | 551 |
| 551 if (request.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE && | 552 if (request.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE && |
| 552 tab_capture_allowed && | 553 tab_capture_allowed && |
| 553 extension->HasAPIPermission(extensions::APIPermission::kTabCapture)) { | 554 extension->permissions_data()->HasAPIPermission( |
| 555 extensions::APIPermission::kTabCapture)) { |
| 554 devices.push_back(content::MediaStreamDevice( | 556 devices.push_back(content::MediaStreamDevice( |
| 555 content::MEDIA_TAB_AUDIO_CAPTURE, std::string(), std::string())); | 557 content::MEDIA_TAB_AUDIO_CAPTURE, std::string(), std::string())); |
| 556 } | 558 } |
| 557 | 559 |
| 558 if (request.video_type == content::MEDIA_TAB_VIDEO_CAPTURE && | 560 if (request.video_type == content::MEDIA_TAB_VIDEO_CAPTURE && |
| 559 tab_capture_allowed && | 561 tab_capture_allowed && |
| 560 extension->HasAPIPermission(extensions::APIPermission::kTabCapture)) { | 562 extension->permissions_data()->HasAPIPermission( |
| 563 extensions::APIPermission::kTabCapture)) { |
| 561 devices.push_back(content::MediaStreamDevice( | 564 devices.push_back(content::MediaStreamDevice( |
| 562 content::MEDIA_TAB_VIDEO_CAPTURE, std::string(), std::string())); | 565 content::MEDIA_TAB_VIDEO_CAPTURE, std::string(), std::string())); |
| 563 } | 566 } |
| 564 | 567 |
| 565 if (!devices.empty()) { | 568 if (!devices.empty()) { |
| 566 ui = media_stream_capture_indicator_->RegisterMediaStream( | 569 ui = media_stream_capture_indicator_->RegisterMediaStream( |
| 567 web_contents, devices); | 570 web_contents, devices); |
| 568 } | 571 } |
| 569 callback.Run( | 572 callback.Run( |
| 570 devices, | 573 devices, |
| 571 devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE : | 574 devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE : |
| 572 content::MEDIA_DEVICE_OK, | 575 content::MEDIA_DEVICE_OK, |
| 573 ui.Pass()); | 576 ui.Pass()); |
| 574 #endif // !defined(OS_ANDROID) | 577 #endif // !defined(OS_ANDROID) |
| 575 } | 578 } |
| 576 | 579 |
| 577 void MediaCaptureDevicesDispatcher:: | 580 void MediaCaptureDevicesDispatcher:: |
| 578 ProcessMediaAccessRequestFromPlatformAppOrExtension( | 581 ProcessMediaAccessRequestFromPlatformAppOrExtension( |
| 579 content::WebContents* web_contents, | 582 content::WebContents* web_contents, |
| 580 const content::MediaStreamRequest& request, | 583 const content::MediaStreamRequest& request, |
| 581 const content::MediaResponseCallback& callback, | 584 const content::MediaResponseCallback& callback, |
| 582 const extensions::Extension* extension) { | 585 const extensions::Extension* extension) { |
| 583 content::MediaStreamDevices devices; | 586 content::MediaStreamDevices devices; |
| 584 Profile* profile = | 587 Profile* profile = |
| 585 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 588 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 586 | 589 |
| 587 if (request.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE && | 590 if (request.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE && |
| 588 extension->HasAPIPermission(extensions::APIPermission::kAudioCapture)) { | 591 extension->permissions_data()->HasAPIPermission( |
| 592 extensions::APIPermission::kAudioCapture)) { |
| 589 GetDefaultDevicesForProfile(profile, true, false, &devices); | 593 GetDefaultDevicesForProfile(profile, true, false, &devices); |
| 590 } | 594 } |
| 591 | 595 |
| 592 if (request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE && | 596 if (request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE && |
| 593 extension->HasAPIPermission(extensions::APIPermission::kVideoCapture)) { | 597 extension->permissions_data()->HasAPIPermission( |
| 598 extensions::APIPermission::kVideoCapture)) { |
| 594 GetDefaultDevicesForProfile(profile, false, true, &devices); | 599 GetDefaultDevicesForProfile(profile, false, true, &devices); |
| 595 } | 600 } |
| 596 | 601 |
| 597 scoped_ptr<content::MediaStreamUI> ui; | 602 scoped_ptr<content::MediaStreamUI> ui; |
| 598 if (!devices.empty()) { | 603 if (!devices.empty()) { |
| 599 ui = media_stream_capture_indicator_->RegisterMediaStream( | 604 ui = media_stream_capture_indicator_->RegisterMediaStream( |
| 600 web_contents, devices); | 605 web_contents, devices); |
| 601 } | 606 } |
| 602 callback.Run( | 607 callback.Run( |
| 603 devices, | 608 devices, |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 | 968 |
| 964 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( | 969 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( |
| 965 const MediaStreamDevices& devices) { | 970 const MediaStreamDevices& devices) { |
| 966 test_audio_devices_ = devices; | 971 test_audio_devices_ = devices; |
| 967 } | 972 } |
| 968 | 973 |
| 969 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( | 974 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( |
| 970 const MediaStreamDevices& devices) { | 975 const MediaStreamDevices& devices) { |
| 971 test_video_devices_ = devices; | 976 test_video_devices_ = devices; |
| 972 } | 977 } |
| OLD | NEW |