cbui: stop using BubbleUi for bluetooth chooser
This change:
1) Adds a new function, chrome::ShowDeviceChooserDialog, that displays a
device chooser bypassing the BubbleUi framework
2) Has Browser use this new function rather than BubbleUi to show the
bluetooth device choosers
Note that ShowDeviceChooserDialog returns a OnceClosure, which the client
can call to close the dialog. It does not return a pointer to the dialog
since the dialog is self-owning. Previously, this code dealt with that
by passing around BubbleReferences, which have weak pointer semantics;
returning a OnceClosure (which internally has a WeakPtr to the UI)
allows the client code to close the bubble when it wants to without adding
new lifetime issues.
Remaining uses of ChooserBubbleDelegate directly:
* Web USB chooser
* HID chooser
* Serial chooser
These use similar design patterns, and will be migrated in follow-up
changes.
Bug: 496955
Change-Id: I1b45c1cfdba6e0eaee57ef61d91da294832a0888
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2102947
Commit-Queue: Elly Fong-Jones <[email protected]>
Reviewed-by: Peter Kasting <[email protected]>
Cr-Commit-Position: refs/heads/master@{#750540}
diff --git a/chrome/browser/ui/bluetooth/bluetooth_scanning_prompt_desktop.cc b/chrome/browser/ui/bluetooth/bluetooth_scanning_prompt_desktop.cc
index bee595b..3d8aae6 100644
--- a/chrome/browser/ui/bluetooth/bluetooth_scanning_prompt_desktop.cc
+++ b/chrome/browser/ui/bluetooth/bluetooth_scanning_prompt_desktop.cc
@@ -6,12 +6,13 @@
#include "base/logging.h"
#include "chrome/browser/ui/bluetooth/bluetooth_scanning_prompt_controller.h"
-#include "components/bubble/bubble_controller.h"
BluetoothScanningPromptDesktop::BluetoothScanningPromptDesktop(
- BluetoothScanningPromptController* bluetooth_scanning_prompt_controller)
+ BluetoothScanningPromptController* bluetooth_scanning_prompt_controller,
+ base::OnceClosure&& close_closure)
: bluetooth_scanning_prompt_controller_(
- bluetooth_scanning_prompt_controller) {
+ bluetooth_scanning_prompt_controller),
+ close_closure_(std::move(close_closure)) {
DCHECK(bluetooth_scanning_prompt_controller_);
}
@@ -20,8 +21,8 @@
// requirement that the EventHandler can be destroyed any time after the
// BluetoothScanningPrompt instance.
bluetooth_scanning_prompt_controller_->ResetEventHandler();
- if (bubble_)
- bubble_->CloseBubble(BUBBLE_CLOSE_FORCED);
+ if (close_closure_)
+ std::move(close_closure_).Run();
}
void BluetoothScanningPromptDesktop::AddOrUpdateDevice(