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

Unified Diff: chrome/browser/ui/views/desktop_media_picker_views.cc

Issue 307453010: Fix a crash when chooseDesktopMedia is called with no target tab (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 7 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
Index: chrome/browser/ui/views/desktop_media_picker_views.cc
diff --git a/chrome/browser/ui/views/desktop_media_picker_views.cc b/chrome/browser/ui/views/desktop_media_picker_views.cc
index 30f5ed1a7f7fcf42f24eea8bd04a2614946544f4..f8badc4fbdd33f0c8fc4d7da493cac9fa67cf9fa 100644
--- a/chrome/browser/ui/views/desktop_media_picker_views.cc
+++ b/chrome/browser/ui/views/desktop_media_picker_views.cc
@@ -518,15 +518,25 @@ DesktopMediaPickerDialogView::DesktopMediaPickerDialogView(
scroll_view_->SetContents(list_view_);
AddChildView(scroll_view_);
- WebContentsModalDialogManager* web_contents_modal_dialog_manager =
- WebContentsModalDialogManager::FromWebContents(parent_web_contents);
- DCHECK(web_contents_modal_dialog_manager);
- WebContentsModalDialogManagerDelegate* delegate =
- web_contents_modal_dialog_manager->delegate();
- DCHECK(delegate);
- views::Widget::CreateWindowAsFramelessChild(
- this,
- delegate->GetWebContentsModalDialogHost()->GetHostView());
+ // If |parent_web_contents| is set, the picker will be shown modal to the
+ // web contents. Otherwise, a new dialog widget inside |parent_window| will be
+ // created for the picker. Note that |parent_window| may also be NULL if
+ // parent web contents is not set. In this case the picker will be parented
+ // by a root window.
+ WebContentsModalDialogManager* web_contents_modal_dialog_manager = NULL;
+ if (parent_web_contents) {
+ web_contents_modal_dialog_manager =
+ WebContentsModalDialogManager::FromWebContents(parent_web_contents);
+ DCHECK(web_contents_modal_dialog_manager);
+ WebContentsModalDialogManagerDelegate* delegate =
+ web_contents_modal_dialog_manager->delegate();
+ DCHECK(delegate);
+ views::Widget::CreateWindowAsFramelessChild(
+ this,
+ delegate->GetWebContentsModalDialogHost()->GetHostView());
+ } else {
+ DialogDelegate::CreateDialogWidget(this, context, parent_window);
+ }
// DesktopMediaList needs to know the ID of the picker window which
// matches the ID it gets from the OS. Depending on the OS and configuration
@@ -547,8 +557,12 @@ DesktopMediaPickerDialogView::DesktopMediaPickerDialogView(
list_view_->StartUpdating(dialog_window_id);
- web_contents_modal_dialog_manager->ShowModalDialog(
- GetWidget()->GetNativeView());
+ if (parent_web_contents) {
+ web_contents_modal_dialog_manager->ShowModalDialog(
+ GetWidget()->GetNativeView());
+ } else {
+ GetWidget()->Show();
+ }
}
DesktopMediaPickerDialogView::~DesktopMediaPickerDialogView() {}

Powered by Google App Engine
This is Rietveld 408576698