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" | |
26 #include "extensions/browser/app_window/app_window.h" | 25 #include "extensions/browser/app_window/app_window.h" |
27 #include "extensions/browser/app_window/app_window_registry.h" | 26 #include "extensions/browser/app_window/app_window_registry.h" |
28 #include "extensions/common/constants.h" | 27 #include "extensions/common/constants.h" |
29 #include "extensions/common/extension.h" | 28 #include "extensions/common/extension.h" |
30 #include "media/audio/audio_manager_base.h" | 29 #include "media/audio/audio_manager_base.h" |
31 #include "net/base/net_util.h" | 30 #include "net/base/net_util.h" |
32 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_types.h" | 31 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_types.h" |
33 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
34 | 33 |
35 #if defined(OS_CHROMEOS) | 34 #if defined(OS_CHROMEOS) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 base::string16 GetApplicationTitle(content::WebContents* web_contents, | 70 base::string16 GetApplicationTitle(content::WebContents* web_contents, |
72 const extensions::Extension* extension) { | 71 const extensions::Extension* extension) { |
73 // 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 |
74 // web. | 73 // web. |
75 std::string title; | 74 std::string title; |
76 if (extension) { | 75 if (extension) { |
77 title = extension->name(); | 76 title = extension->name(); |
78 return base::UTF8ToUTF16(title); | 77 return base::UTF8ToUTF16(title); |
79 } | 78 } |
80 GURL url = web_contents->GetURL(); | 79 GURL url = web_contents->GetURL(); |
81 title = content::IsOriginSecure(url) ? net::GetHostAndOptionalPort(url) | 80 title = url.SchemeIsSecure() ? net::GetHostAndOptionalPort(url) |
82 : url.GetOrigin().spec(); | 81 : url.GetOrigin().spec(); |
83 return base::UTF8ToUTF16(title); | 82 return base::UTF8ToUTF16(title); |
84 } | 83 } |
85 | 84 |
86 // 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|. |
87 // Registers to display notification if |display_notification| is true. | 86 // Registers to display notification if |display_notification| is true. |
88 // Returns an instance of MediaStreamUI to be passed to content layer. | 87 // Returns an instance of MediaStreamUI to be passed to content layer. |
89 scoped_ptr<content::MediaStreamUI> GetDevicesForDesktopCapture( | 88 scoped_ptr<content::MediaStreamUI> GetDevicesForDesktopCapture( |
90 content::MediaStreamDevices* devices, | 89 content::MediaStreamDevices* devices, |
91 content::DesktopMediaID media_id, | 90 content::DesktopMediaID media_id, |
92 bool capture_audio, | 91 bool capture_audio, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 172 |
174 bool screen_capture_enabled = | 173 bool screen_capture_enabled = |
175 base::CommandLine::ForCurrentProcess()->HasSwitch( | 174 base::CommandLine::ForCurrentProcess()->HasSwitch( |
176 switches::kEnableUserMediaScreenCapturing) || | 175 switches::kEnableUserMediaScreenCapturing) || |
177 MediaCaptureDevicesDispatcher::IsOriginForCasting( | 176 MediaCaptureDevicesDispatcher::IsOriginForCasting( |
178 request.security_origin) || | 177 request.security_origin) || |
179 IsExtensionWhitelistedForScreenCapture(extension) || | 178 IsExtensionWhitelistedForScreenCapture(extension) || |
180 IsBuiltInExtension(request.security_origin); | 179 IsBuiltInExtension(request.security_origin); |
181 | 180 |
182 const bool origin_is_secure = | 181 const bool origin_is_secure = |
183 content::IsOriginSecure(request.security_origin) || | 182 request.security_origin.SchemeIsSecure() || |
| 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 |