Blink roll 25b6bd3a7a131ffe68d809546ad1a20707915cdc:3a503f41ae42e5b79cfcd2ff10e65afde...
[chromium-blink-merge.git] / extensions / common / api / bluetooth / bluetooth_manifest_permission.h
blobeb71fa4be8c78ef1c325fd975a42c1454f9ee057
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_PERMISSION_H_
6 #define EXTENSIONS_COMMON_API_BLUETOOTH_BLUETOOTH_MANIFEST_PERMISSION_H_
8 #include <set>
9 #include <vector>
11 #include "extensions/common/install_warning.h"
12 #include "extensions/common/permissions/manifest_permission.h"
14 namespace extensions {
15 class Extension;
18 namespace extensions {
19 struct BluetoothPermissionRequest;
22 namespace extensions {
24 class BluetoothManifestPermission : public ManifestPermission {
25 public:
26 typedef std::set<std::string> BluetoothUuidSet;
27 BluetoothManifestPermission();
28 ~BluetoothManifestPermission() override;
30 // Tries to construct the info based on |value|, as it would have appeared in
31 // the manifest. Sets |error| and returns an empty scoped_ptr on failure.
32 static scoped_ptr<BluetoothManifestPermission> FromValue(
33 const base::Value& value,
34 base::string16* error);
36 bool CheckRequest(const Extension* extension,
37 const BluetoothPermissionRequest& request) const;
38 bool CheckSocketPermitted(const Extension* extension) const;
39 bool CheckLowEnergyPermitted(const Extension* extension) const;
41 void AddPermission(const std::string& uuid);
43 // extensions::ManifestPermission overrides.
44 std::string name() const override;
45 std::string id() const override;
46 bool HasMessages() const override;
47 PermissionMessages GetMessages() const override;
48 bool FromValue(const base::Value* value) override;
49 scoped_ptr<base::Value> ToValue() const override;
50 ManifestPermission* Diff(const ManifestPermission* rhs) const override;
51 ManifestPermission* Union(const ManifestPermission* rhs) const override;
52 ManifestPermission* Intersect(const ManifestPermission* rhs) const override;
54 const BluetoothUuidSet& uuids() const {
55 return uuids_;
58 private:
59 BluetoothUuidSet uuids_;
60 bool socket_;
61 bool low_energy_;
64 } // namespace extensions
66 #endif // EXTENSIONS_COMMON_API_BLUETOOTH_BLUETOOTH_MANIFEST_PERMISSION_H_