diff options
author | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-15 09:25:29 +0000 |
---|---|---|
committer | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-15 09:25:29 +0000 |
commit | 284773982716ed62182f1b1c1897d0c33d165bda (patch) | |
tree | 4d3c5d5b471c8e89b25c9eb40dc9063e3fd78e56 /chrome | |
parent | dd6bfdea5eb77fcbbd8e651b0e1c534e3a407f0e (diff) | |
download | chromium_src-284773982716ed62182f1b1c1897d0c33d165bda.zip chromium_src-284773982716ed62182f1b1c1897d0c33d165bda.tar.gz chromium_src-284773982716ed62182f1b1c1897d0c33d165bda.tar.bz2 |
Revert 142360 - Add additional device attributes.
TEST=updated apitest
BUG=none
Review URL: https://chromiumcodereview.appspot.com/10537167
TBR=bryeung@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10539180
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142363 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
7 files changed, 23 insertions, 82 deletions
diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_device.cc b/chrome/browser/chromeos/bluetooth/bluetooth_device.cc index 6e5d1dae..3c2e120 100644 --- a/chrome/browser/chromeos/bluetooth/bluetooth_device.cc +++ b/chrome/browser/chromeos/bluetooth/bluetooth_device.cc @@ -194,10 +194,6 @@ string16 BluetoothDevice::GetAddressWithLocalizedDeviceTypeName() const { } } -bool BluetoothDevice::IsPaired() const { return !object_path_.value().empty(); } - -bool BluetoothDevice::IsBonded() const { return bonded_; } - bool BluetoothDevice::IsConnected() const { // TODO(keybuk): examine protocol-specific connected state, such as Input return connected_; diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_device.h b/chrome/browser/chromeos/bluetooth/bluetooth_device.h index 06514c0..2c3a240 100644 --- a/chrome/browser/chromeos/bluetooth/bluetooth_device.h +++ b/chrome/browser/chromeos/bluetooth/bluetooth_device.h @@ -161,16 +161,16 @@ class BluetoothDevice : private BluetoothDeviceClient::Observer, // Indicates whether the device is paired to the adapter, whether or not // that pairing is permanent or temporary. - virtual bool IsPaired() const; + bool IsPaired() const { return !object_path_.value().empty(); } // 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. - virtual bool IsBonded() const; + bool IsBonded() const { return bonded_; } // Indicates whether the device is currently connected to the adapter // and at least one service available for use. - virtual bool IsConnected() const; + bool IsConnected() const; // Returns the services (as UUID strings) that this device provides. typedef std::vector<std::string> ServiceList; diff --git a/chrome/browser/chromeos/bluetooth/test/mock_bluetooth_device.cc b/chrome/browser/chromeos/bluetooth/test/mock_bluetooth_device.cc index 5bc0cf7..c09ccd98 100644 --- a/chrome/browser/chromeos/bluetooth/test/mock_bluetooth_device.cc +++ b/chrome/browser/chromeos/bluetooth/test/mock_bluetooth_device.cc @@ -9,24 +9,12 @@ namespace chromeos { MockBluetoothDevice::MockBluetoothDevice(MockBluetoothAdapter* adapter, - const std::string& name, - const std::string& address, - bool paired, - bool bonded, - bool connected) - : BluetoothDevice(adapter), - name_(UTF8ToUTF16(name)), - address_(address) { + const std::string& name, const std::string& address) + : BluetoothDevice(adapter), name_(UTF8ToUTF16(name)), address_(address) { ON_CALL(*this, GetName()) .WillByDefault(testing::Return(name_)); ON_CALL(*this, address()) .WillByDefault(testing::ReturnRef(address_)); - ON_CALL(*this, IsPaired()) - .WillByDefault(testing::Return(paired)); - ON_CALL(*this, IsBonded()) - .WillByDefault(testing::Return(bonded)); - ON_CALL(*this, IsConnected()) - .WillByDefault(testing::Return(connected)); } MockBluetoothDevice::~MockBluetoothDevice() {} diff --git a/chrome/browser/chromeos/bluetooth/test/mock_bluetooth_device.h b/chrome/browser/chromeos/bluetooth/test/mock_bluetooth_device.h index c7b9226..f2d204f 100644 --- a/chrome/browser/chromeos/bluetooth/test/mock_bluetooth_device.h +++ b/chrome/browser/chromeos/bluetooth/test/mock_bluetooth_device.h @@ -16,19 +16,12 @@ namespace chromeos { class MockBluetoothDevice : public BluetoothDevice { public: - MockBluetoothDevice(MockBluetoothAdapter* adapter, - const std::string& name, - const std::string& address, - bool paired, - bool bonded, - bool connected); + explicit MockBluetoothDevice(MockBluetoothAdapter* adapter, + const std::string& name, const std::string& address); virtual ~MockBluetoothDevice(); MOCK_CONST_METHOD0(address, const std::string&()); MOCK_CONST_METHOD0(GetName, string16()); - MOCK_CONST_METHOD0(IsPaired, bool()); - MOCK_CONST_METHOD0(IsBonded, bool()); - MOCK_CONST_METHOD0(IsConnected, bool()); MOCK_CONST_METHOD1(ProvidesServiceWithUUID, bool(const std::string&)); MOCK_METHOD3(SetOutOfBandPairingData, diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc index 92ca8a3..3b6e034 100644 --- a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc +++ b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc @@ -43,23 +43,6 @@ chromeos::BluetoothAdapter* GetMutableAdapter(Profile* profile) { return GetEventRouter(profile)->GetMutableAdapter(); } -// Fill in a Device object from a chromeos::BluetoothDevice. -void PopulateApiDevice(const chromeos::BluetoothDevice& device, - extensions::api::experimental_bluetooth::Device* out) { - out->name = UTF16ToUTF8(device.GetName()); - out->address = device.address(); - out->paired = device.IsPaired(); - out->bonded = device.IsBonded(); - out->connected = device.IsConnected(); -} - -// The caller takes ownership of the returned pointer. -base::Value* BluetoothDeviceToValue(const chromeos::BluetoothDevice& device) { - extensions::api::experimental_bluetooth::Device api_device; - PopulateApiDevice(device, &api_device); - return api_device.ToValue().release(); -} - } // namespace #endif @@ -120,8 +103,12 @@ bool BluetoothGetDevicesWithServiceUUIDFunction::RunImpl() { ListValue* matches = new ListValue; for (BluetoothAdapter::ConstDeviceList::const_iterator i = devices.begin(); i != devices.end(); ++i) { - if ((*i)->ProvidesServiceWithUUID(params->uuid)) - matches->Append(BluetoothDeviceToValue(**i)); + if ((*i)->ProvidesServiceWithUUID(params->uuid)) { + experimental_bluetooth::Device device; + device.name = UTF16ToUTF8((*i)->GetName()); + device.address = (*i)->address(); + matches->Append(device.ToValue().release()); + } } result_.reset(matches); @@ -135,8 +122,12 @@ void BluetoothGetDevicesWithServiceNameFunction::AddDeviceIfTrue( ListValue* list, const BluetoothDevice* device, bool result) { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - if (result) - list->Append(BluetoothDeviceToValue(*device)); + if (result) { + experimental_bluetooth::Device device_result; + device_result.name = UTF16ToUTF8(device->GetName()); + device_result.address = device->address(); + list->Append(device_result.ToValue().release()); + } callbacks_pending_--; if (callbacks_pending_ == 0) { @@ -184,7 +175,8 @@ void BluetoothConnectFunction::ConnectToServiceCallback( int socket_id = GetEventRouter(profile())->RegisterSocket(socket); experimental_bluetooth::Socket result_socket; - PopulateApiDevice(*device, &result_socket.device); + result_socket.device.address = device->address(); + result_socket.device.name = UTF16ToUTF8(device->GetName()); result_socket.service_uuid = service_uuid; result_socket.id = socket_id; result_.reset(result_socket.ToValue().release()); diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc index 80bdda2..4e0602f 100644 --- a/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc +++ b/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc @@ -135,11 +135,9 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, IsPowered) { IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevicesWithServiceUUID) { testing::NiceMock<chromeos::MockBluetoothDevice> device1( - mock_adapter_, "d1", "11:12:13:14:15:16", - true /* paired */, false /* bonded */, true /* connected */); + mock_adapter_, "d1", "11:12:13:14:15:16"); testing::NiceMock<chromeos::MockBluetoothDevice> device2( - mock_adapter_, "d2", "21:22:23:24:25:26", - false /* paired */, true /* bonded */, false /* connected */); + mock_adapter_, "d2", "21:22:23:24:25:26"); chromeos::BluetoothAdapter::ConstDeviceList devices; devices.push_back(&device1); devices.push_back(&device2); @@ -173,18 +171,6 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetDevicesWithServiceUUID) { std::string name; ASSERT_TRUE(device->GetString("name", &name)); EXPECT_EQ("d2", name); - std::string address; - ASSERT_TRUE(device->GetString("address", &address)); - EXPECT_EQ("21:22:23:24:25:26", address); - bool paired; - ASSERT_TRUE(device->GetBoolean("paired", &paired)); - EXPECT_EQ(false, paired); - bool bonded; - ASSERT_TRUE(device->GetBoolean("bonded", &bonded)); - EXPECT_EQ(true, bonded); - bool connected; - ASSERT_TRUE(device->GetBoolean("connected", &connected)); - EXPECT_EQ(false, connected); } IN_PROC_BROWSER_TEST_F(BluetoothApiTest, GetLocalOutOfBandPairingData) { diff --git a/chrome/common/extensions/api/experimental_bluetooth.idl b/chrome/common/extensions/api/experimental_bluetooth.idl index 747ecaf..d38a3c0 100644 --- a/chrome/common/extensions/api/experimental_bluetooth.idl +++ b/chrome/common/extensions/api/experimental_bluetooth.idl @@ -7,22 +7,8 @@ [nodoc] namespace experimental.bluetooth { dictionary Device { - // The address of the device, in the format 'XX:XX:XX:XX:XX:XX'. DOMString address; - - // The human-readable name of the device. DOMString name; - - // Indicates whether or not the device is paired with the system. - boolean paired; - - // Indicates whether or not the device is bonded with the system. A device - // is bonded if it is paired and high-security link keys have been - // exchanged so that connections may be encrypted. - boolean bonded; - - // Indicates whether the device is currently connected to the system. - boolean connected; }; dictionary Socket { |