Commit 172086a4 authored by Peter Boström's avatar Peter Boström Committed by Commit Bot

Fix DesktopMediaPickerViews positioning

Before this change DesktopMediaPickerViews would center itself on the
page (and be spoofable), which is in conflict with it being a web-modal
dialog that normally attaches to the location bar.

This change also removes the close-x which is out of place for web-modal
dialogs (and redundant with the existing close button).

Bug: chromium:896012
Change-Id: I6d87a626cb5a4a3f2af87667faa3b2a718905202
Reviewed-on: https://chromium-review.googlesource.com/c/1284755
Commit-Queue: Peter Boström <pbos@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600572}
parent 8efe49bb
...@@ -350,6 +350,10 @@ bool DesktopMediaPickerDialogView::Accept() { ...@@ -350,6 +350,10 @@ bool DesktopMediaPickerDialogView::Accept() {
return true; return true;
} }
bool DesktopMediaPickerDialogView::ShouldShowCloseButton() const {
return false;
}
void DesktopMediaPickerDialogView::DeleteDelegate() { void DesktopMediaPickerDialogView::DeleteDelegate() {
// If the dialog is being closed then notify the parent about it. // If the dialog is being closed then notify the parent about it.
if (parent_) if (parent_)
...@@ -377,12 +381,23 @@ void DesktopMediaPickerDialogView::SelectTab( ...@@ -377,12 +381,23 @@ void DesktopMediaPickerDialogView::SelectTab(
} }
void DesktopMediaPickerDialogView::OnMediaListRowsChanged() { void DesktopMediaPickerDialogView::OnMediaListRowsChanged() {
gfx::Rect widget_bound = GetWidget()->GetWindowBoundsInScreen(); PreferredSizeChanged();
// TODO(pbos): Ideally this would use shared logic similar to
int new_height = widget_bound.height() - pane_->height() + // BubbleDialogDelegateView::SizeToContents() instead of implementing sizing
pane_->GetPreferredSize().height(); // logic in-place.
const gfx::Size new_size = GetWidget()->GetRootView()->GetPreferredSize();
if (modality_ == ui::ModalType::MODAL_TYPE_CHILD) {
// For the web-modal dialog resize the dialog in place.
// TODO(pbos): This should ideally use UpdateWebContentsModalDialogPosition
// to keep the widget centered horizontally. As this dialog is fixed-width
// we're effectively only changing the height, so reusing the current
// widget origin should be equivalent.
GetWidget()->SetSize(new_size);
return;
}
GetWidget()->CenterWindow(gfx::Size(widget_bound.width(), new_height)); // When not using the web-modal dialog, center the dialog with its new size.
GetWidget()->CenterWindow(new_size);
} }
DesktopMediaListView* DesktopMediaPickerDialogView::GetMediaListViewForTesting() DesktopMediaListView* DesktopMediaPickerDialogView::GetMediaListViewForTesting()
......
...@@ -52,6 +52,7 @@ class DesktopMediaPickerDialogView : public views::DialogDelegateView, ...@@ -52,6 +52,7 @@ class DesktopMediaPickerDialogView : public views::DialogDelegateView,
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
View* CreateExtraView() override; View* CreateExtraView() override;
bool Accept() override; bool Accept() override;
bool ShouldShowCloseButton() const override;
void DeleteDelegate() override; void DeleteDelegate() override;
void OnMediaListRowsChanged(); void OnMediaListRowsChanged();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment