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" |
11 #include "base/prefs/scoped_user_pref_update.h" | 11 #include "base/prefs/scoped_user_pref_update.h" |
12 #include "base/sha1.h" | 12 #include "base/sha1.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "chrome/browser/media/desktop_streams_registry.h" | 16 #include "chrome/browser/media/desktop_streams_registry.h" |
17 #include "chrome/browser/media/media_stream_capture_indicator.h" | 17 #include "chrome/browser/media/media_stream_capture_indicator.h" |
18 #include "chrome/browser/media/media_stream_device_permissions.h" | 18 #include "chrome/browser/media/media_stream_device_permissions.h" |
19 #include "chrome/browser/media/media_stream_infobar_delegate.h" | 19 #include "chrome/browser/media/media_stream_infobar_delegate.h" |
20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
22 #include "chrome/browser/ui/browser_finder.h" | 22 #include "chrome/browser/ui/browser_finder.h" |
23 #include "chrome/browser/ui/browser_window.h" | 23 #include "chrome/browser/ui/browser_window.h" |
24 #include "chrome/browser/ui/screen_capture_notification_ui.h" | 24 #include "chrome/browser/ui/screen_capture_notification_ui.h" |
25 #include "chrome/browser/ui/simple_message_box.h" | 25 #include "chrome/browser/ui/simple_message_box.h" |
26 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" | 26 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" |
27 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
28 #include "chrome/common/chrome_version_info.h" | 28 #include "chrome/common/chrome_version_info.h" |
| 29 #include "chrome/common/origin_util.h" |
29 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
30 #include "chrome/grit/generated_resources.h" | 31 #include "chrome/grit/generated_resources.h" |
31 #include "components/content_settings/core/browser/host_content_settings_map.h" | 32 #include "components/content_settings/core/browser/host_content_settings_map.h" |
32 #include "components/pref_registry/pref_registry_syncable.h" | 33 #include "components/pref_registry/pref_registry_syncable.h" |
33 #include "content/public/browser/browser_thread.h" | 34 #include "content/public/browser/browser_thread.h" |
34 #include "content/public/browser/desktop_media_id.h" | 35 #include "content/public/browser/desktop_media_id.h" |
35 #include "content/public/browser/media_capture_devices.h" | 36 #include "content/public/browser/media_capture_devices.h" |
36 #include "content/public/browser/notification_service.h" | 37 #include "content/public/browser/notification_service.h" |
37 #include "content/public/browser/notification_source.h" | 38 #include "content/public/browser/notification_source.h" |
38 #include "content/public/browser/notification_types.h" | 39 #include "content/public/browser/notification_types.h" |
(...skipping 121 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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 base::CommandLine::ForCurrentProcess()->HasSwitch( | 593 base::CommandLine::ForCurrentProcess()->HasSwitch( |
593 switches::kEnableUserMediaScreenCapturing); | 594 switches::kEnableUserMediaScreenCapturing); |
594 #if defined(ENABLE_EXTENSIONS) | 595 #if defined(ENABLE_EXTENSIONS) |
595 screen_capture_enabled |= | 596 screen_capture_enabled |= |
596 IsOriginForCasting(request.security_origin) || | 597 IsOriginForCasting(request.security_origin) || |
597 IsExtensionWhitelistedForScreenCapture(extension) || | 598 IsExtensionWhitelistedForScreenCapture(extension) || |
598 IsBuiltInExtension(request.security_origin); | 599 IsBuiltInExtension(request.security_origin); |
599 #endif | 600 #endif |
600 | 601 |
601 const bool origin_is_secure = | 602 const bool origin_is_secure = |
602 request.security_origin.SchemeIsSecure() || | 603 IsOriginSecure(request.security_origin) || |
603 request.security_origin.SchemeIs(extensions::kExtensionScheme) || | |
604 base::CommandLine::ForCurrentProcess()->HasSwitch( | 604 base::CommandLine::ForCurrentProcess()->HasSwitch( |
605 switches::kAllowHttpScreenCapture); | 605 switches::kAllowHttpScreenCapture); |
606 | 606 |
607 // If basic conditions (screen capturing is enabled and origin is secure) | 607 // If basic conditions (screen capturing is enabled and origin is secure) |
608 // aren't fulfilled, we'll use "invalid state" as result. Otherwise, we set | 608 // aren't fulfilled, we'll use "invalid state" as result. Otherwise, we set |
609 // it after checking permission. | 609 // it after checking permission. |
610 // TODO(grunell): It would be good to change this result for something else, | 610 // TODO(grunell): It would be good to change this result for something else, |
611 // probably a new one. | 611 // probably a new one. |
612 content::MediaStreamRequestResult result = | 612 content::MediaStreamRequestResult result = |
613 content::MEDIA_DEVICE_INVALID_STATE; | 613 content::MEDIA_DEVICE_INVALID_STATE; |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 | 1143 |
1144 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( | 1144 void MediaCaptureDevicesDispatcher::SetTestAudioCaptureDevices( |
1145 const MediaStreamDevices& devices) { | 1145 const MediaStreamDevices& devices) { |
1146 test_audio_devices_ = devices; | 1146 test_audio_devices_ = devices; |
1147 } | 1147 } |
1148 | 1148 |
1149 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( | 1149 void MediaCaptureDevicesDispatcher::SetTestVideoCaptureDevices( |
1150 const MediaStreamDevices& devices) { | 1150 const MediaStreamDevices& devices) { |
1151 test_video_devices_ = devices; | 1151 test_video_devices_ = devices; |
1152 } | 1152 } |
OLD | NEW |