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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/media/desktop_streams_registry.h" | 11 #include "chrome/browser/media/desktop_streams_registry.h" |
12 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 12 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_finder.h" | 14 #include "chrome/browser/ui/browser_finder.h" |
15 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
16 #include "chrome/browser/ui/screen_capture_notification_ui.h" | 16 #include "chrome/browser/ui/screen_capture_notification_ui.h" |
17 #include "chrome/browser/ui/simple_message_box.h" | 17 #include "chrome/browser/ui/simple_message_box.h" |
18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/grit/generated_resources.h" | 19 #include "chrome/grit/generated_resources.h" |
20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
21 #include "content/public/browser/desktop_media_id.h" | 21 #include "content/public/browser/desktop_media_id.h" |
22 #include "content/public/browser/render_frame_host.h" | 22 #include "content/public/browser/render_frame_host.h" |
23 #include "content/public/browser/render_process_host.h" | 23 #include "content/public/browser/render_process_host.h" |
24 #include "content/public/common/media_stream_request.h" | 24 #include "content/public/common/media_stream_request.h" |
| 25 #include "content/public/common/origin_util.h" |
25 #include "extensions/browser/app_window/app_window.h" | 26 #include "extensions/browser/app_window/app_window.h" |
26 #include "extensions/browser/app_window/app_window_registry.h" | 27 #include "extensions/browser/app_window/app_window_registry.h" |
27 #include "extensions/common/constants.h" | 28 #include "extensions/common/constants.h" |
28 #include "extensions/common/extension.h" | 29 #include "extensions/common/extension.h" |
29 #include "media/audio/audio_manager_base.h" | 30 #include "media/audio/audio_manager_base.h" |
30 #include "net/base/net_util.h" | 31 #include "net/base/net_util.h" |
31 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_types.h" | 32 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_types.h" |
32 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
33 | 34 |
34 #if defined(OS_CHROMEOS) | 35 #if defined(OS_CHROMEOS) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 base::string16 GetApplicationTitle(content::WebContents* web_contents, | 71 base::string16 GetApplicationTitle(content::WebContents* web_contents, |
71 const extensions::Extension* extension) { | 72 const extensions::Extension* extension) { |
72 // Use extension name as title for extensions and host/origin for drive-by | 73 // Use extension name as title for extensions and host/origin for drive-by |
73 // web. | 74 // web. |
74 std::string title; | 75 std::string title; |
75 if (extension) { | 76 if (extension) { |
76 title = extension->name(); | 77 title = extension->name(); |
77 return base::UTF8ToUTF16(title); | 78 return base::UTF8ToUTF16(title); |
78 } | 79 } |
79 GURL url = web_contents->GetURL(); | 80 GURL url = web_contents->GetURL(); |
80 title = url.SchemeIsSecure() ? net::GetHostAndOptionalPort(url) | 81 title = content::IsOriginSecure(url) ? net::GetHostAndOptionalPort(url) |
81 : url.GetOrigin().spec(); | 82 : url.GetOrigin().spec(); |
82 return base::UTF8ToUTF16(title); | 83 return base::UTF8ToUTF16(title); |
83 } | 84 } |
84 | 85 |
85 // Helper to get list of media stream devices for desktop capture in |devices|. | 86 // Helper to get list of media stream devices for desktop capture in |devices|. |
86 // Registers to display notification if |display_notification| is true. | 87 // Registers to display notification if |display_notification| is true. |
87 // Returns an instance of MediaStreamUI to be passed to content layer. | 88 // Returns an instance of MediaStreamUI to be passed to content layer. |
88 scoped_ptr<content::MediaStreamUI> GetDevicesForDesktopCapture( | 89 scoped_ptr<content::MediaStreamUI> GetDevicesForDesktopCapture( |
89 content::MediaStreamDevices* devices, | 90 content::MediaStreamDevices* devices, |
90 content::DesktopMediaID media_id, | 91 content::DesktopMediaID media_id, |
91 bool capture_audio, | 92 bool capture_audio, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 173 |
173 bool screen_capture_enabled = | 174 bool screen_capture_enabled = |
174 base::CommandLine::ForCurrentProcess()->HasSwitch( | 175 base::CommandLine::ForCurrentProcess()->HasSwitch( |
175 switches::kEnableUserMediaScreenCapturing) || | 176 switches::kEnableUserMediaScreenCapturing) || |
176 MediaCaptureDevicesDispatcher::IsOriginForCasting( | 177 MediaCaptureDevicesDispatcher::IsOriginForCasting( |
177 request.security_origin) || | 178 request.security_origin) || |
178 IsExtensionWhitelistedForScreenCapture(extension) || | 179 IsExtensionWhitelistedForScreenCapture(extension) || |
179 IsBuiltInExtension(request.security_origin); | 180 IsBuiltInExtension(request.security_origin); |
180 | 181 |
181 const bool origin_is_secure = | 182 const bool origin_is_secure = |
182 request.security_origin.SchemeIsSecure() || | 183 content::IsOriginSecure(request.security_origin) || |
183 request.security_origin.SchemeIs(extensions::kExtensionScheme) || | |
184 base::CommandLine::ForCurrentProcess()->HasSwitch( | 184 base::CommandLine::ForCurrentProcess()->HasSwitch( |
185 switches::kAllowHttpScreenCapture); | 185 switches::kAllowHttpScreenCapture); |
186 | 186 |
187 // If basic conditions (screen capturing is enabled and origin is secure) | 187 // If basic conditions (screen capturing is enabled and origin is secure) |
188 // aren't fulfilled, we'll use "invalid state" as result. Otherwise, we set | 188 // aren't fulfilled, we'll use "invalid state" as result. Otherwise, we set |
189 // it after checking permission. | 189 // it after checking permission. |
190 // TODO(grunell): It would be good to change this result for something else, | 190 // TODO(grunell): It would be good to change this result for something else, |
191 // probably a new one. | 191 // probably a new one. |
192 content::MediaStreamRequestResult result = | 192 content::MediaStreamRequestResult result = |
193 content::MEDIA_DEVICE_INVALID_STATE; | 193 content::MEDIA_DEVICE_INVALID_STATE; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 desktop_capture_sessions_.erase(it); | 379 desktop_capture_sessions_.erase(it); |
380 break; | 380 break; |
381 } | 381 } |
382 } | 382 } |
383 } | 383 } |
384 } | 384 } |
385 | 385 |
386 bool DesktopCaptureAccessHandler::IsCaptureInProgress() { | 386 bool DesktopCaptureAccessHandler::IsCaptureInProgress() { |
387 return desktop_capture_sessions_.size() > 0; | 387 return desktop_capture_sessions_.size() > 0; |
388 } | 388 } |
OLD | NEW |