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

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: Modal 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/profiles/profile.h"
21 #include "chrome/browser/ui/browser_finder.h"
22 #include "chrome/browser/ui/tabs/tab_strip_model.h"
20 #include "components/version_info/version_info.h" 23 #include "components/version_info/version_info.h"
21 #include "content/public/browser/render_frame_host.h" 24 #include "content/public/browser/render_frame_host.h"
22 #include "content/public/browser/render_process_host.h" 25 #include "content/public/browser/render_process_host.h"
23 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
24 #include "extensions/common/switches.h" 27 #include "extensions/common/switches.h"
25 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h" 28 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h"
26 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" 29 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h"
27 #include "third_party/webrtc/modules/desktop_capture/window_capturer.h" 30 #include "third_party/webrtc/modules/desktop_capture/window_capturer.h"
28 31
29 namespace extensions { 32 namespace extensions {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 request_audio = !has_flag; 112 request_audio = !has_flag;
110 break; 113 break;
111 } 114 }
112 } 115 }
113 116
114 if (!show_screens && !show_windows && !show_tabs) { 117 if (!show_screens && !show_windows && !show_tabs) {
115 error_ = kEmptySourcesListError; 118 error_ = kEmptySourcesListError;
116 return false; 119 return false;
117 } 120 }
118 121
119 const gfx::NativeWindow parent_window = 122 gfx::NativeWindow parent_window = web_contents->GetTopLevelNativeWindow();
120 web_contents->GetTopLevelNativeWindow(); 123 if (!parent_window) {
124 Browser* target_browser = chrome::FindAnyBrowser(
Sergey Ulanov 2016/10/24 21:37:31 I'm not sure this is the right thing to do. This b
qiangchen 2016/10/24 22:18:39 The chooseDesktopMedia is from the background Java
125 Profile::FromBrowserContext(web_contents->GetBrowserContext()), false);
126
127 content::WebContents* target_contents =
Sergey Ulanov 2016/10/24 21:37:31 I don't think you need to get target content. Inst
qiangchen 2016/10/24 22:18:39 Done.
128 target_browser->tab_strip_model()->GetActiveWebContents();
Sergey Ulanov 2016/10/24 21:37:31 Need to check that target_browser isn't nullptr.
qiangchen 2016/10/24 22:18:40 Done.
129
130 parent_window = target_contents->GetTopLevelNativeWindow();
131 }
121 std::unique_ptr<DesktopMediaList> screen_list; 132 std::unique_ptr<DesktopMediaList> screen_list;
122 std::unique_ptr<DesktopMediaList> window_list; 133 std::unique_ptr<DesktopMediaList> window_list;
123 std::unique_ptr<DesktopMediaList> tab_list; 134 std::unique_ptr<DesktopMediaList> tab_list;
124 if (g_picker_factory) { 135 if (g_picker_factory) {
125 PickerFactory::MediaListArray media_lists = 136 PickerFactory::MediaListArray media_lists =
126 g_picker_factory->CreateModel(show_screens, show_windows, show_tabs, 137 g_picker_factory->CreateModel(show_screens, show_windows, show_tabs,
127 request_audio); 138 request_audio);
128 screen_list = std::move(media_lists[0]); 139 screen_list = std::move(media_lists[0]);
129 window_list = std::move(media_lists[1]); 140 window_list = std::move(media_lists[1]);
130 tab_list = std::move(media_lists[2]); 141 tab_list = std::move(media_lists[2]);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 284
274 void DesktopCaptureRequestsRegistry::CancelRequest(int process_id, 285 void DesktopCaptureRequestsRegistry::CancelRequest(int process_id,
275 int request_id) { 286 int request_id) {
276 RequestsMap::iterator it = requests_.find(RequestId(process_id, request_id)); 287 RequestsMap::iterator it = requests_.find(RequestId(process_id, request_id));
277 if (it != requests_.end()) 288 if (it != requests_.end())
278 it->second->Cancel(); 289 it->second->Cancel();
279 } 290 }
280 291
281 292
282 } // namespace extensions 293 } // 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