Commit 5cb523d3 authored by Charlene Yan's avatar Charlene Yan Committed by Commit Bot

Make dialogs not draggable by default.

Updated a few known cases that should be draggable.

Bug: 930782
Change-Id: I09ba7e0a71097317d241042e16a89f28dd27f4a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1570126
Commit-Queue: Charlene Yan <cyan@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Reviewed-by: default avatarJoe Mason <joenotcharles@google.com>
Cr-Commit-Position: refs/heads/master@{#652665}
parent 12a26a1c
...@@ -122,6 +122,10 @@ bool ChromeCleanerRebootDialog::Close() { ...@@ -122,6 +122,10 @@ bool ChromeCleanerRebootDialog::Close() {
return true; return true;
} }
bool ChromeCleanerRebootDialog::IsDialogDraggable() const {
return true;
}
void ChromeCleanerRebootDialog::HandleDialogInteraction( void ChromeCleanerRebootDialog::HandleDialogInteraction(
DialogInteractionResult result) { DialogInteractionResult result) {
if (!dialog_controller_) if (!dialog_controller_)
......
...@@ -44,6 +44,7 @@ class ChromeCleanerRebootDialog : public views::DialogDelegateView { ...@@ -44,6 +44,7 @@ class ChromeCleanerRebootDialog : public views::DialogDelegateView {
bool Accept() override; bool Accept() override;
bool Cancel() override; bool Cancel() override;
bool Close() override; bool Close() override;
bool IsDialogDraggable() const override;
private: private:
enum class DialogInteractionResult { enum class DialogInteractionResult {
......
...@@ -388,6 +388,13 @@ bool ExtensionInstallDialogView::Accept() { ...@@ -388,6 +388,13 @@ bool ExtensionInstallDialogView::Accept() {
return true; return true;
} }
// parent_window() may be null if an upgrade permissions prompt is triggered
// when launching via a desktop shortcut. In that case, there is no browser
// window to move (which would move the dialog), so allow dragging in this case.
bool ExtensionInstallDialogView::IsDialogDraggable() const {
return !parent_window();
}
int ExtensionInstallDialogView::GetDialogButtons() const { int ExtensionInstallDialogView::GetDialogButtons() const {
int buttons = prompt_->GetDialogButtons(); int buttons = prompt_->GetDialogButtons();
// Simply having just an OK button is *not* supported. See comment on function // Simply having just an OK button is *not* supported. See comment on function
......
...@@ -58,6 +58,7 @@ class ExtensionInstallDialogView : public views::BubbleDialogDelegateView, ...@@ -58,6 +58,7 @@ class ExtensionInstallDialogView : public views::BubbleDialogDelegateView,
views::View* CreateExtraView() override; views::View* CreateExtraView() override;
bool Cancel() override; bool Cancel() override;
bool Accept() override; bool Accept() override;
bool IsDialogDraggable() const override;
int GetDialogButtons() const override; int GetDialogButtons() const override;
int GetDefaultDialogButton() const override; int GetDefaultDialogButton() const override;
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
......
...@@ -158,6 +158,10 @@ bool EnterpriseStartupDialogView::Close() { ...@@ -158,6 +158,10 @@ bool EnterpriseStartupDialogView::Close() {
return Cancel(); return Cancel();
} }
bool EnterpriseStartupDialogView::IsDialogDraggable() const {
return true;
}
bool EnterpriseStartupDialogView::ShouldShowWindowTitle() const { bool EnterpriseStartupDialogView::ShouldShowWindowTitle() const {
return false; return false;
} }
......
...@@ -44,6 +44,7 @@ class EnterpriseStartupDialogView : public views::DialogDelegateView { ...@@ -44,6 +44,7 @@ class EnterpriseStartupDialogView : public views::DialogDelegateView {
bool Accept() override; bool Accept() override;
bool Cancel() override; bool Cancel() override;
bool Close() override; bool Close() override;
bool IsDialogDraggable() const override;
bool ShouldShowWindowTitle() const override; bool ShouldShowWindowTitle() const override;
ui::ModalType GetModalType() const override; ui::ModalType GetModalType() const override;
views::View* CreateExtraView() override; views::View* CreateExtraView() override;
......
...@@ -192,8 +192,7 @@ int BubbleFrameView::NonClientHitTest(const gfx::Point& point) { ...@@ -192,8 +192,7 @@ int BubbleFrameView::NonClientHitTest(const gfx::Point& point) {
if (point.y() < title()->bounds().bottom()) { if (point.y() < title()->bounds().bottom()) {
auto* dialog_delegate = GetWidget()->widget_delegate()->AsDialogDelegate(); auto* dialog_delegate = GetWidget()->widget_delegate()->AsDialogDelegate();
// Allow the dialog to be dragged if it is not a bubble dialog. if (dialog_delegate && dialog_delegate->IsDialogDraggable()) {
if (dialog_delegate && !dialog_delegate->AsBubbleDialogDelegate()) {
return HTCAPTION; return HTCAPTION;
} }
} }
......
...@@ -151,6 +151,10 @@ bool DialogDelegate::Close() { ...@@ -151,6 +151,10 @@ bool DialogDelegate::Close() {
return Accept(); return Accept();
} }
bool DialogDelegate::IsDialogDraggable() const {
return false;
}
void DialogDelegate::UpdateButton(LabelButton* button, ui::DialogButton type) { void DialogDelegate::UpdateButton(LabelButton* button, ui::DialogButton type) {
button->SetText(GetDialogButtonLabel(type)); button->SetText(GetDialogButtonLabel(type));
button->SetEnabled(IsDialogButtonEnabled(type)); button->SetEnabled(IsDialogButtonEnabled(type));
......
...@@ -101,6 +101,10 @@ class VIEWS_EXPORT DialogDelegate : public WidgetDelegate { ...@@ -101,6 +101,10 @@ class VIEWS_EXPORT DialogDelegate : public WidgetDelegate {
// must remain open. // must remain open.
virtual bool Close(); virtual bool Close();
// Dialogs should not be draggable unless the dialog can be created with no
// parent browser window.
virtual bool IsDialogDraggable() const;
// Updates the properties and appearance of |button| which has been created // Updates the properties and appearance of |button| which has been created
// for type |type|. Override to do special initialization above and beyond // for type |type|. Override to do special initialization above and beyond
// the typical. // the typical.
......
...@@ -57,6 +57,7 @@ class TestDialog : public DialogDelegateView { ...@@ -57,6 +57,7 @@ class TestDialog : public DialogDelegateView {
closed_ = true; closed_ = true;
return closeable_; return closeable_;
} }
bool IsDialogDraggable() const override { return true; }
gfx::Size CalculatePreferredSize() const override { gfx::Size CalculatePreferredSize() const override {
return gfx::Size(200, 200); return gfx::Size(200, 200);
......
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