| Index: chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc
|
| diff --git a/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc b/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc
|
| index 122f6a106839c5fcc0baa0d384135b50992d8a6d..a34580f671f39955f109f5fffe9825a8e96ab18a 100644
|
| --- a/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc
|
| +++ b/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc
|
| @@ -324,6 +324,21 @@ device::BluetoothGattCharacteristic::Permissions GetBluetoothPermissions(
|
| return permissions;
|
| }
|
|
|
| +bool IsAutoLaunchedKioskApp(const ExtensionId& id) {
|
| +#if defined(OS_CHROMEOS)
|
| + chromeos::KioskAppManager::App app_info;
|
| + return chromeos::KioskAppManager::Get()->GetApp(id, &app_info) &&
|
| + app_info.was_auto_launched_with_zero_delay;
|
| +#else
|
| + return false;
|
| +#endif
|
| +}
|
| +
|
| +bool IsPeripheralFlagEnabled() {
|
| + return base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableBLEAdvertising);
|
| +}
|
| +
|
| } // namespace
|
|
|
|
|
| @@ -440,6 +455,11 @@ BLEPeripheralExtensionFunction<Params>::Run() {
|
| if (!BluetoothManifestData::CheckPeripheralPermitted(extension()))
|
| return RespondNow(Error(kErrorPermissionDenied));
|
|
|
| + if (!(IsAutoLaunchedKioskApp(extension()->id()) ||
|
| + IsPeripheralFlagEnabled())) {
|
| + return RespondNow(Error(kErrorPermissionDenied));
|
| + }
|
| +
|
| // Causes link error on Windows. API will never be on Windows, so #ifdefing.
|
| #if !defined(OS_WIN)
|
| params_ = Params::Create(*args_);
|
| @@ -1110,21 +1130,6 @@ void BluetoothLowEnergyAdvertisementFunction::Initialize() {
|
| ApiResourceManager<BluetoothApiAdvertisement>::Get(browser_context());
|
| }
|
|
|
| -static bool IsAutoLaunchedKioskApp(const ExtensionId& id) {
|
| -#if defined(OS_CHROMEOS)
|
| - chromeos::KioskAppManager::App app_info;
|
| - return chromeos::KioskAppManager::Get()->GetApp(id, &app_info) &&
|
| - app_info.was_auto_launched_with_zero_delay;
|
| -#else
|
| - return false;
|
| -#endif
|
| -}
|
| -
|
| -static bool IsPeripheralFlagEnabled() {
|
| - return base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kEnableBLEAdvertising);
|
| -}
|
| -
|
| // RegisterAdvertisement:
|
|
|
| bool BluetoothLowEnergyRegisterAdvertisementFunction::DoWork() {
|
|
|