Index: chrome/browser/extensions/api/bluetooth/bluetooth_api.cc |
diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..905d8ad0d7e152ce4b98d87ec02a2da162c64459 |
--- /dev/null |
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc |
@@ -0,0 +1,99 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/extensions/api/bluetooth/bluetooth_api.h" |
+ |
+#include "chrome/browser/extensions/extension_service.h" |
+#include "chrome/browser/profiles/profile.h" |
+ |
+#if defined(OS_CHROMEOS) |
+#include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h" |
+#include "chrome/browser/chromeos/extensions/bluetooth_event_router.h" |
+#endif |
+ |
+namespace extensions { |
+namespace api { |
+ |
+#if defined(OS_CHROMEOS) |
+bool BluetoothIsAvailableFunction::RunImpl() { |
+ const chromeos::BluetoothAdapter *adapter = |
+ profile()->GetExtensionService()->bluetooth_event_router()->adapter(); |
+ if (!adapter) |
+ return false; |
Mihai Parparita -not on Chrome
2012/03/21 21:48:52
You have a DCHECK for adapter not being null in Bl
bryeung
2012/03/22 00:37:04
Thank you for pointing this out. I removed the if
|
+ |
+ result_.reset(Value::CreateBooleanValue(adapter->IsPresent())); |
+ SendResponse(true); |
asargent_no_longer_on_chrome
2012/03/21 21:19:58
Since you can synchronously answer the question on
bryeung
2012/03/21 21:34:14
Thanks for the clarification: done.
|
+ return true; |
+} |
+ |
+bool BluetoothIsPoweredFunction::RunImpl() { |
asargent_no_longer_on_chrome
2012/03/21 21:19:58
same thing here
bryeung
2012/03/21 21:34:14
Done.
|
+ const chromeos::BluetoothAdapter *adapter = |
+ profile()->GetExtensionService()->bluetooth_event_router()->adapter(); |
+ if (!adapter) |
+ return false; |
+ |
+ result_.reset(Value::CreateBooleanValue(adapter->IsPowered())); |
+ SendResponse(true); |
+ return true; |
+} |
+ |
+#else |
+ |
+// ----------------------------------------------------------------------------- |
+// NIY stubs |
+// ----------------------------------------------------------------------------- |
+bool BluetoothIsAvailableFunction::RunImpl() { |
+ NOTREACHED() << "Not implemented yet"; |
+ return false; |
+} |
+ |
+bool BluetoothIsPoweredFunction::RunImpl() { |
+ NOTREACHED() << "Not implemented yet"; |
+ return false; |
+} |
+ |
+#endif |
+ |
+bool BluetoothDisconnectFunction::RunImpl() { |
+ NOTREACHED() << "Not implemented yet"; |
+ return false; |
+} |
+ |
+bool BluetoothReadFunction::RunImpl() { |
+ NOTREACHED() << "Not implemented yet"; |
+ return false; |
+} |
+ |
+bool BluetoothSetOutOfBandPairingDataFunction::RunImpl() { |
+ NOTREACHED() << "Not implemented yet"; |
+ return false; |
+} |
+ |
+bool BluetoothGetOutOfBandPairingDataFunction::RunImpl() { |
+ NOTREACHED() << "Not implemented yet"; |
+ return false; |
+} |
+ |
+bool BluetoothGetAddressFunction::RunImpl() { |
+ NOTREACHED() << "Not implemented yet"; |
+ return false; |
+} |
+ |
+bool BluetoothWriteFunction::RunImpl() { |
+ NOTREACHED() << "Not implemented yet"; |
+ return false; |
+} |
+ |
+bool BluetoothConnectFunction::RunImpl() { |
+ NOTREACHED() << "Not implemented yet"; |
+ return false; |
+} |
+ |
+bool BluetoothGetDevicesWithServiceFunction::RunImpl() { |
+ NOTREACHED() << "Not implemented yet"; |
+ return false; |
+} |
+ |
+} // namespace api |
+} // namespace extensions |