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

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

Issue 1576073003: Support Audio for Desktop Capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 11 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
OLDNEW
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"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
14 #include "chrome/browser/media/desktop_streams_registry.h" 15 #include "chrome/browser/media/desktop_streams_registry.h"
15 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 16 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
16 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/browser_finder.h" 18 #include "chrome/browser/ui/browser_finder.h"
18 #include "chrome/browser/ui/browser_window.h" 19 #include "chrome/browser/ui/browser_window.h"
19 #include "chrome/browser/ui/screen_capture_notification_ui.h" 20 #include "chrome/browser/ui/screen_capture_notification_ui.h"
20 #include "chrome/browser/ui/simple_message_box.h" 21 #include "chrome/browser/ui/simple_message_box.h"
21 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
22 #include "chrome/grit/generated_resources.h" 23 #include "chrome/grit/generated_resources.h"
24 #include "components/content_settings/core/browser/host_content_settings_map.h"
25 #include "components/content_settings/core/common/content_settings.h"
23 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/desktop_media_id.h" 27 #include "content/public/browser/desktop_media_id.h"
25 #include "content/public/browser/render_frame_host.h" 28 #include "content/public/browser/render_frame_host.h"
26 #include "content/public/browser/render_process_host.h" 29 #include "content/public/browser/render_process_host.h"
27 #include "content/public/common/content_switches.h" 30 #include "content/public/common/content_switches.h"
28 #include "content/public/common/media_stream_request.h" 31 #include "content/public/common/media_stream_request.h"
29 #include "content/public/common/origin_util.h" 32 #include "content/public/common/origin_util.h"
30 #include "extensions/browser/app_window/app_window.h" 33 #include "extensions/browser/app_window/app_window.h"
31 #include "extensions/browser/app_window/app_window_registry.h" 34 #include "extensions/browser/app_window/app_window_registry.h"
32 #include "extensions/common/constants.h" 35 #include "extensions/common/constants.h"
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 callback.Run(devices, content::MEDIA_DEVICE_INVALID_STATE, std::move(ui)); 339 callback.Run(devices, content::MEDIA_DEVICE_INVALID_STATE, std::move(ui));
337 return; 340 return;
338 } 341 }
339 342
340 bool loopback_audio_supported = false; 343 bool loopback_audio_supported = false;
341 #if defined(USE_CRAS) || defined(OS_WIN) 344 #if defined(USE_CRAS) || defined(OS_WIN)
342 // Currently loopback audio capture is supported only on Windows and ChromeOS. 345 // Currently loopback audio capture is supported only on Windows and ChromeOS.
343 loopback_audio_supported = true; 346 loopback_audio_supported = true;
344 #endif 347 #endif
345 348
349 bool loopback_audio_permitted = true;
GeorgeZ 2016/01/15 16:37:55 Maybe use this flag for all audio share (such as t
qiangchen 2016/01/15 18:19:40 Done.
350
351 const bool audio_support_flag_for_desktop_share =
352 base::CommandLine::ForCurrentProcess()->HasSwitch(
353 switches::kEnableAudioSupportForDesktopShare);
354
355 if (audio_support_flag_for_desktop_share) {
356 Profile* profile =
357 Profile::FromBrowserContext(web_contents->GetBrowserContext());
358
359 GURL origin(web_contents->GetLastCommittedURL().GetOrigin());
360
361 ContentSetting result =
362 HostContentSettingsMapFactory::GetForProfile(profile)
363 ->GetContentSetting(
364 origin, origin,
365 ContentSettingsType::CONTENT_SETTINGS_TYPE_DESKTOP_AUDIO_SHARE,
366 std::string());
367
368 loopback_audio_permitted =
369 (result == ContentSetting::CONTENT_SETTING_ALLOW);
370 }
371
346 // Audio is only supported for screen capture streams. 372 // Audio is only supported for screen capture streams.
347 bool capture_audio = 373 bool capture_audio =
348 (media_id.type == content::DesktopMediaID::TYPE_SCREEN && 374 (media_id.type == content::DesktopMediaID::TYPE_SCREEN &&
349 request.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE && 375 request.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE &&
350 loopback_audio_supported); 376 loopback_audio_supported && loopback_audio_permitted);
351 377
352 ui = GetDevicesForDesktopCapture(&devices, media_id, capture_audio, true, 378 ui = GetDevicesForDesktopCapture(&devices, media_id, capture_audio, true,
353 GetApplicationTitle(web_contents, extension), 379 GetApplicationTitle(web_contents, extension),
354 base::UTF8ToUTF16(original_extension_name)); 380 base::UTF8ToUTF16(original_extension_name));
355 381
356 callback.Run(devices, content::MEDIA_DEVICE_OK, std::move(ui)); 382 callback.Run(devices, content::MEDIA_DEVICE_OK, std::move(ui));
357 } 383 }
358 384
359 void DesktopCaptureAccessHandler::UpdateMediaRequestState( 385 void DesktopCaptureAccessHandler::UpdateMediaRequestState(
360 int render_process_id, 386 int render_process_id,
(...skipping 22 matching lines...) Expand all
383 desktop_capture_sessions_.erase(it); 409 desktop_capture_sessions_.erase(it);
384 break; 410 break;
385 } 411 }
386 } 412 }
387 } 413 }
388 } 414 }
389 415
390 bool DesktopCaptureAccessHandler::IsCaptureInProgress() { 416 bool DesktopCaptureAccessHandler::IsCaptureInProgress() {
391 return desktop_capture_sessions_.size() > 0; 417 return desktop_capture_sessions_.size() > 0;
392 } 418 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698