Commit 018d07c7 authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

remoting: use DialogDelegate closure callbacks

Bug: 1011446
Change-Id: Ia2227f00e07d6f1cb26f55f52df571383a8e8137
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2154728Reviewed-by: default avatarGary Kacmarcik <garykac@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760136}
parent 0897b1c3
...@@ -37,8 +37,6 @@ class MessageBox::Core : public views::DialogDelegateView { ...@@ -37,8 +37,6 @@ class MessageBox::Core : public views::DialogDelegateView {
void Hide(); void Hide();
// views::DialogDelegateView: // views::DialogDelegateView:
bool Accept() override;
bool Cancel() override;
ui::ModalType GetModalType() const override; ui::ModalType GetModalType() const override;
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
views::View* GetContentsView() override; views::View* GetContentsView() override;
...@@ -74,6 +72,17 @@ MessageBox::Core::Core(const base::string16& title_label, ...@@ -74,6 +72,17 @@ MessageBox::Core::Core(const base::string16& title_label,
DCHECK(message_box_); DCHECK(message_box_);
DialogDelegate::SetButtonLabel(ui::DIALOG_BUTTON_OK, ok_label); DialogDelegate::SetButtonLabel(ui::DIALOG_BUTTON_OK, ok_label);
DialogDelegate::SetButtonLabel(ui::DIALOG_BUTTON_CANCEL, cancel_label); DialogDelegate::SetButtonLabel(ui::DIALOG_BUTTON_CANCEL, cancel_label);
auto run_callback = [](MessageBox::Core* core, Result result) {
if (core->result_callback_)
std::move(core->result_callback_).Run(result);
};
DialogDelegate::SetAcceptCallback(
base::BindOnce(run_callback, base::Unretained(this), OK));
DialogDelegate::SetCancelCallback(
base::BindOnce(run_callback, base::Unretained(this), CANCEL));
DialogDelegate::SetCloseCallback(
base::BindOnce(run_callback, base::Unretained(this), CANCEL));
} }
void MessageBox::Core::Show() { void MessageBox::Core::Show() {
...@@ -94,20 +103,6 @@ void MessageBox::Core::Hide() { ...@@ -94,20 +103,6 @@ void MessageBox::Core::Hide() {
} }
} }
bool MessageBox::Core::Accept() {
if (!result_callback_.is_null()) {
std::move(result_callback_).Run(OK);
}
return true /* close the window*/;
}
bool MessageBox::Core::Cancel() {
if (!result_callback_.is_null()) {
std::move(result_callback_).Run(CANCEL);
}
return true /* close the window*/;
}
ui::ModalType MessageBox::Core::GetModalType() const { ui::ModalType MessageBox::Core::GetModalType() const {
return ui::MODAL_TYPE_SYSTEM; return ui::MODAL_TYPE_SYSTEM;
} }
......
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