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

Unified Diff: chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc

Issue 2428383008: Bug Fix: Desktop Capture Picker Not Modal (Closed)
Patch Set: Rebase Created 4 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc
diff --git a/chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc b/chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc
index 03c11362c2118931ec93d5da2468b61cd1425a93..7a0ba8cf565cff7bfc96e41aeb81f00e0b3f9652 100644
--- a/chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc
+++ b/chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc
@@ -17,6 +17,8 @@
#include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
#include "chrome/browser/media/webrtc/native_desktop_media_list.h"
#include "chrome/browser/media/webrtc/tab_desktop_media_list.h"
+#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/browser_window.h"
#include "chrome/grit/chromium_strings.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
@@ -118,8 +120,17 @@ bool DesktopCaptureChooseDesktopMediaFunctionBase::Execute(
return false;
}
- const gfx::NativeWindow parent_window =
- web_contents->GetTopLevelNativeWindow();
+ gfx::NativeWindow parent_window = web_contents->GetTopLevelNativeWindow();
+ // In case of coming from background extension page, |parent_window| will
+ // be null. We are going to make the picker modal to the current browser
+ // window.
+ if (!parent_window) {
+ Browser* target_browser = chrome::FindLastActiveWithProfile(
+ Profile::FromBrowserContext(web_contents->GetBrowserContext()));
+
+ if (target_browser)
+ parent_window = target_browser->window()->GetNativeWindow();
+ }
std::unique_ptr<DesktopMediaList> screen_list;
std::unique_ptr<DesktopMediaList> window_list;
std::unique_ptr<DesktopMediaList> tab_list;
« 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