OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extensions/api/desktop_capture/desktop_capture_api.h" | 5 #include "chrome/browser/extensions/api/desktop_capture/desktop_capture_api.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/extensions/extension_tab_util.h" | 10 #include "chrome/browser/extensions/extension_tab_util.h" |
11 #include "chrome/browser/media/desktop_media_list_ash.h" | 11 #include "chrome/browser/media/desktop_media_list_ash.h" |
12 #include "chrome/browser/media/desktop_streams_registry.h" | 12 #include "chrome/browser/media/desktop_streams_registry.h" |
13 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 13 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
14 #include "chrome/browser/media/native_desktop_media_list.h" | 14 #include "chrome/browser/media/native_desktop_media_list.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/ash/ash_util.h" | 16 #include "chrome/browser/ui/ash/ash_util.h" |
17 #include "chrome/browser/ui/host_desktop.h" | 17 #include "chrome/browser/ui/host_desktop.h" |
18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/extensions/api/tabs.h" | 19 #include "chrome/common/extensions/api/tabs.h" |
20 #include "content/public/browser/render_frame_host.h" | 20 #include "content/public/browser/render_frame_host.h" |
21 #include "content/public/browser/render_process_host.h" | 21 #include "content/public/browser/render_process_host.h" |
22 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
24 #include "content/public/common/origin_util.h" | |
24 #include "net/base/net_util.h" | 25 #include "net/base/net_util.h" |
25 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h" | 26 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h" |
26 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" | 27 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" |
27 #include "third_party/webrtc/modules/desktop_capture/window_capturer.h" | 28 #include "third_party/webrtc/modules/desktop_capture/window_capturer.h" |
28 | 29 |
29 namespace extensions { | 30 namespace extensions { |
30 | 31 |
31 namespace { | 32 namespace { |
32 | 33 |
33 const char kInvalidSourceNameError[] = "Invalid source type specified."; | 34 const char kInvalidSourceNameError[] = "Invalid source type specified."; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 } | 101 } |
101 origin_ = GURL(*(params->target_tab->url)).GetOrigin(); | 102 origin_ = GURL(*(params->target_tab->url)).GetOrigin(); |
102 | 103 |
103 if (!origin_.is_valid()) { | 104 if (!origin_.is_valid()) { |
104 error_ = kInvalidOriginError; | 105 error_ = kInvalidOriginError; |
105 return false; | 106 return false; |
106 } | 107 } |
107 | 108 |
108 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 109 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
109 switches::kAllowHttpScreenCapture) && | 110 switches::kAllowHttpScreenCapture) && |
110 !origin_.SchemeIsSecure()) { | 111 !IsOriginSecure(origin_)) { |
111 error_ = kTabUrlNotSecure; | 112 error_ = kTabUrlNotSecure; |
112 return false; | 113 return false; |
113 } | 114 } |
114 target_name = base::UTF8ToUTF16(origin_.SchemeIsSecure() ? | 115 target_name = base::UTF8ToUTF16(IsOriginSecure(origin_) |
115 net::GetHostAndOptionalPort(origin_) : origin_.spec()); | 116 ? net::GetHostAndOptionalPort(origin_) |
felt
2015/05/09 15:14:27
did git cl format do this? the wrapping looks odd
lgarron
2015/05/12 01:53:08
Yeah, this is the result of `git cl format`.
I don
| |
117 : origin_.spec()); | |
116 | 118 |
117 if (!params->target_tab->id) { | 119 if (!params->target_tab->id) { |
118 error_ = kNoTabIdError; | 120 error_ = kNoTabIdError; |
119 return false; | 121 return false; |
120 } | 122 } |
121 | 123 |
122 if (!ExtensionTabUtil::GetTabById(*(params->target_tab->id), GetProfile(), | 124 if (!ExtensionTabUtil::GetTabById(*(params->target_tab->id), GetProfile(), |
123 true, NULL, NULL, &web_contents, NULL)) { | 125 true, NULL, NULL, &web_contents, NULL)) { |
124 error_ = kInvalidTabIdError; | 126 error_ = kInvalidTabIdError; |
125 return false; | 127 return false; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 | 298 |
297 void DesktopCaptureRequestsRegistry::CancelRequest(int process_id, | 299 void DesktopCaptureRequestsRegistry::CancelRequest(int process_id, |
298 int request_id) { | 300 int request_id) { |
299 RequestsMap::iterator it = requests_.find(RequestId(process_id, request_id)); | 301 RequestsMap::iterator it = requests_.find(RequestId(process_id, request_id)); |
300 if (it != requests_.end()) | 302 if (it != requests_.end()) |
301 it->second->Cancel(); | 303 it->second->Cancel(); |
302 } | 304 } |
303 | 305 |
304 | 306 |
305 } // namespace extensions | 307 } // namespace extensions |
OLD | NEW |