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

cbuiv permissions: use new DialogDelegate closure hooks

This bubble also uses the old BubbleUi framework, so at some point
that will need to go as well (https://crbug.com/496955).

Bug: 1011446
Change-Id: I88444fcd84c3c0259872732da8685aae0367ba78
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2047272
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741336}
parent f62f9ea0
...@@ -52,9 +52,6 @@ class ChooserBubbleUiViewDelegate : public views::BubbleDialogDelegateView, ...@@ -52,9 +52,6 @@ class ChooserBubbleUiViewDelegate : public views::BubbleDialogDelegateView,
// views::DialogDelegate: // views::DialogDelegate:
bool IsDialogButtonEnabled(ui::DialogButton button) const override; bool IsDialogButtonEnabled(ui::DialogButton button) const override;
views::View* GetInitiallyFocusedView() override; views::View* GetInitiallyFocusedView() override;
bool Accept() override;
bool Cancel() override;
bool Close() override;
// views::TableViewObserver: // views::TableViewObserver:
void OnSelectionChanged() override; void OnSelectionChanged() override;
...@@ -104,6 +101,26 @@ ChooserBubbleUiViewDelegate::ChooserBubbleUiViewDelegate( ...@@ -104,6 +101,26 @@ ChooserBubbleUiViewDelegate::ChooserBubbleUiViewDelegate(
DialogDelegate::SetExtraView(device_chooser_content_view_->CreateExtraView()); DialogDelegate::SetExtraView(device_chooser_content_view_->CreateExtraView());
using ContentViewFn = void (DeviceChooserContentView::*)();
auto closure_callback = [](ChooserBubbleUiViewDelegate* dialog,
ContentViewFn func,
base::Optional<BubbleCloseReason> reason) {
(dialog->device_chooser_content_view_->*func)();
if (reason.has_value() && dialog->bubble_reference_)
dialog->bubble_reference_->CloseBubble(reason.value());
};
DialogDelegate::set_accept_callback(base::BindOnce(
closure_callback, base::Unretained(this),
&DeviceChooserContentView::Accept,
base::make_optional<BubbleCloseReason>(BUBBLE_CLOSE_ACCEPTED)));
DialogDelegate::set_cancel_callback(base::BindOnce(
closure_callback, base::Unretained(this),
&DeviceChooserContentView::Cancel,
base::make_optional<BubbleCloseReason>(BUBBLE_CLOSE_CANCELED)));
DialogDelegate::set_close_callback(
base::BindOnce(closure_callback, base::Unretained(this),
&DeviceChooserContentView::Close, base::nullopt));
UpdateAnchor(browser); UpdateAnchor(browser);
chrome::RecordDialogCreation(chrome::DialogIdentifier::CHOOSER_UI); chrome::RecordDialogCreation(chrome::DialogIdentifier::CHOOSER_UI);
} }
...@@ -127,25 +144,6 @@ bool ChooserBubbleUiViewDelegate::IsDialogButtonEnabled( ...@@ -127,25 +144,6 @@ bool ChooserBubbleUiViewDelegate::IsDialogButtonEnabled(
return device_chooser_content_view_->IsDialogButtonEnabled(button); return device_chooser_content_view_->IsDialogButtonEnabled(button);
} }
bool ChooserBubbleUiViewDelegate::Accept() {
device_chooser_content_view_->Accept();
if (bubble_reference_)
bubble_reference_->CloseBubble(BUBBLE_CLOSE_ACCEPTED);
return true;
}
bool ChooserBubbleUiViewDelegate::Cancel() {
device_chooser_content_view_->Cancel();
if (bubble_reference_)
bubble_reference_->CloseBubble(BUBBLE_CLOSE_CANCELED);
return true;
}
bool ChooserBubbleUiViewDelegate::Close() {
device_chooser_content_view_->Close();
return true;
}
void ChooserBubbleUiViewDelegate::OnSelectionChanged() { void ChooserBubbleUiViewDelegate::OnSelectionChanged() {
DialogModelChanged(); DialogModelChanged();
} }
......
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