Blink roll 25b6bd3a7a131ffe68d809546ad1a20707915cdc:3a503f41ae42e5b79cfcd2ff10e65afde...
[chromium-blink-merge.git] / extensions / common / api / bluetooth / bluetooth_manifest_data.h
blobe4c489d8bf8a80c15d2e201144390a9d0a5ab5e0
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 #ifndef EXTENSIONS_COMMON_API_BLUETOOTH_BLUETOOTH_MANIFEST_DATA_H_
6 #define EXTENSIONS_COMMON_API_BLUETOOTH_BLUETOOTH_MANIFEST_DATA_H_
8 #include <vector>
10 #include "base/strings/string16.h"
11 #include "extensions/common/extension.h"
12 #include "extensions/common/manifest_handler.h"
14 namespace extensions {
15 class BluetoothManifestPermission;
16 struct BluetoothPermissionRequest;
19 namespace extensions {
21 // The parsed form of the "bluetooth" manifest entry.
22 class BluetoothManifestData : public Extension::ManifestData {
23 public:
24 explicit BluetoothManifestData(
25 scoped_ptr<BluetoothManifestPermission> permission);
26 ~BluetoothManifestData() override;
28 // Gets the BluetoothManifestData for |extension|, or NULL if none was
29 // specified.
30 static BluetoothManifestData* Get(const Extension* extension);
32 static bool CheckRequest(const Extension* extension,
33 const BluetoothPermissionRequest& request);
35 static bool CheckSocketPermitted(const Extension* extension);
36 static bool CheckLowEnergyPermitted(const Extension* extension);
38 // Tries to construct the info based on |value|, as it would have appeared in
39 // the manifest. Sets |error| and returns an empty scoped_ptr on failure.
40 static scoped_ptr<BluetoothManifestData> FromValue(const base::Value& value,
41 base::string16* error);
43 const BluetoothManifestPermission* permission() const {
44 return permission_.get();
47 private:
48 scoped_ptr<BluetoothManifestPermission> permission_;
51 // Used for checking bluetooth permission.
52 struct BluetoothPermissionRequest {
53 explicit BluetoothPermissionRequest(const std::string& uuid);
54 ~BluetoothPermissionRequest();
56 std::string uuid;
59 } // namespace extensions
61 #endif // EXTENSIONS_COMMON_API_BLUETOOTH_BLUETOOTH_MANIFEST_DATA_H_