Show throbber while initializing chooser permission prompt
This change enables the throbber and status message that are used for
the Web Bluetooth device chooser prompt on all of the other APIs which
use this UI. This improves the user experience for users on slower
devices where it can take some time for the set of available options to
be available.
Bug: 1160147
Change-Id: I59a03c1a94f58fdb38bf7c8d2d713680cb21c5aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2597903
Reviewed-by: Olivier Yiptong <[email protected]>
Reviewed-by: Connie Wan <[email protected]>
Commit-Queue: Reilly Grant <[email protected]>
Cr-Commit-Position: refs/heads/master@{#843207}
diff --git a/chrome/browser/chooser_controller/chooser_controller.cc b/chrome/browser/chooser_controller/chooser_controller.cc
index df95777..f9abcfc 100644
--- a/chrome/browser/chooser_controller/chooser_controller.cc
+++ b/chrome/browser/chooser_controller/chooser_controller.cc
@@ -120,10 +120,6 @@
NOTREACHED();
}
-base::string16 ChooserController::GetStatus() const {
- return base::string16();
-}
-
void ChooserController::OpenAdapterOffHelpUrl() const {
NOTREACHED();
}
diff --git a/chrome/browser/chooser_controller/chooser_controller.h b/chrome/browser/chooser_controller/chooser_controller.h
index 119ee81..99325e3 100644
--- a/chrome/browser/chooser_controller/chooser_controller.h
+++ b/chrome/browser/chooser_controller/chooser_controller.h
@@ -94,6 +94,11 @@
// Returns the label for SelectAll checkbox.
virtual base::string16 GetSelectAllCheckboxLabel() const;
+ // Returns the label for the throbber shown while options are initializing or
+ // a re-scan is in progress.
+ virtual std::pair<base::string16, base::string16> GetThrobberLabelAndTooltip()
+ const = 0;
+
// Returns whether both OK and Cancel buttons are enabled.
//
// For chooser used in Web APIs such as WebBluetooth, WebUSB,
@@ -137,9 +142,6 @@
// Refresh the list of options.
virtual void RefreshOptions();
- // Returns the status text to be shown in the chooser.
- virtual base::string16 GetStatus() const;
-
// These three functions are called just before this object is destroyed:
// Called when the user selects elements from the dialog. |indices| contains
diff --git a/chrome/browser/chooser_controller/fake_bluetooth_chooser_controller.cc b/chrome/browser/chooser_controller/fake_bluetooth_chooser_controller.cc
index c2bff4b..b0e0352 100644
--- a/chrome/browser/chooser_controller/fake_bluetooth_chooser_controller.cc
+++ b/chrome/browser/chooser_controller/fake_bluetooth_chooser_controller.cc
@@ -38,6 +38,14 @@
IDS_BLUETOOTH_DEVICE_CHOOSER_PAIR_BUTTON_TEXT);
}
+std::pair<base::string16, base::string16>
+FakeBluetoothChooserController::GetThrobberLabelAndTooltip() const {
+ return {
+ l10n_util::GetStringUTF16(IDS_BLUETOOTH_DEVICE_CHOOSER_SCANNING_LABEL),
+ l10n_util::GetStringUTF16(
+ IDS_BLUETOOTH_DEVICE_CHOOSER_SCANNING_LABEL_TOOLTIP)};
+}
+
bool FakeBluetoothChooserController::TableViewAlwaysDisabled() const {
return table_view_always_disabled_;
}
@@ -62,26 +70,12 @@
return devices_.at(index).paired;
}
-base::string16 FakeBluetoothChooserController::GetStatus() const {
- switch (status_) {
- case BluetoothStatus::UNAVAILABLE:
- return base::string16();
- case BluetoothStatus::IDLE:
- return l10n_util::GetStringUTF16(IDS_BLUETOOTH_DEVICE_CHOOSER_RE_SCAN);
- case BluetoothStatus::SCANNING:
- return l10n_util::GetStringUTF16(IDS_BLUETOOTH_DEVICE_CHOOSER_SCANNING);
- }
- NOTREACHED();
- return base::string16();
-}
-
void FakeBluetoothChooserController::SetBluetoothStatus(
BluetoothStatus status) {
- status_ = status;
const bool available = status != BluetoothStatus::UNAVAILABLE;
view()->OnAdapterEnabledChanged(available);
if (available)
- view()->OnRefreshStateChanged(status_ == BluetoothStatus::SCANNING);
+ view()->OnRefreshStateChanged(status == BluetoothStatus::SCANNING);
}
void FakeBluetoothChooserController::AddDevice(FakeDevice device) {
diff --git a/chrome/browser/chooser_controller/fake_bluetooth_chooser_controller.h b/chrome/browser/chooser_controller/fake_bluetooth_chooser_controller.h
index f2b3de9..57b2f15 100644
--- a/chrome/browser/chooser_controller/fake_bluetooth_chooser_controller.h
+++ b/chrome/browser/chooser_controller/fake_bluetooth_chooser_controller.h
@@ -55,13 +55,14 @@
bool ShouldShowReScanButton() const override;
base::string16 GetNoOptionsText() const override;
base::string16 GetOkButtonLabel() const override;
+ std::pair<base::string16, base::string16> GetThrobberLabelAndTooltip()
+ const override;
bool TableViewAlwaysDisabled() const override;
size_t NumOptions() const override;
int GetSignalStrengthLevel(size_t index) const override;
base::string16 GetOption(size_t index) const override;
bool IsConnected(size_t index) const override;
bool IsPaired(size_t index) const override;
- base::string16 GetStatus() const override;
MOCK_METHOD0(RefreshOptions, void());
MOCK_METHOD1(Select, void(const std::vector<size_t>& indices));
MOCK_METHOD0(Cancel, void());
@@ -78,7 +79,6 @@
}
private:
- BluetoothStatus status_ = BluetoothStatus::UNAVAILABLE;
std::vector<FakeDevice> devices_;
bool table_view_always_disabled_ = false;
diff --git a/chrome/browser/chooser_controller/fake_usb_chooser_controller.cc b/chrome/browser/chooser_controller/fake_usb_chooser_controller.cc
index c3accb2..c634d2e 100644
--- a/chrome/browser/chooser_controller/fake_usb_chooser_controller.cc
+++ b/chrome/browser/chooser_controller/fake_usb_chooser_controller.cc
@@ -23,6 +23,13 @@
return l10n_util::GetStringUTF16(IDS_USB_DEVICE_CHOOSER_CONNECT_BUTTON_TEXT);
}
+std::pair<base::string16, base::string16>
+FakeUsbChooserController::GetThrobberLabelAndTooltip() const {
+ return {
+ l10n_util::GetStringUTF16(IDS_USB_DEVICE_CHOOSER_LOADING_LABEL),
+ l10n_util::GetStringUTF16(IDS_USB_DEVICE_CHOOSER_LOADING_LABEL_TOOLTIP)};
+}
+
size_t FakeUsbChooserController::NumOptions() const {
return device_count_;
}
diff --git a/chrome/browser/chooser_controller/fake_usb_chooser_controller.h b/chrome/browser/chooser_controller/fake_usb_chooser_controller.h
index 38a6531..5b7e92c 100644
--- a/chrome/browser/chooser_controller/fake_usb_chooser_controller.h
+++ b/chrome/browser/chooser_controller/fake_usb_chooser_controller.h
@@ -19,6 +19,8 @@
// ChooserController:
base::string16 GetNoOptionsText() const override;
base::string16 GetOkButtonLabel() const override;
+ std::pair<base::string16, base::string16> GetThrobberLabelAndTooltip()
+ const override;
size_t NumOptions() const override;
base::string16 GetOption(size_t index) const override;
void Select(const std::vector<size_t>& indices) override {}