Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc

Issue 2428383008: Bug Fix: Desktop Capture Picker Not Modal (Closed)
Patch Set: Fix by comment Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 if (!parent_window) {
Sergey Ulanov 2016/10/26 17:08:08 Please add a comment here to explain why we need t
qiangchen 2016/10/26 18:39:17 Done.
123 Browser* target_browser = chrome::FindLastActive();
Sergey Ulanov 2016/10/26 17:08:08 I think it's best to use chrome::FindLastActiveWit
qiangchen 2016/10/26 18:39:17 Done.
124
125 if (target_browser)
126 parent_window = target_browser->window()->GetNativeWindow();
127 }
121 std::unique_ptr<DesktopMediaList> screen_list; 128 std::unique_ptr<DesktopMediaList> screen_list;
122 std::unique_ptr<DesktopMediaList> window_list; 129 std::unique_ptr<DesktopMediaList> window_list;
123 std::unique_ptr<DesktopMediaList> tab_list; 130 std::unique_ptr<DesktopMediaList> tab_list;
124 if (g_picker_factory) { 131 if (g_picker_factory) {
125 PickerFactory::MediaListArray media_lists = 132 PickerFactory::MediaListArray media_lists =
126 g_picker_factory->CreateModel(show_screens, show_windows, show_tabs, 133 g_picker_factory->CreateModel(show_screens, show_windows, show_tabs,
127 request_audio); 134 request_audio);
128 screen_list = std::move(media_lists[0]); 135 screen_list = std::move(media_lists[0]);
129 window_list = std::move(media_lists[1]); 136 window_list = std::move(media_lists[1]);
130 tab_list = std::move(media_lists[2]); 137 tab_list = std::move(media_lists[2]);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 280
274 void DesktopCaptureRequestsRegistry::CancelRequest(int process_id, 281 void DesktopCaptureRequestsRegistry::CancelRequest(int process_id,
275 int request_id) { 282 int request_id) {
276 RequestsMap::iterator it = requests_.find(RequestId(process_id, request_id)); 283 RequestsMap::iterator it = requests_.find(RequestId(process_id, request_id));
277 if (it != requests_.end()) 284 if (it != requests_.end())
278 it->second->Cancel(); 285 it->second->Cancel();
279 } 286 }
280 287
281 288
282 } // namespace extensions 289 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698