summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkeybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-12 10:01:34 +0000
committerkeybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-12 10:01:34 +0000
commitc011b2f34a22d3e3354d8edd082a0ad80a0b8245 (patch)
tree2b7ff5ef315e72dbe57288b9b3116d59bca4c4ab
parented628c0f4079e62f4a44b03fc0ab6c00189903f8 (diff)
downloadchromium_src-c011b2f34a22d3e3354d8edd082a0ad80a0b8245.zip
chromium_src-c011b2f34a22d3e3354d8edd082a0ad80a0b8245.tar.gz
chromium_src-c011b2f34a22d3e3354d8edd082a0ad80a0b8245.tar.bz2
Bluetooth: mark all Paired devices as Trusted
Move the point in which we mark a device as Trusted (incoming connections allowed) from the completion of the Pair() command to the Paired property becoming true. This means that devices paired from an incoming pairing request will now also be trusted. BUG=349608 TEST=device_unittests Review URL: https://codereview.chromium.org/194713014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256499 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--device/bluetooth/bluetooth_adapter_chromeos.cc6
-rw-r--r--device/bluetooth/bluetooth_chromeos_unittest.cc40
-rw-r--r--device/bluetooth/bluetooth_device_chromeos.cc1
3 files changed, 38 insertions, 9 deletions
diff --git a/device/bluetooth/bluetooth_adapter_chromeos.cc b/device/bluetooth/bluetooth_adapter_chromeos.cc
index 075b40f9..820972e 100644
--- a/device/bluetooth/bluetooth_adapter_chromeos.cc
+++ b/device/bluetooth/bluetooth_adapter_chromeos.cc
@@ -303,6 +303,12 @@ void BluetoothAdapterChromeOS::DevicePropertyChanged(
property_name == properties->uuids.name())
NotifyDeviceChanged(device_chromeos);
+ // When a device becomes paired, mark it as trusted so that the user does
+ // not need to approve every incoming connection
+ if (property_name == properties->paired.name() &&
+ properties->paired.value())
+ device_chromeos->SetTrusted();
+
// UMA connection counting
if (property_name == properties->connected.name()) {
int count = 0;
diff --git a/device/bluetooth/bluetooth_chromeos_unittest.cc b/device/bluetooth/bluetooth_chromeos_unittest.cc
index d24ad94..ca5ff03 100644
--- a/device/bluetooth/bluetooth_chromeos_unittest.cc
+++ b/device/bluetooth/bluetooth_chromeos_unittest.cc
@@ -2700,12 +2700,18 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPinCode) {
EXPECT_EQ(1, callback_count_);
EXPECT_EQ(0, error_callback_count_);
- // One for paired.
- EXPECT_EQ(1, observer.device_changed_count_);
+ // One change for paired, and one for trusted.
+ EXPECT_EQ(2, observer.device_changed_count_);
EXPECT_EQ(device, observer.last_device_);
EXPECT_TRUE(device->IsPaired());
+ // Make sure the trusted property has been set to true.
+ FakeBluetoothDeviceClient::Properties* properties =
+ fake_bluetooth_device_client_->GetProperties(
+ dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath));
+ ASSERT_TRUE(properties->trusted.value());
+
// No pairing context should remain on the device.
BluetoothDeviceChromeOS* device_chromeos =
static_cast<BluetoothDeviceChromeOS*>(device);
@@ -2752,12 +2758,18 @@ TEST_F(BluetoothChromeOSTest, IncomingPairConfirmPasskey) {
EXPECT_EQ(1, callback_count_);
EXPECT_EQ(0, error_callback_count_);
- // One for paired.
- EXPECT_EQ(1, observer.device_changed_count_);
+ // One change for paired, and one for trusted.
+ EXPECT_EQ(2, observer.device_changed_count_);
EXPECT_EQ(device, observer.last_device_);
EXPECT_TRUE(device->IsPaired());
+ // Make sure the trusted property has been set to true.
+ FakeBluetoothDeviceClient::Properties* properties =
+ fake_bluetooth_device_client_->GetProperties(
+ dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath));
+ ASSERT_TRUE(properties->trusted.value());
+
// No pairing context should remain on the device.
BluetoothDeviceChromeOS* device_chromeos =
static_cast<BluetoothDeviceChromeOS*>(device);
@@ -2803,12 +2815,18 @@ TEST_F(BluetoothChromeOSTest, IncomingPairRequestPasskey) {
EXPECT_EQ(1, callback_count_);
EXPECT_EQ(0, error_callback_count_);
- // One for paired.
- EXPECT_EQ(1, observer.device_changed_count_);
+ // One change for paired, and one for trusted.
+ EXPECT_EQ(2, observer.device_changed_count_);
EXPECT_EQ(device, observer.last_device_);
EXPECT_TRUE(device->IsPaired());
+ // Make sure the trusted property has been set to true.
+ FakeBluetoothDeviceClient::Properties* properties =
+ fake_bluetooth_device_client_->GetProperties(
+ dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPasskeyPath));
+ ASSERT_TRUE(properties->trusted.value());
+
// No pairing context should remain on the device.
BluetoothDeviceChromeOS* device_chromeos =
static_cast<BluetoothDeviceChromeOS*>(device);
@@ -2855,12 +2873,18 @@ TEST_F(BluetoothChromeOSTest, IncomingPairJustWorks) {
EXPECT_EQ(1, callback_count_);
EXPECT_EQ(0, error_callback_count_);
- // One for paired.
- EXPECT_EQ(1, observer.device_changed_count_);
+ // One change for paired, and one for trusted.
+ EXPECT_EQ(2, observer.device_changed_count_);
EXPECT_EQ(device, observer.last_device_);
EXPECT_TRUE(device->IsPaired());
+ // Make sure the trusted property has been set to true.
+ FakeBluetoothDeviceClient::Properties* properties =
+ fake_bluetooth_device_client_->GetProperties(
+ dbus::ObjectPath(FakeBluetoothDeviceClient::kJustWorksPath));
+ ASSERT_TRUE(properties->trusted.value());
+
// No pairing context should remain on the device.
BluetoothDeviceChromeOS* device_chromeos =
static_cast<BluetoothDeviceChromeOS*>(device);
diff --git a/device/bluetooth/bluetooth_device_chromeos.cc b/device/bluetooth/bluetooth_device_chromeos.cc
index d68fd0b..aa1d66b 100644
--- a/device/bluetooth/bluetooth_device_chromeos.cc
+++ b/device/bluetooth/bluetooth_device_chromeos.cc
@@ -491,7 +491,6 @@ void BluetoothDeviceChromeOS::OnPair(
EndPairing();
- SetTrusted();
ConnectInternal(true, callback, error_callback);
}