Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ |
| 7 | 7 |
| 8 #include "base/android/jni_android.h" | |
| 8 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 9 #include "device/bluetooth/bluetooth_adapter.h" | 10 #include "device/bluetooth/bluetooth_adapter.h" |
| 10 | 11 |
| 11 namespace base { | 12 namespace base { |
| 12 class SequencedTaskRunner; | 13 class SequencedTaskRunner; |
| 13 } // namespace base | 14 } // namespace base |
| 14 | 15 |
| 15 namespace device { | 16 namespace device { |
| 16 | 17 |
| 17 // The BluetoothAdapterAndroid class implements BluetoothAdapter for the | 18 // The BluetoothAdapterAndroid class implements BluetoothAdapter for the |
| 18 // Android platform. | 19 // Android platform. |
| 19 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterAndroid final | 20 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterAndroid final |
| 20 : public BluetoothAdapter { | 21 : public BluetoothAdapter { |
| 21 public: | 22 public: |
| 22 static base::WeakPtr<BluetoothAdapter> CreateAdapter(); | 23 // Create a BluetoothAdapterAndroid instance. |
| 24 static base::WeakPtr<BluetoothAdapterAndroid> CreateAdapter(); | |
|
armansito
2015/05/06 01:57:06
Shouldn't this be <BluetoothAdapter>?
scheib
2015/05/06 04:30:15
No, changed to BluetoothAdapterAndroid so that And
| |
| 25 | |
| 26 // Register C++ methods exposed to Java using JNI. | |
| 27 static bool RegisterJNI(JNIEnv* env); | |
| 28 | |
| 29 // True if this app has android permissions necessary for bluetooth. | |
|
armansito
2015/05/06 01:57:06
s/bluetooth/Bluetooth/
scheib
2015/05/06 04:30:15
Done.
| |
| 30 bool has_bluetooth_permission() { return has_bluetooth_permission_; } | |
|
armansito
2015/05/06 01:57:06
nit: make this a const method.
scheib
2015/05/06 04:30:15
Done.
| |
| 23 | 31 |
| 24 // BluetoothAdapter: | 32 // BluetoothAdapter: |
| 25 std::string GetAddress() const override; | 33 std::string GetAddress() const override; |
| 26 std::string GetName() const override; | 34 std::string GetName() const override; |
| 27 void SetName(const std::string& name, | 35 void SetName(const std::string& name, |
| 28 const base::Closure& callback, | 36 const base::Closure& callback, |
| 29 const ErrorCallback& error_callback) override; | 37 const ErrorCallback& error_callback) override; |
| 30 bool IsInitialized() const override; | 38 bool IsInitialized() const override; |
| 31 bool IsPresent() const override; | 39 bool IsPresent() const override; |
| 32 bool IsPowered() const override; | 40 bool IsPowered() const override; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 const ErrorCallback& error_callback) override; | 75 const ErrorCallback& error_callback) override; |
| 68 void RemoveDiscoverySession(BluetoothDiscoveryFilter* discovery_filter, | 76 void RemoveDiscoverySession(BluetoothDiscoveryFilter* discovery_filter, |
| 69 const base::Closure& callback, | 77 const base::Closure& callback, |
| 70 const ErrorCallback& error_callback) override; | 78 const ErrorCallback& error_callback) override; |
| 71 void SetDiscoveryFilter(scoped_ptr<BluetoothDiscoveryFilter> discovery_filter, | 79 void SetDiscoveryFilter(scoped_ptr<BluetoothDiscoveryFilter> discovery_filter, |
| 72 const base::Closure& callback, | 80 const base::Closure& callback, |
| 73 const ErrorCallback& error_callback) override; | 81 const ErrorCallback& error_callback) override; |
| 74 void RemovePairingDelegateInternal( | 82 void RemovePairingDelegateInternal( |
| 75 BluetoothDevice::PairingDelegate* pairing_delegate) override; | 83 BluetoothDevice::PairingDelegate* pairing_delegate) override; |
| 76 | 84 |
| 85 // Java object org.chromium.device.bluetooth.BluetoothAdapter. | |
| 86 base::android::ScopedJavaGlobalRef<jobject> j_bluetooth_adapter_; | |
| 87 | |
| 88 bool has_bluetooth_permission_ = false; | |
|
armansito
2015/05/06 01:57:06
Is this allowed in Chromium (or C++ for that matte
scheib
2015/05/06 04:30:15
Yes, https://chromium-cpp.appspot.com/ "Non-Static
| |
| 77 std::string address_; | 89 std::string address_; |
| 78 std::string name_; | 90 std::string name_; |
| 79 | 91 |
| 80 // Note: This should remain the last member so it'll be destroyed and | 92 // Note: This should remain the last member so it'll be destroyed and |
| 81 // invalidate its weak pointers before any other members are destroyed. | 93 // invalidate its weak pointers before any other members are destroyed. |
| 82 base::WeakPtrFactory<BluetoothAdapterAndroid> weak_ptr_factory_; | 94 base::WeakPtrFactory<BluetoothAdapterAndroid> weak_ptr_factory_; |
| 83 | 95 |
| 84 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterAndroid); | 96 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterAndroid); |
| 85 }; | 97 }; |
| 86 | 98 |
| 87 } // namespace device | 99 } // namespace device |
| 88 | 100 |
| 89 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ | 101 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ |
| OLD | NEW |