Commit cbcb900a authored by Steven Bennetts's avatar Steven Bennetts Committed by Commit Bot

BluetoothDialog cleanup: Pass non cannonical address

In the two (soon to be three) places where we call
BluetoothPairingDialog::ShowDialog, we first call
device::BluetoothDevice::CanonicalizeAddress(address).

We should do this in the ShowDialog call instead to simplify the
calling code.

Bug: 756094
Change-Id: Ie4b6ee4935bd9a632e231f5c07b4830fc590a832
Reviewed-on: https://chromium-review.googlesource.com/1153573Reviewed-by: default avatarXiaoyin Hu <xiaoyinh@chromium.org>
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578793}
parent 15df0846
...@@ -1312,8 +1312,8 @@ void ArcBluetoothBridge::CreateBond(mojom::BluetoothAddressPtr addr, ...@@ -1312,8 +1312,8 @@ void ArcBluetoothBridge::CreateBond(mojom::BluetoothAddressPtr addr,
// BluetoothPairingDialog will automatically pair the device and handle all // BluetoothPairingDialog will automatically pair the device and handle all
// the incoming pairing requests. // the incoming pairing requests.
chromeos::BluetoothPairingDialog::ShowDialog( chromeos::BluetoothPairingDialog::ShowDialog(
device::BluetoothDevice::CanonicalizeAddress(device->GetAddress()), device->GetAddress(), device->GetNameForDisplay(), device->IsPaired(),
device->GetNameForDisplay(), device->IsPaired(), device->IsConnected()); device->IsConnected());
} }
void ArcBluetoothBridge::RemoveBond(mojom::BluetoothAddressPtr addr) { void ArcBluetoothBridge::RemoveBond(mojom::BluetoothAddressPtr addr) {
......
...@@ -49,7 +49,6 @@ ...@@ -49,7 +49,6 @@
#include "components/session_manager/core/session_manager.h" #include "components/session_manager/core/session_manager.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
#include "content/public/common/service_manager_connection.h" #include "content/public/common/service_manager_connection.h"
#include "device/bluetooth/bluetooth_device.h"
#include "extensions/browser/api/vpn_provider/vpn_service.h" #include "extensions/browser/api/vpn_provider/vpn_service.h"
#include "extensions/browser/api/vpn_provider/vpn_service_factory.h" #include "extensions/browser/api/vpn_provider/vpn_service_factory.h"
#include "net/base/escape.h" #include "net/base/escape.h"
...@@ -225,15 +224,11 @@ void SystemTrayClient::ShowBluetoothPairingDialog( ...@@ -225,15 +224,11 @@ void SystemTrayClient::ShowBluetoothPairingDialog(
const base::string16& name_for_display, const base::string16& name_for_display,
bool paired, bool paired,
bool connected) { bool connected) {
std::string canonical_address = if (chromeos::BluetoothPairingDialog::ShowDialog(address, name_for_display,
device::BluetoothDevice::CanonicalizeAddress(address); paired, connected)) {
if (canonical_address.empty()) // Address was invalid. base::RecordAction(
return; base::UserMetricsAction("StatusArea_Bluetooth_Connect_Unknown"));
}
base::RecordAction(
base::UserMetricsAction("StatusArea_Bluetooth_Connect_Unknown"));
chromeos::BluetoothPairingDialog::ShowDialog(
canonical_address, name_for_display, paired, connected);
} }
void SystemTrayClient::ShowDateSettings() { void SystemTrayClient::ShowDateSettings() {
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h" #include "content/public/browser/web_ui_data_source.h"
#include "device/bluetooth/bluetooth_device.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
namespace chromeos { namespace chromeos {
...@@ -41,8 +42,14 @@ BluetoothPairingDialog* BluetoothPairingDialog::ShowDialog( ...@@ -41,8 +42,14 @@ BluetoothPairingDialog* BluetoothPairingDialog::ShowDialog(
const base::string16& name_for_display, const base::string16& name_for_display,
bool paired, bool paired,
bool connected) { bool connected) {
BluetoothPairingDialog* dialog = std::string cannonical_address =
new BluetoothPairingDialog(address, name_for_display, paired, connected); device::BluetoothDevice::CanonicalizeAddress(address);
if (cannonical_address.empty()) {
LOG(ERROR) << "BluetoothPairingDialog: Invalid address: " << address;
return nullptr;
}
BluetoothPairingDialog* dialog = new BluetoothPairingDialog(
cannonical_address, name_for_display, paired, connected);
dialog->ShowSystemDialog(); dialog->ShowSystemDialog();
return dialog; return dialog;
} }
......
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