OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_ api.h" | 5 #include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_ api.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
703 reinterpret_cast<const char*>(user_image->front()), user_image->size())); | 703 reinterpret_cast<const char*>(user_image->front()), user_image->size())); |
704 #else | 704 #else |
705 // TODO(tengs): Find a way to get the profile picture for non-ChromeOS | 705 // TODO(tengs): Find a way to get the profile picture for non-ChromeOS |
706 // devices. | 706 // devices. |
707 results_ = easy_unlock_private::GetUserImage::Results::Create(""); | 707 results_ = easy_unlock_private::GetUserImage::Results::Create(""); |
708 SetError("Not supported on non-ChromeOS platforms."); | 708 SetError("Not supported on non-ChromeOS platforms."); |
709 #endif | 709 #endif |
710 return true; | 710 return true; |
711 } | 711 } |
712 | 712 |
713 EasyUnlockPrivateGetConnectionInfoFunction:: | |
714 EasyUnlockPrivateGetConnectionInfoFunction() { | |
715 } | |
716 | |
717 EasyUnlockPrivateGetConnectionInfoFunction:: | |
718 ~EasyUnlockPrivateGetConnectionInfoFunction() { | |
719 } | |
720 | |
721 bool EasyUnlockPrivateGetConnectionInfoFunction::DoWork( | |
722 scoped_refptr<device::BluetoothAdapter> adapter) { | |
723 scoped_ptr<easy_unlock_private::GetConnectionInfo::Params> params = | |
724 easy_unlock_private::GetConnectionInfo::Params::Create(*args_); | |
725 EXTENSION_FUNCTION_VALIDATE(params); | |
726 | |
727 device::BluetoothDevice* device = adapter->GetDevice(params->device_address); | |
728 | |
729 std::string error; | |
730 if (!device) | |
731 error = "Invalid Bluetooth device."; | |
732 else if (!device->IsConnected()) | |
733 error = "Bluetooth device not connected."; | |
734 | |
735 if (!error.empty()) { | |
736 SetError(error); | |
737 SendResponse(false); | |
738 return true; | |
Yoyo Zhou
2015/01/08 20:23:05
Aside: It looks like BluetoothExtensionFunction ju
Tim Song
2015/01/09 00:31:46
I followed the styles of the other subclasses that
| |
739 } | |
740 | |
741 device->GetConnectionInfo(base::Bind( | |
742 &EasyUnlockPrivateGetConnectionInfoFunction::OnConnectionInfo, this)); | |
743 return false; | |
744 } | |
745 | |
746 void EasyUnlockPrivateGetConnectionInfoFunction::OnConnectionInfo( | |
747 const device::BluetoothDevice::ConnectionInfo& connection_info) { | |
748 scoped_ptr<base::ListValue> results(new base::ListValue()); | |
749 results->AppendInteger(connection_info.rssi); | |
750 results->AppendInteger(connection_info.transmit_power); | |
751 results->AppendInteger(connection_info.max_transmit_power); | |
752 SetResultList(results.Pass()); | |
753 SendResponse(true); | |
754 } | |
755 | |
713 } // namespace api | 756 } // namespace api |
714 } // namespace extensions | 757 } // namespace extensions |
OLD | NEW |