Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Side by Side Diff: content/browser/bluetooth/bluetooth_blacklist.h

Issue 1922923002: bluetooth: Move requestDevice to mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-separate-tests-request-device
Patch Set: Remove debug log Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_BLACKLIST_H_ 5 #ifndef CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_BLACKLIST_H_
6 #define CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_BLACKLIST_H_ 6 #define CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_BLACKLIST_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/strings/string_piece.h" 13 #include "base/strings/string_piece.h"
14 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
15 #include "device/bluetooth/bluetooth_uuid.h" 15 #include "device/bluetooth/bluetooth_uuid.h"
16 #include "third_party/WebKit/public/platform/modules/bluetooth/web_bluetooth.moj om.h"
16 17
17 namespace content { 18 namespace content {
18 19
19 struct BluetoothScanFilter;
20
21 // Implements the Web Bluetooth Blacklist policy as defined in the Web Bluetooth 20 // Implements the Web Bluetooth Blacklist policy as defined in the Web Bluetooth
22 // specification: 21 // specification:
23 // https://webbluetoothcg.github.io/web-bluetooth/#the-gatt-blacklist 22 // https://webbluetoothcg.github.io/web-bluetooth/#the-gatt-blacklist
24 // 23 //
25 // Client code may query UUIDs to determine if they are excluded from use by the 24 // Client code may query UUIDs to determine if they are excluded from use by the
26 // blacklist. 25 // blacklist.
27 // 26 //
28 // Singleton access via Get() enforces only one copy of blacklist. 27 // Singleton access via Get() enforces only one copy of blacklist.
29 class CONTENT_EXPORT BluetoothBlacklist final { 28 class CONTENT_EXPORT BluetoothBlacklist final {
30 public: 29 public:
(...skipping 27 matching lines...) Expand all
58 // 57 //
59 // Malformed pairs in the string are ignored, including invalid UUID or 58 // Malformed pairs in the string are ignored, including invalid UUID or
60 // exclusion values. Duplicate UUIDs follow Add()'s merging rule. 59 // exclusion values. Duplicate UUIDs follow Add()'s merging rule.
61 void Add(base::StringPiece blacklist_string); 60 void Add(base::StringPiece blacklist_string);
62 61
63 // Returns if a UUID is excluded from all operations. UUID must be valid. 62 // Returns if a UUID is excluded from all operations. UUID must be valid.
64 bool IsExcluded(const device::BluetoothUUID&) const; 63 bool IsExcluded(const device::BluetoothUUID&) const;
65 64
66 // Returns if any UUID in a set of filters is excluded from all operations. 65 // Returns if any UUID in a set of filters is excluded from all operations.
67 // UUID must be valid. 66 // UUID must be valid.
68 bool IsExcluded(const std::vector<content::BluetoothScanFilter>&); 67 bool IsExcluded(
68 const mojo::Array<blink::mojom::WebBluetoothScanFilterPtr>& filters);
69 69
70 // Returns if a UUID is excluded from read operations. UUID must be valid. 70 // Returns if a UUID is excluded from read operations. UUID must be valid.
71 bool IsExcludedFromReads(const device::BluetoothUUID&) const; 71 bool IsExcludedFromReads(const device::BluetoothUUID&) const;
72 72
73 // Returns if a UUID is excluded from write operations. UUID must be valid. 73 // Returns if a UUID is excluded from write operations. UUID must be valid.
74 bool IsExcludedFromWrites(const device::BluetoothUUID&) const; 74 bool IsExcludedFromWrites(const device::BluetoothUUID&) const;
75 75
76 // Modifies a list of UUIDs, removing any UUIDs with Value::EXCLUDE. 76 // Modifies |options->optional_services|, removing any UUIDs with
77 void RemoveExcludedUuids(std::vector<device::BluetoothUUID>*); 77 // Value::EXCLUDE.
78 void RemoveExcludedUUIDs(
79 blink::mojom::WebBluetoothRequestDeviceOptions* options);
78 80
79 // Size of blacklist. 81 // Size of blacklist.
80 size_t size() { return blacklisted_uuids_.size(); } 82 size_t size() { return blacklisted_uuids_.size(); }
81 83
82 void ResetToDefaultValuesForTest(); 84 void ResetToDefaultValuesForTest();
83 85
84 private: 86 private:
85 // friend LazyInstance to permit access to private constructor. 87 // friend LazyInstance to permit access to private constructor.
86 friend base::DefaultLazyInstanceTraits<BluetoothBlacklist>; 88 friend base::DefaultLazyInstanceTraits<BluetoothBlacklist>;
87 89
88 BluetoothBlacklist(); 90 BluetoothBlacklist();
89 91
90 void PopulateWithDefaultValues(); 92 void PopulateWithDefaultValues();
91 93
92 // Populates blacklist with values obtained dynamically from a server, able 94 // Populates blacklist with values obtained dynamically from a server, able
93 // to be updated without shipping new executable versions. 95 // to be updated without shipping new executable versions.
94 void PopulateWithServerProvidedValues(); 96 void PopulateWithServerProvidedValues();
95 97
96 // Map of UUID to blacklisted value. 98 // Map of UUID to blacklisted value.
97 std::map<device::BluetoothUUID, Value> blacklisted_uuids_; 99 std::map<device::BluetoothUUID, Value> blacklisted_uuids_;
98 100
99 DISALLOW_COPY_AND_ASSIGN(BluetoothBlacklist); 101 DISALLOW_COPY_AND_ASSIGN(BluetoothBlacklist);
100 }; 102 };
101 103
102 } // namespace content 104 } // namespace content
103 105
104 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_BLACKLIST_H_ 106 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_BLACKLIST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698