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

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

Issue 11743024: Implemented BluetoothExtensionFunction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 7 years, 11 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_extension_function.cc
diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.cc
new file mode 100644
index 0000000000000000000000000000000000000000..eb88330326103cb61d1658307d5711e18a38ce52
--- /dev/null
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.cc
@@ -0,0 +1,49 @@
+// 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_extension_function.h"
+
+#include "base/memory/ref_counted.h"
+#include "chrome/browser/extensions/api/bluetooth/bluetooth_api.h"
+#include "chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h"
+#include "chrome/browser/profiles/profile.h"
+#include "device/bluetooth/bluetooth_adapter.h"
+#include "device/bluetooth/bluetooth_adapter_factory.h"
+
+namespace {
+
+const char kPlatformNotSupported[] =
+ "This operation is not supported on your platform";
+
+scoped_refptr<device::BluetoothAdapter> GetAdapter(Profile* profile) {
+ extensions::ExtensionBluetoothEventRouter* event_router =
+ extensions::BluetoothAPI::Get(profile)->bluetooth_event_router();
+ return event_router->GetAdapter();
+}
+
+} // namespace
+
+namespace extensions {
+
+namespace api {
+
+BluetoothExtensionFunction::BluetoothExtensionFunction() {
+}
+
+BluetoothExtensionFunction::~BluetoothExtensionFunction() {
+}
+
+bool BluetoothExtensionFunction::RunImpl() {
+ scoped_refptr<device::BluetoothAdapter> adapter = GetAdapter(profile());
+ if (!adapter) {
+ SetError(kPlatformNotSupported);
+ return false;
+ }
+ DoWork(adapter);
+ return true;
+}
+
+} // namespace api
+
+} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.h ('k') | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698