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,
// BluetoothPairingDialog will automatically pair the device and handle all
// the incoming pairing requests.
chromeos::BluetoothPairingDialog::ShowDialog(
device::BluetoothDevice::CanonicalizeAddress(device->GetAddress()),
device->GetNameForDisplay(), device->IsPaired(), device->IsConnected());
device->GetAddress(), device->GetNameForDisplay(), device->IsPaired(),
device->IsConnected());
}
void ArcBluetoothBridge::RemoveBond(mojom::BluetoothAddressPtr addr) {
......
......@@ -49,7 +49,6 @@
#include "components/session_manager/core/session_manager.h"
#include "components/user_manager/user_manager.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_factory.h"
#include "net/base/escape.h"
......@@ -225,15 +224,11 @@ void SystemTrayClient::ShowBluetoothPairingDialog(
const base::string16& name_for_display,
bool paired,
bool connected) {
std::string canonical_address =
device::BluetoothDevice::CanonicalizeAddress(address);
if (canonical_address.empty()) // Address was invalid.
return;
base::RecordAction(
base::UserMetricsAction("StatusArea_Bluetooth_Connect_Unknown"));
chromeos::BluetoothPairingDialog::ShowDialog(
canonical_address, name_for_display, paired, connected);
if (chromeos::BluetoothPairingDialog::ShowDialog(address, name_for_display,
paired, connected)) {
base::RecordAction(
base::UserMetricsAction("StatusArea_Bluetooth_Connect_Unknown"));
}
}
void SystemTrayClient::ShowDateSettings() {
......
......@@ -13,6 +13,7 @@
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "device/bluetooth/bluetooth_device.h"
#include "ui/base/l10n/l10n_util.h"
namespace chromeos {
......@@ -41,8 +42,14 @@ BluetoothPairingDialog* BluetoothPairingDialog::ShowDialog(
const base::string16& name_for_display,
bool paired,
bool connected) {
BluetoothPairingDialog* dialog =
new BluetoothPairingDialog(address, name_for_display, paired, connected);
std::string cannonical_address =
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();
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