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/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
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/render_process_host.h" | 40 #include "content/public/browser/render_process_host.h" |
41 #include "content/public/browser/web_contents.h" | 41 #include "content/public/browser/web_contents.h" |
42 #include "content/public/common/media_stream_request.h" | 42 #include "content/public/common/media_stream_request.h" |
| 43 #include "content/public/common/origin_util.h" |
43 #include "extensions/common/constants.h" | 44 #include "extensions/common/constants.h" |
44 #include "media/audio/audio_manager_base.h" | 45 #include "media/audio/audio_manager_base.h" |
45 #include "media/base/media_switches.h" | 46 #include "media/base/media_switches.h" |
46 #include "net/base/net_util.h" | 47 #include "net/base/net_util.h" |
47 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_types.h" | 48 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_types.h" |
48 #include "ui/base/l10n/l10n_util.h" | 49 #include "ui/base/l10n/l10n_util.h" |
49 | 50 |
50 #if defined(OS_CHROMEOS) | 51 #if defined(OS_CHROMEOS) |
51 #include "ash/shell.h" | 52 #include "ash/shell.h" |
52 #endif // defined(OS_CHROMEOS) | 53 #endif // defined(OS_CHROMEOS) |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 // Use extension name as title for extensions and host/origin for drive-by | 161 // Use extension name as title for extensions and host/origin for drive-by |
161 // web. | 162 // web. |
162 std::string title; | 163 std::string title; |
163 #if defined(ENABLE_EXTENSIONS) | 164 #if defined(ENABLE_EXTENSIONS) |
164 if (extension) { | 165 if (extension) { |
165 title = extension->name(); | 166 title = extension->name(); |
166 return base::UTF8ToUTF16(title); | 167 return base::UTF8ToUTF16(title); |
167 } | 168 } |
168 #endif | 169 #endif |
169 GURL url = web_contents->GetURL(); | 170 GURL url = web_contents->GetURL(); |
170 title = url.SchemeIsSecure() ? net::GetHostAndOptionalPort(url) | 171 title = IsOriginSecure(url) ? net::GetHostAndOptionalPort(url) |
171 : url.GetOrigin().spec(); | 172 : url.GetOrigin().spec(); |
172 return base::UTF8ToUTF16(title); | 173 return base::UTF8ToUTF16(title); |
173 } | 174 } |
174 | 175 |
175 // Helper to get list of media stream devices for desktop capture in |devices|. | 176 // Helper to get list of media stream devices for desktop capture in |devices|. |
176 // Registers to display notification if |display_notification| is true. | 177 // Registers to display notification if |display_notification| is true. |
177 // Returns an instance of MediaStreamUI to be passed to content layer. | 178 // Returns an instance of MediaStreamUI to be passed to content layer. |
178 scoped_ptr<content::MediaStreamUI> GetDevicesForDesktopCapture( | 179 scoped_ptr<content::MediaStreamUI> GetDevicesForDesktopCapture( |
179 content::MediaStreamDevices* devices, | 180 content::MediaStreamDevices* devices, |
180 content::DesktopMediaID media_id, | 181 content::DesktopMediaID media_id, |
181 bool capture_audio, | 182 bool capture_audio, |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 base::CommandLine::ForCurrentProcess()->HasSwitch( | 589 base::CommandLine::ForCurrentProcess()->HasSwitch( |
589 switches::kEnableUserMediaScreenCapturing); | 590 switches::kEnableUserMediaScreenCapturing); |
590 #if defined(ENABLE_EXTENSIONS) | 591 #if defined(ENABLE_EXTENSIONS) |
591 screen_capture_enabled |= | 592 screen_capture_enabled |= |
592 IsOriginForCasting(request.security_origin) || | 593 IsOriginForCasting(request.security_origin) || |
593 IsExtensionWhitelistedForScreenCapture(extension) || | 594 IsExtensionWhitelistedForScreenCapture(extension) || |
594 IsBuiltInExtension(request.security_origin); | 595 IsBuiltInExtension(request.security_origin); |
595 #endif | 596 #endif |
596 | 597 |
597 const bool origin_is_secure = | 598 const bool origin_is_secure = |
598 request.security_origin.SchemeIsSecure() || | 599 IsOriginSecure(request.security_origin) || |
599 request.security_origin.SchemeIs(extensions::kExtensionScheme) || | |
600 base::CommandLine::ForCurrentProcess()->HasSwitch( | 600 base::CommandLine::ForCurrentProcess()->HasSwitch( |
601 switches::kAllowHttpScreenCapture); | 601 switches::kAllowHttpScreenCapture); |
602 | 602 |
603 // If basic conditions (screen capturing is enabled and origin is secure) | 603 // If basic conditions (screen capturing is enabled and origin is secure) |
604 // aren't fulfilled, we'll use "invalid state" as result. Otherwise, we set | 604 // aren't fulfilled, we'll use "invalid state" as result. Otherwise, we set |
605 // it after checking permission. | 605 // it after checking permission. |
606 // TODO(grunell): It would be good to change this result for something else, | 606 // TODO(grunell): It would be good to change this result for something else, |
607 // probably a new one. | 607 // probably a new one. |
608 content::MediaStreamRequestResult result = | 608 content::MediaStreamRequestResult result = |
609 content::MEDIA_DEVICE_INVALID_STATE; | 609 content::MEDIA_DEVICE_INVALID_STATE; |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1139 | 1139 |
1140 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( | 1140 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( |
1141 const MediaStreamDevices& devices) { | 1141 const MediaStreamDevices& devices) { |
1142 test_audio_devices_ = devices; | 1142 test_audio_devices_ = devices; |
1143 } | 1143 } |
1144 | 1144 |
1145 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( | 1145 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( |
1146 const MediaStreamDevices& devices) { | 1146 const MediaStreamDevices& devices) { |
1147 test_video_devices_ = devices; | 1147 test_video_devices_ = devices; |
1148 } | 1148 } |
OLD | NEW |