Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / extensions / common / api / bluetooth / bluetooth_manifest_data.cc
blobcb85e08ba65ebaa440b53ed0a84415e23134931f
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
3 // found in the LICENSE file.
5 #include "extensions/common/api/bluetooth/bluetooth_manifest_data.h"
7 #include "extensions/common/api/bluetooth/bluetooth_manifest_permission.h"
8 #include "extensions/common/manifest_constants.h"
10 namespace extensions {
12 BluetoothManifestData::BluetoothManifestData(
13 scoped_ptr<BluetoothManifestPermission> permission)
14 : permission_(permission.Pass()) {
15 DCHECK(permission_);
18 BluetoothManifestData::~BluetoothManifestData() {}
20 // static
21 BluetoothManifestData* BluetoothManifestData::Get(const Extension* extension) {
22 return static_cast<BluetoothManifestData*>(
23 extension->GetManifestData(manifest_keys::kBluetooth));
26 // static
27 bool BluetoothManifestData::CheckRequest(
28 const Extension* extension,
29 const BluetoothPermissionRequest& request) {
30 const BluetoothManifestData* data = BluetoothManifestData::Get(extension);
31 return data && data->permission()->CheckRequest(extension, request);
34 // static
35 bool BluetoothManifestData::CheckSocketPermitted(
36 const Extension* extension) {
37 const BluetoothManifestData* data = BluetoothManifestData::Get(extension);
38 return data && data->permission()->CheckSocketPermitted(extension);
41 // static
42 bool BluetoothManifestData::CheckLowEnergyPermitted(
43 const Extension* extension) {
44 const BluetoothManifestData* data = BluetoothManifestData::Get(extension);
45 return data && data->permission()->CheckLowEnergyPermitted(extension);
48 // static
49 bool BluetoothManifestData::CheckPeripheralPermitted(
50 const Extension* extension) {
51 const BluetoothManifestData* data = BluetoothManifestData::Get(extension);
52 return data && data->permission()->CheckLowEnergyPermitted(extension) &&
53 data->permission()->CheckPeripheralPermitted(extension);
56 // static
57 scoped_ptr<BluetoothManifestData> BluetoothManifestData::FromValue(
58 const base::Value& value,
59 base::string16* error) {
60 scoped_ptr<BluetoothManifestPermission> permission =
61 BluetoothManifestPermission::FromValue(value, error);
62 if (!permission)
63 return scoped_ptr<BluetoothManifestData>();
65 return scoped_ptr<BluetoothManifestData>(
66 new BluetoothManifestData(permission.Pass())).Pass();
69 BluetoothPermissionRequest::BluetoothPermissionRequest(
70 const std::string& uuid)
71 : uuid(uuid) {}
73 BluetoothPermissionRequest::~BluetoothPermissionRequest() {}
75 } // namespace extensions