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

Side by Side 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: merge 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.h " 5 #include "extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.h "
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 results_ = apibtle::WriteDescriptorValue::Results::Create(); 786 results_ = apibtle::WriteDescriptorValue::Results::Create();
787 SendResponse(true); 787 SendResponse(true);
788 } 788 }
789 789
790 void BluetoothLowEnergyWriteDescriptorValueFunction::ErrorCallback( 790 void BluetoothLowEnergyWriteDescriptorValueFunction::ErrorCallback(
791 BluetoothLowEnergyEventRouter::Status status) { 791 BluetoothLowEnergyEventRouter::Status status) {
792 SetError(StatusToString(status)); 792 SetError(StatusToString(status));
793 SendResponse(false); 793 SendResponse(false);
794 } 794 }
795 795
796 // RegisterAdvertisement:
797
798 bool BluetoothLowEnergyRegisterAdvertisementFunction::DoWork() {
799 DCHECK_CURRENTLY_ON(BrowserThread::UI);
800
801 if (!BluetoothManifestData::CheckPeripheralPermitted(extension())) {
802 error_ = kErrorPermissionDenied;
803 SendResponse(false);
804 return false;
805 }
806
807 BluetoothLowEnergyEventRouter* event_router =
808 GetEventRouter(browser_context());
809
810 // The adapter must be initialized at this point, but return an error instead
811 // of asserting.
812 if (!event_router->HasAdapter()) {
813 SetError(kErrorAdapterNotInitialized);
814 SendResponse(false);
815 return false;
816 }
817
818 scoped_ptr<apibtle::RegisterAdvertisement::Params> params(
819 apibtle::RegisterAdvertisement::Params::Create(*args_));
820 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL);
821
822 // TODO(rkc): Implement this function.
823
824 return true;
825 }
826
827 // UnregisterAdvertisement:
828
829 bool BluetoothLowEnergyUnregisterAdvertisementFunction::DoWork() {
830 DCHECK_CURRENTLY_ON(BrowserThread::UI);
831
832 if (!BluetoothManifestData::CheckPeripheralPermitted(extension())) {
833 error_ = kErrorPermissionDenied;
834 SendResponse(false);
835 return false;
836 }
837
838 BluetoothLowEnergyEventRouter* event_router =
839 GetEventRouter(browser_context());
840
841 // If we don't have an initialized adapter, unregistering is a no-op.
842 if (!event_router->HasAdapter())
843 return true;
844
845 scoped_ptr<apibtle::UnregisterAdvertisement::Params> params(
846 apibtle::UnregisterAdvertisement::Params::Create(*args_));
847 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL);
848
849 // TODO(rkc): Implement this function.
850
851 return true;
852 }
853
796 } // namespace core_api 854 } // namespace core_api
797 } // namespace extensions 855 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698