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

Unified Diff: extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.cc

Issue 1096393002: API stubs for the BLE advertisement API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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: extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.cc
diff --git a/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.cc b/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.cc
index 71529ad7c579caaf562637bb2c63763b418ae330..a072c0c8b6203cd34567c845f77ebdd5a8b73a25 100644
--- a/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.cc
+++ b/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.cc
@@ -793,5 +793,63 @@ void BluetoothLowEnergyWriteDescriptorValueFunction::ErrorCallback(
SendResponse(false);
}
+// RegisterAdvertisement:
+
+bool BluetoothLowEnergyRegisterAdvertisementFunction::DoWork() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ if (!BluetoothManifestData::CheckPeripheralPermitted(extension())) {
+ error_ = kErrorPermissionDenied;
+ SendResponse(false);
+ return false;
+ }
+
+ BluetoothLowEnergyEventRouter* event_router =
+ GetEventRouter(browser_context());
+
+ // The adapter must be initialized at this point, but return an error instead
+ // of asserting.
+ if (!event_router->HasAdapter()) {
+ SetError(kErrorAdapterNotInitialized);
+ SendResponse(false);
+ return false;
+ }
+
+ scoped_ptr<apibtle::RegisterAdvertisement::Params> params(
+ apibtle::RegisterAdvertisement::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params.get() != NULL);
+
+ // TODO(rkc): Implement this function.
+
+ return true;
+}
+
+// UnregisterAdvertisement:
+
+bool BluetoothLowEnergyUnregisterAdvertisementFunction::DoWork() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ if (!BluetoothManifestData::CheckPeripheralPermitted(extension())) {
+ error_ = kErrorPermissionDenied;
+ SendResponse(false);
+ return false;
+ }
+
+ BluetoothLowEnergyEventRouter* event_router =
+ GetEventRouter(browser_context());
+
+ // If we don't have an initialized adapter, unregistering is a no-op.
+ if (!event_router->HasAdapter())
+ return true;
+
+ scoped_ptr<apibtle::UnregisterAdvertisement::Params> params(
+ apibtle::UnregisterAdvertisement::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params.get() != NULL);
+
+ // TODO(rkc): Implement this function.
+
+ return true;
+}
+
} // namespace core_api
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698