Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: chrome/browser/extensions/api/bluetooth/bluetooth_api.cc

Issue 9822001: Basic infrastructure for the Bluetooth API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix non-chromeos builds Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698