| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/desktop_capture_access_handler.h" | 5 #include "chrome/browser/media/desktop_capture_access_handler.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "content/public/browser/desktop_media_id.h" | 24 #include "content/public/browser/desktop_media_id.h" |
| 25 #include "content/public/browser/render_frame_host.h" | 25 #include "content/public/browser/render_frame_host.h" |
| 26 #include "content/public/browser/render_process_host.h" | 26 #include "content/public/browser/render_process_host.h" |
| 27 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
| 28 #include "content/public/common/media_stream_request.h" | 28 #include "content/public/common/media_stream_request.h" |
| 29 #include "content/public/common/origin_util.h" | 29 #include "content/public/common/origin_util.h" |
| 30 #include "extensions/browser/app_window/app_window.h" | 30 #include "extensions/browser/app_window/app_window.h" |
| 31 #include "extensions/browser/app_window/app_window_registry.h" | 31 #include "extensions/browser/app_window/app_window_registry.h" |
| 32 #include "extensions/common/constants.h" | 32 #include "extensions/common/constants.h" |
| 33 #include "extensions/common/extension.h" | 33 #include "extensions/common/extension.h" |
| 34 #include "extensions/common/switches.h" |
| 34 #include "media/audio/audio_manager_base.h" | 35 #include "media/audio/audio_manager_base.h" |
| 35 #include "net/base/url_util.h" | 36 #include "net/base/url_util.h" |
| 36 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_types.h" | 37 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_types.h" |
| 37 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
| 38 | 39 |
| 39 #if defined(OS_CHROMEOS) | 40 #if defined(OS_CHROMEOS) |
| 40 #include "ash/shell.h" | 41 #include "ash/shell.h" |
| 41 #include "base/sha1.h" | 42 #include "base/sha1.h" |
| 42 #endif // defined(OS_CHROMEOS) | 43 #endif // defined(OS_CHROMEOS) |
| 43 | 44 |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 callback.Run(devices, content::MEDIA_DEVICE_INVALID_STATE, std::move(ui)); | 337 callback.Run(devices, content::MEDIA_DEVICE_INVALID_STATE, std::move(ui)); |
| 337 return; | 338 return; |
| 338 } | 339 } |
| 339 | 340 |
| 340 bool loopback_audio_supported = false; | 341 bool loopback_audio_supported = false; |
| 341 #if defined(USE_CRAS) || defined(OS_WIN) | 342 #if defined(USE_CRAS) || defined(OS_WIN) |
| 342 // Currently loopback audio capture is supported only on Windows and ChromeOS. | 343 // Currently loopback audio capture is supported only on Windows and ChromeOS. |
| 343 loopback_audio_supported = true; | 344 loopback_audio_supported = true; |
| 344 #endif | 345 #endif |
| 345 | 346 |
| 346 // Audio is only supported for screen capture streams. | 347 // This value essentially from the checkbox on picker window, so it |
| 348 // corresponds to user permission. |
| 349 bool audio_permitted = media_id.audio_share; |
| 350 |
| 351 // This value essentially from whether getUserMedia requests audio stream. |
| 352 bool audio_requested = |
| 353 request.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE; |
| 354 |
| 355 // This value shows for a given capture type, whether the system or our code |
| 356 // can support audio sharing. Currently audio is only supported for screen |
| 357 // capture streams. |
| 358 bool audio_supported = |
| 359 media_id.type == content::DesktopMediaID::TYPE_SCREEN && |
| 360 loopback_audio_supported; |
| 361 |
| 362 bool has_flag = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 363 extensions::switches::kEnableDesktopCaptureAudio); |
| 347 bool capture_audio = | 364 bool capture_audio = |
| 348 (media_id.type == content::DesktopMediaID::TYPE_SCREEN && | 365 (has_flag ? audio_permitted : true) && audio_requested && audio_supported; |
| 349 request.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE && | |
| 350 loopback_audio_supported); | |
| 351 | 366 |
| 352 ui = GetDevicesForDesktopCapture(&devices, media_id, capture_audio, true, | 367 ui = GetDevicesForDesktopCapture(&devices, media_id, capture_audio, true, |
| 353 GetApplicationTitle(web_contents, extension), | 368 GetApplicationTitle(web_contents, extension), |
| 354 base::UTF8ToUTF16(original_extension_name)); | 369 base::UTF8ToUTF16(original_extension_name)); |
| 355 | 370 |
| 356 callback.Run(devices, content::MEDIA_DEVICE_OK, std::move(ui)); | 371 callback.Run(devices, content::MEDIA_DEVICE_OK, std::move(ui)); |
| 357 } | 372 } |
| 358 | 373 |
| 359 void DesktopCaptureAccessHandler::UpdateMediaRequestState( | 374 void DesktopCaptureAccessHandler::UpdateMediaRequestState( |
| 360 int render_process_id, | 375 int render_process_id, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 383 desktop_capture_sessions_.erase(it); | 398 desktop_capture_sessions_.erase(it); |
| 384 break; | 399 break; |
| 385 } | 400 } |
| 386 } | 401 } |
| 387 } | 402 } |
| 388 } | 403 } |
| 389 | 404 |
| 390 bool DesktopCaptureAccessHandler::IsCaptureInProgress() { | 405 bool DesktopCaptureAccessHandler::IsCaptureInProgress() { |
| 391 return desktop_capture_sessions_.size() > 0; | 406 return desktop_capture_sessions_.size() > 0; |
| 392 } | 407 } |
| OLD | NEW |