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