OLD | NEW |
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 #ifndef EXTENSIONS_COMMON_API_BLUETOOTH_BLUETOOTH_MANIFEST_PERMISSION_H_ | 5 #ifndef EXTENSIONS_COMMON_API_BLUETOOTH_BLUETOOTH_MANIFEST_PERMISSION_H_ |
6 #define EXTENSIONS_COMMON_API_BLUETOOTH_BLUETOOTH_MANIFEST_PERMISSION_H_ | 6 #define EXTENSIONS_COMMON_API_BLUETOOTH_BLUETOOTH_MANIFEST_PERMISSION_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "extensions/common/install_warning.h" | 11 #include "extensions/common/install_warning.h" |
12 #include "extensions/common/permissions/manifest_permission.h" | 12 #include "extensions/common/permissions/manifest_permission.h" |
13 | 13 |
14 namespace extensions { | 14 namespace extensions { |
15 class Extension; | 15 class Extension; |
16 } | 16 } |
17 | 17 |
18 namespace extensions { | 18 namespace extensions { |
19 struct BluetoothPermissionRequest; | 19 struct BluetoothPermissionRequest; |
20 } | 20 } |
21 | 21 |
22 namespace extensions { | 22 namespace extensions { |
23 | 23 |
24 class BluetoothManifestPermission : public ManifestPermission { | 24 class BluetoothManifestPermission : public ManifestPermission { |
25 public: | 25 public: |
26 typedef std::set<std::string> BluetoothUuidSet; | 26 typedef std::set<std::string> BluetoothUuidSet; |
27 BluetoothManifestPermission(); | 27 BluetoothManifestPermission(); |
28 virtual ~BluetoothManifestPermission(); | 28 ~BluetoothManifestPermission() override; |
29 | 29 |
30 // Tries to construct the info based on |value|, as it would have appeared in | 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. | 31 // the manifest. Sets |error| and returns an empty scoped_ptr on failure. |
32 static scoped_ptr<BluetoothManifestPermission> FromValue( | 32 static scoped_ptr<BluetoothManifestPermission> FromValue( |
33 const base::Value& value, | 33 const base::Value& value, |
34 base::string16* error); | 34 base::string16* error); |
35 | 35 |
36 bool CheckRequest(const Extension* extension, | 36 bool CheckRequest(const Extension* extension, |
37 const BluetoothPermissionRequest& request) const; | 37 const BluetoothPermissionRequest& request) const; |
38 bool CheckSocketPermitted(const Extension* extension) const; | 38 bool CheckSocketPermitted(const Extension* extension) const; |
39 bool CheckLowEnergyPermitted(const Extension* extension) const; | 39 bool CheckLowEnergyPermitted(const Extension* extension) const; |
40 | 40 |
41 void AddPermission(const std::string& uuid); | 41 void AddPermission(const std::string& uuid); |
42 | 42 |
43 // extensions::ManifestPermission overrides. | 43 // extensions::ManifestPermission overrides. |
44 virtual std::string name() const override; | 44 std::string name() const override; |
45 virtual std::string id() const override; | 45 std::string id() const override; |
46 virtual bool HasMessages() const override; | 46 bool HasMessages() const override; |
47 virtual PermissionMessages GetMessages() const override; | 47 PermissionMessages GetMessages() const override; |
48 virtual bool FromValue(const base::Value* value) override; | 48 bool FromValue(const base::Value* value) override; |
49 virtual scoped_ptr<base::Value> ToValue() const override; | 49 scoped_ptr<base::Value> ToValue() const override; |
50 virtual ManifestPermission* Diff(const ManifestPermission* rhs) | 50 ManifestPermission* Diff(const ManifestPermission* rhs) const override; |
51 const override; | 51 ManifestPermission* Union(const ManifestPermission* rhs) const override; |
52 virtual ManifestPermission* Union(const ManifestPermission* rhs) | 52 ManifestPermission* Intersect(const ManifestPermission* rhs) const override; |
53 const override; | |
54 virtual ManifestPermission* Intersect(const ManifestPermission* rhs) | |
55 const override; | |
56 | 53 |
57 const BluetoothUuidSet& uuids() const { | 54 const BluetoothUuidSet& uuids() const { |
58 return uuids_; | 55 return uuids_; |
59 } | 56 } |
60 | 57 |
61 private: | 58 private: |
62 BluetoothUuidSet uuids_; | 59 BluetoothUuidSet uuids_; |
63 bool socket_; | 60 bool socket_; |
64 bool low_energy_; | 61 bool low_energy_; |
65 }; | 62 }; |
66 | 63 |
67 } // namespace extensions | 64 } // namespace extensions |
68 | 65 |
69 #endif // EXTENSIONS_COMMON_API_BLUETOOTH_BLUETOOTH_MANIFEST_PERMISSION_H_ | 66 #endif // EXTENSIONS_COMMON_API_BLUETOOTH_BLUETOOTH_MANIFEST_PERMISSION_H_ |
OLD | NEW |