summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorkeybuk@google.com <keybuk@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-21 02:34:00 +0000
committerkeybuk@google.com <keybuk@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-21 02:34:00 +0000
commit6652074712f84591150721953f6ed8049145256e (patch)
treeba08278031be2edf40be1d8bbc6a31251fed5615 /chrome
parent80f07939e245cbccd898ee5742de79711d094914 (diff)
downloadchromium_src-6652074712f84591150721953f6ed8049145256e.zip
chromium_src-6652074712f84591150721953f6ed8049145256e.tar.gz
chromium_src-6652074712f84591150721953f6ed8049145256e.tar.bz2
bluetooth: use better definitions of Paired
Recent Bluetooth specifications (such as V4.0 and HID 1.1) redefine "paired" to be less confusing: pairing is the process of connecting two devices and agreeing a basic link key, even if only temporary for that session. The term "bonded" is used for a permanent link key that can be used for the next connection. While BlueZ still uses the older definitions, it makes sense for our interface to use these new definitions, since it neatly divides devices into "paired" and "not yet paired", with "bonded" a sub-category of "paired". BUG=none TEST=verified on device Change-Id: I29fc55fb9ffd0a20f8280e2b6371c3be459467b2 R=satorux@chromium.org,jhawkins@chromium.org,csilv@chromium.org,kevers@chromium.org Review URL: https://chromiumcodereview.appspot.com/9766005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127884 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/chromeos/bluetooth/bluetooth_adapter.cc16
-rw-r--r--chrome/browser/chromeos/bluetooth/bluetooth_adapter.h11
-rw-r--r--chrome/browser/chromeos/bluetooth/bluetooth_device.cc16
-rw-r--r--chrome/browser/chromeos/bluetooth/bluetooth_device.h40
-rw-r--r--chrome/browser/resources/options2/browser_options.js4
-rw-r--r--chrome/browser/resources/options2/chromeos/bluetooth_device_list.js12
-rw-r--r--chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.js1
-rw-r--r--chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.cc2
-rw-r--r--chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.cc2
9 files changed, 49 insertions, 55 deletions
diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_adapter.cc b/chrome/browser/chromeos/bluetooth/bluetooth_adapter.cc
index ac18cd5..b660c6f 100644
--- a/chrome/browser/chromeos/bluetooth/bluetooth_adapter.cc
+++ b/chrome/browser/chromeos/bluetooth/bluetooth_adapter.cc
@@ -276,7 +276,7 @@ void BluetoothAdapter::UpdateDevice(const dbus::ObjectPath& device_path) {
if (iter != devices_.end()){
BluetoothDevice* device = iter->second;
- if (device->WasDiscovered())
+ if (!device->IsPaired())
device->SetObjectPath(device_path);
device->Update(properties, true);
@@ -367,7 +367,7 @@ void BluetoothAdapter::ClearDiscoveredDevices() {
DevicesMap::iterator temp = iter;
++iter;
- if (device->WasDiscovered()) {
+ if (!device->IsPaired()) {
FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
DeviceRemoved(this, device));
@@ -384,8 +384,8 @@ void BluetoothAdapter::DeviceFound(
return;
// DeviceFound can also be called to indicate that a device we've
- // paired with or previously connected to is now visible to the adapter,
- // so check it's not already in the list and just update if it is.
+ // paired with is now visible to the adapter, so check it's not already
+ // in the list and just update if it is.
BluetoothDevice* device;
DevicesMap::iterator iter = devices_.find(address);
if (iter == devices_.end()) {
@@ -399,7 +399,7 @@ void BluetoothAdapter::DeviceFound(
device = iter->second;
device->Update(&properties, false);
- if (device->IsSupported() || !device->WasDiscovered())
+ if (device->IsSupported() || device->IsPaired())
FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
DeviceChanged(this, device));
}
@@ -417,9 +417,9 @@ void BluetoothAdapter::DeviceDisappeared(const dbus::ObjectPath& adapter_path,
BluetoothDevice* device = iter->second;
// DeviceDisappeared can also be called to indicate that a device we've
- // paired with or previously connected to is no longer visible to the
- // adapter, so only delete discovered devices.
- if (device->WasDiscovered()) {
+ // paired with is no longer visible to the adapter, so only delete
+ // discovered devices.
+ if (!device->IsPaired()) {
FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
DeviceRemoved(this, device));
diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_adapter.h b/chrome/browser/chromeos/bluetooth/bluetooth_adapter.h
index da89877..5c4f82f 100644
--- a/chrome/browser/chromeos/bluetooth/bluetooth_adapter.h
+++ b/chrome/browser/chromeos/bluetooth/bluetooth_adapter.h
@@ -115,8 +115,7 @@ class BluetoothAdapter : private BluetoothManagerClient::Observer,
void SetDiscovering(bool discovering, ErrorCallback callback);
// Requests the list of devices from the adapter, all are returned
- // including those currently connected, those that have been connected or
- // paired in the past and those that have only been discovered. Use the
+ // including those currently connected and those paired. Use the
// returned device pointers to determine which they are.
typedef std::vector<BluetoothDevice*> DeviceList;
DeviceList GetDevices();
@@ -280,10 +279,10 @@ class BluetoothAdapter : private BluetoothManagerClient::Observer,
bool powered_;
bool discovering_;
- // Devices paired with, connected to, previously connected to, discovered
- // and visible to the adapter. The key is the Bluetooth address of the device
- // and the value is the BluetoothDevice object whose lifetime is managed
- // by the adapter instance.
+ // Devices paired with, connected to, discovered by, or visible to the
+ // adapter. The key is the Bluetooth address of the device and the value
+ // is the BluetoothDevice object whose lifetime is managed by the adapter
+ // instance.
typedef std::map<const std::string, BluetoothDevice*> DevicesMap;
DevicesMap devices_;
diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_device.cc b/chrome/browser/chromeos/bluetooth/bluetooth_device.cc
index 0a2dc0c..3fd4f83 100644
--- a/chrome/browser/chromeos/bluetooth/bluetooth_device.cc
+++ b/chrome/browser/chromeos/bluetooth/bluetooth_device.cc
@@ -32,7 +32,7 @@ BluetoothDevice::BluetoothDevice(BluetoothAdapter* adapter)
: weak_ptr_factory_(this),
adapter_(adapter),
bluetooth_class_(0),
- paired_(false),
+ bonded_(false),
connected_(false),
pairing_delegate_(NULL) {
}
@@ -53,7 +53,9 @@ void BluetoothDevice::Update(
bluetooth_class_ = properties->bluetooth_class.value();
if (update_state) {
- paired_ = properties->paired.value();
+ // BlueZ uses paired to mean link keys exchanged, whereas the Bluetooth
+ // spec refers to this as bonded. Use the spec name for our interface.
+ bonded_ = properties->paired.value();
connected_ = properties->connected.value();
}
}
@@ -154,10 +156,6 @@ string16 BluetoothDevice::GetAddressWithLocalizedDeviceTypeName() const {
}
}
-bool BluetoothDevice::WasDiscovered() const {
- return object_path_.value().empty();
-}
-
bool BluetoothDevice::IsConnected() const {
// TODO(keybuk): examine protocol-specific connected state, such as Input
return connected_;
@@ -165,8 +163,8 @@ bool BluetoothDevice::IsConnected() const {
void BluetoothDevice::Connect(PairingDelegate* pairing_delegate,
ErrorCallback error_callback) {
- if (paired_ || connected_ || !WasDiscovered()) {
- // Connection to already known or paired device.
+ if (IsPaired() || IsBonded() || IsConnected()) {
+ // Connection to already paired or connected device.
ConnectApplications(error_callback);
} else if (!pairing_delegate) {
@@ -227,7 +225,7 @@ void BluetoothDevice::ConnectCallback(ErrorCallback error_callback,
// we can connect after rebooting. This information is part of the
// pairing information of the device, and is unique to the combination
// of our bluetooth address and the device's bluetooth address. A
- // different device needs a new pairing, so it's not useful to sync.
+ // different host needs a new pairing, so it's not useful to sync.
DBusThreadManager::Get()->GetBluetoothDeviceClient()->
GetProperties(object_path_)->trusted.Set(
true,
diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_device.h b/chrome/browser/chromeos/bluetooth/bluetooth_device.h
index d1cd0d8..f8d93aa 100644
--- a/chrome/browser/chromeos/bluetooth/bluetooth_device.h
+++ b/chrome/browser/chromeos/bluetooth/bluetooth_device.h
@@ -151,15 +151,14 @@ class BluetoothDevice : private BluetoothDeviceClient::Observer,
// Indicates whether the class of this device is supported by Chrome OS.
bool IsSupported() const;
- // Indicates if the device was one discovered by the adapter, and not yet
- // paired with or connected to.
- bool WasDiscovered() const;
+ // Indicates whether the device is paired to the adapter, whether or not
+ // that pairing is permanent or temporary.
+ bool IsPaired() const { return !object_path_.value().empty(); }
- // Indicates whether the device is paired to the adapter, note that some
- // devices can be connected to and used without pairing so use
- // WasDiscovered() rather than this method to determine whether or not
- // to display in a list of devices.
- bool IsPaired() const { return paired_; }
+ // Indicates whether the device is bonded to the adapter, bonding is
+ // formed by pairing and exchanging high-security link keys so that
+ // connections may be encrypted.
+ bool IsBonded() const { return bonded_; }
// Indicates whether the device is currently connected to the adapter
// and at least one service available for use.
@@ -187,11 +186,10 @@ class BluetoothDevice : private BluetoothDeviceClient::Observer,
//
// Method calls will be made on the supplied object |pairing_delegate|
// to indicate what display, and in response should make method calls
- // back to the device object. Not all devices require pairing, and not
- // all those that do will require user responses, so it is normal for
- // |pairing_delegate| to receive no calls. To explicitly force a
- // low-security connection without pairing, pass NULL, though this is
- // ignored if the device is already paired.
+ // back to the device object. Not all devices require user responses
+ // during pairing, so it is normal for |pairing_delegate| to receive no
+ // calls. To explicitly force a low-security connection without bonding,
+ // pass NULL, though this is ignored if the device is already paired.
//
// If the request fails, |error_callback| will be called.
void Connect(PairingDelegate* pairing_delegate,
@@ -217,7 +215,7 @@ class BluetoothDevice : private BluetoothDeviceClient::Observer,
// Rejects a pairing or connection request from a remote device.
void RejectPairing();
- // Cancels a pairing or connection attempt to a rmeote device.
+ // Cancels a pairing or connection attempt to a remote device.
void CancelPairing();
// Disconnects the device, terminating the low-level ACL connection
@@ -239,7 +237,7 @@ class BluetoothDevice : private BluetoothDeviceClient::Observer,
explicit BluetoothDevice(BluetoothAdapter* adapter);
// Sets the dbus object path for the device to |object_path|, indicating
- // that the device has gone from being discovered to paired or connected.
+ // that the device has gone from being discovered to paired or bonded.
void SetObjectPath(const dbus::ObjectPath& object_path);
// Updates device information from the properties in |properties|, device
@@ -415,17 +413,15 @@ class BluetoothDevice : private BluetoothDeviceClient::Observer,
// Creates a new BluetoothDevice object bound to the information of the
// dbus object path |object_path| and the adapter |adapter|, representing
- // a paired device or one that is currently or previously connected, with
- // initial properties set from |properties|.
+ // a paired device, with initial properties set from |properties|.
static BluetoothDevice* CreateBound(
BluetoothAdapter* adapter,
const dbus::ObjectPath& object_path,
const BluetoothDeviceClient::Properties* properties);
// Creates a new BluetoothDevice object not bound to a dbus object path,
- // but bound to the adapter |adapter|, representing a discovered device that
- // has not yet been connected to, with initial properties set
- // from |properties|.
+ // but bound to the adapter |adapter|, representing a discovered or unpaired
+ // device, with initial properties set from |properties|.
static BluetoothDevice* CreateUnbound(
BluetoothAdapter* adapter,
const BluetoothDeviceClient::Properties* properties);
@@ -438,7 +434,7 @@ class BluetoothDevice : private BluetoothDeviceClient::Observer,
BluetoothAdapter* adapter_;
// The dbus object path of the device, will be empty if the device has only
- // been discovered and not yet paired with or connected to.
+ // been discovered and not yet paired with.
dbus::ObjectPath object_path_;
// The Bluetooth address of the device.
@@ -453,7 +449,7 @@ class BluetoothDevice : private BluetoothDeviceClient::Observer,
// Tracked device state, updated by the adapter managing the lifecyle of
// the device.
- bool paired_;
+ bool bonded_;
bool connected_;
// During pairing this is set to an object that we don't own, but on which
diff --git a/chrome/browser/resources/options2/browser_options.js b/chrome/browser/resources/options2/browser_options.js
index f6c55fb6..94d1004 100644
--- a/chrome/browser/resources/options2/browser_options.js
+++ b/chrome/browser/resources/options2/browser_options.js
@@ -1172,15 +1172,15 @@ cr.define('options', function() {
* with a matching address is found, the existing element is updated.
* @param {{name: string,
* address: string,
- * discovered: boolean,
* paired: boolean,
+ * bonded: boolean,
* connected: boolean}} device
* Decription of the bluetooth device.
* @private
*/
addBluetoothDevice_: function(device) {
var list = $('bluetooth-unpaired-devices-list');
- if (!device.discovered) {
+ if (device.paired) {
// Test to see if the device is currently in the unpaired list, in which
// case it should be removed from that list.
var index = $('bluetooth-unpaired-devices-list').find(device.address);
diff --git a/chrome/browser/resources/options2/chromeos/bluetooth_device_list.js b/chrome/browser/resources/options2/chromeos/bluetooth_device_list.js
index 06b7513..d3caf80 100644
--- a/chrome/browser/resources/options2/chromeos/bluetooth_device_list.js
+++ b/chrome/browser/resources/options2/chromeos/bluetooth_device_list.js
@@ -16,8 +16,8 @@ cr.define('options.system.bluetooth', function() {
* Creates a new bluetooth list item.
* @param {{name: string,
* address: string,
- * discovered: boolean,
* paired: boolean,
+ * bonded: boolean,
* connected: boolean,
* pairing: string|undefined,
* passkey: number|undefined,
@@ -33,8 +33,8 @@ cr.define('options.system.bluetooth', function() {
for (var key in device)
el.data[key] = device[key];
el.decorate();
- // Only show the close button for non-discovered devices.
- el.deletable = !device.discovered;
+ // Only show the close button for paired devices.
+ el.deletable = device.paired;
return el;
}
@@ -45,8 +45,8 @@ cr.define('options.system.bluetooth', function() {
* Description of the Bluetooth device.
* @type {{name: string,
* address: string,
- * discovered: boolean,
* paired: boolean,
+ * bonded: boolean,
* connected: boolean,
* pairing: string|undefined,
* passkey: number|undefined,
@@ -63,7 +63,7 @@ cr.define('options.system.bluetooth', function() {
this.connected = this.data.connected;
// Though strictly speaking, a connected device will also be paired, we
// are interested in tracking paired devices that are not connected.
- this.paired = !this.data.discovered && !this.data.connected;
+ this.paired = this.data.paired && !this.data.connected;
this.connecting = !!this.data.pairing;
var content = this.data.name;
// Update label for devices that are paired but not connected.
@@ -108,8 +108,8 @@ cr.define('options.system.bluetooth', function() {
* existing device is updated.
* @param {{name: string,
* address: string,
- * discovered: boolean,
* paired: boolean,
+ * bonded: boolean,
* connected: boolean,
* pairing: string|undefined,
* passkey: number|undefined,
diff --git a/chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.js b/chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.js
index 025e52e..0aaa80e 100644
--- a/chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.js
+++ b/chrome/browser/resources/options2/chromeos/bluetooth_pair_device_overlay.js
@@ -61,6 +61,7 @@ cr.define('options', function() {
* address: string,
* icon: Constants.DEVICE_TYPE,
* paired: boolean,
+ * bonded: boolean,
* connected: boolean,
* pairing: string|undefined,
* passkey: number|undefined,
diff --git a/chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.cc
index a6b68f6..310519f 100644
--- a/chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.cc
+++ b/chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.cc
@@ -184,8 +184,8 @@ void BluetoothOptionsHandler::SendDeviceNotification(
base::DictionaryValue js_properties;
js_properties.SetString("name", device->GetName());
js_properties.SetString("address", device->address());
- js_properties.SetBoolean("discovered", device->WasDiscovered());
js_properties.SetBoolean("paired", device->IsPaired());
+ js_properties.SetBoolean("bonded", device->IsBonded());
js_properties.SetBoolean("connected", device->IsConnected());
if (params) {
js_properties.MergeDictionary(params);
diff --git a/chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.cc b/chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.cc
index c91b5dc..9715d63 100644
--- a/chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.cc
+++ b/chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.cc
@@ -324,8 +324,8 @@ void BluetoothOptionsHandler::SendDeviceNotification(
base::DictionaryValue js_properties;
js_properties.SetString("name", device->GetName());
js_properties.SetString("address", device->address());
- js_properties.SetBoolean("discovered", device->WasDiscovered());
js_properties.SetBoolean("paired", device->IsPaired());
+ js_properties.SetBoolean("bonded", device->IsBonded());
js_properties.SetBoolean("connected", device->IsConnected());
if (params) {
js_properties.MergeDictionary(params);