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/extensions/api/desktop_capture/desktop_capture_base.h" | 5 #include "chrome/browser/extensions/api/desktop_capture/desktop_capture_base.h" |
6 | 6 |
7 #include <tuple> | 7 #include <tuple> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "chrome/browser/extensions/extension_tab_util.h" | 14 #include "chrome/browser/extensions/extension_tab_util.h" |
15 #include "chrome/browser/media/webrtc/desktop_media_list_ash.h" | 15 #include "chrome/browser/media/webrtc/desktop_media_list_ash.h" |
16 #include "chrome/browser/media/webrtc/desktop_streams_registry.h" | 16 #include "chrome/browser/media/webrtc/desktop_streams_registry.h" |
17 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" | 17 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" |
18 #include "chrome/browser/media/webrtc/native_desktop_media_list.h" | 18 #include "chrome/browser/media/webrtc/native_desktop_media_list.h" |
19 #include "chrome/browser/media/webrtc/tab_desktop_media_list.h" | 19 #include "chrome/browser/media/webrtc/tab_desktop_media_list.h" |
20 #include "chrome/browser/ui/browser_finder.h" | |
21 #include "chrome/browser/ui/browser_window.h" | |
20 #include "components/version_info/version_info.h" | 22 #include "components/version_info/version_info.h" |
21 #include "content/public/browser/render_frame_host.h" | 23 #include "content/public/browser/render_frame_host.h" |
22 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
23 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
24 #include "extensions/common/switches.h" | 26 #include "extensions/common/switches.h" |
25 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h" | 27 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h" |
26 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" | 28 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" |
27 #include "third_party/webrtc/modules/desktop_capture/window_capturer.h" | 29 #include "third_party/webrtc/modules/desktop_capture/window_capturer.h" |
28 | 30 |
29 namespace extensions { | 31 namespace extensions { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 request_audio = !has_flag; | 111 request_audio = !has_flag; |
110 break; | 112 break; |
111 } | 113 } |
112 } | 114 } |
113 | 115 |
114 if (!show_screens && !show_windows && !show_tabs) { | 116 if (!show_screens && !show_windows && !show_tabs) { |
115 error_ = kEmptySourcesListError; | 117 error_ = kEmptySourcesListError; |
116 return false; | 118 return false; |
117 } | 119 } |
118 | 120 |
119 const gfx::NativeWindow parent_window = | 121 gfx::NativeWindow parent_window = web_contents->GetTopLevelNativeWindow(); |
120 web_contents->GetTopLevelNativeWindow(); | 122 // In case of background Javascript, |parent_window| will be null. We are |
Sergey Ulanov
2016/10/26 19:19:44
s/of background Javascript/the call comes from a b
qiangchen
2016/10/26 19:42:23
Done.
| |
123 // going to make the picker modal to the current browser window. | |
124 if (!parent_window) { | |
125 Browser* target_browser = chrome::FindLastActiveWithProfile( | |
126 Profile::FromBrowserContext(web_contents->GetBrowserContext())); | |
127 | |
128 if (target_browser) | |
129 parent_window = target_browser->window()->GetNativeWindow(); | |
130 } | |
121 std::unique_ptr<DesktopMediaList> screen_list; | 131 std::unique_ptr<DesktopMediaList> screen_list; |
122 std::unique_ptr<DesktopMediaList> window_list; | 132 std::unique_ptr<DesktopMediaList> window_list; |
123 std::unique_ptr<DesktopMediaList> tab_list; | 133 std::unique_ptr<DesktopMediaList> tab_list; |
124 if (g_picker_factory) { | 134 if (g_picker_factory) { |
125 PickerFactory::MediaListArray media_lists = | 135 PickerFactory::MediaListArray media_lists = |
126 g_picker_factory->CreateModel(show_screens, show_windows, show_tabs, | 136 g_picker_factory->CreateModel(show_screens, show_windows, show_tabs, |
127 request_audio); | 137 request_audio); |
128 screen_list = std::move(media_lists[0]); | 138 screen_list = std::move(media_lists[0]); |
129 window_list = std::move(media_lists[1]); | 139 window_list = std::move(media_lists[1]); |
130 tab_list = std::move(media_lists[2]); | 140 tab_list = std::move(media_lists[2]); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 | 283 |
274 void DesktopCaptureRequestsRegistry::CancelRequest(int process_id, | 284 void DesktopCaptureRequestsRegistry::CancelRequest(int process_id, |
275 int request_id) { | 285 int request_id) { |
276 RequestsMap::iterator it = requests_.find(RequestId(process_id, request_id)); | 286 RequestsMap::iterator it = requests_.find(RequestId(process_id, request_id)); |
277 if (it != requests_.end()) | 287 if (it != requests_.end()) |
278 it->second->Cancel(); | 288 it->second->Cancel(); |
279 } | 289 } |
280 | 290 |
281 | 291 |
282 } // namespace extensions | 292 } // namespace extensions |
OLD | NEW |