Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 // combination of the two, E.G.: | 46 // combination of the two, E.G.: |
| 47 // Add(uuid, EXCLUDE_READS); | 47 // Add(uuid, EXCLUDE_READS); |
| 48 // Add(uuid, EXCLUDE_WRITES); | 48 // Add(uuid, EXCLUDE_WRITES); |
| 49 // IsExcluded(uuid); // true. | 49 // IsExcluded(uuid); // true. |
| 50 // Requires UUID to be valid. | 50 // Requires UUID to be valid. |
| 51 void Add(const device::BluetoothUUID&, Value); | 51 void Add(const device::BluetoothUUID&, Value); |
| 52 | 52 |
| 53 // Adds UUIDs to the blacklist by parsing a blacklist string and calling | 53 // Adds UUIDs to the blacklist by parsing a blacklist string and calling |
| 54 // Add(uuid, value). | 54 // Add(uuid, value). |
| 55 // | 55 // |
| 56 // The blacklist string must be a comma-separated list of UUID:exclusion | 56 // The blacklist string format is defined at |
| 57 // pairs. The pairs may be separated by whitespace. Pair components are | 57 // ContentBrowserClient::GetWebBluetoothBlacklist(). |
| 58 // colon-separated and must not have whitespace around the colon. | |
| 59 // | |
| 60 // UUIDs are a string that BluetoothUUID can parse (See BluetoothUUID | |
| 61 // constructor comment). Exclusion values are a single lower case character | |
| 62 // string "e", "r", or "w" for EXCLUDE, EXCLUDE_READS, or EXCLUDE_WRITES. | |
| 63 // | 58 // |
| 64 // Malformed pairs in the string are ignored, including invalid UUID or | 59 // Malformed pairs in the string are ignored, including invalid UUID or |
| 65 // exclusion values. Duplicate UUIDs follow Add()'s merging rule. | 60 // exclusion values. Duplicate UUIDs follow Add()'s merging rule. |
| 66 // | |
| 67 // Example: | |
| 68 // "1812:e, 00001800-0000-1000-8000-00805f9b34fb:w, ignored:1, alsoignored." | |
| 69 void Add(base::StringPiece blacklist_string); | 61 void Add(base::StringPiece blacklist_string); |
| 70 | 62 |
| 71 // Returns if a UUID is excluded from all operations. UUID must be valid. | 63 // Returns if a UUID is excluded from all operations. UUID must be valid. |
| 72 bool IsExcluded(const device::BluetoothUUID&) const; | 64 bool IsExcluded(const device::BluetoothUUID&) const; |
| 73 | 65 |
| 74 // Returns if any UUID in a set of filters is excluded from all operations. | 66 // Returns if any UUID in a set of filters is excluded from all operations. |
| 75 // UUID must be valid. | 67 // UUID must be valid. |
| 76 bool IsExcluded(const std::vector<content::BluetoothScanFilter>&); | 68 bool IsExcluded(const std::vector<content::BluetoothScanFilter>&); |
| 77 | 69 |
| 78 // 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. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 90 void ResetToDefaultValuesForTest(); | 82 void ResetToDefaultValuesForTest(); |
| 91 | 83 |
| 92 private: | 84 private: |
| 93 // friend LazyInstance to permit access to private constructor. | 85 // friend LazyInstance to permit access to private constructor. |
| 94 friend base::DefaultLazyInstanceTraits<BluetoothBlacklist>; | 86 friend base::DefaultLazyInstanceTraits<BluetoothBlacklist>; |
| 95 | 87 |
| 96 BluetoothBlacklist(); | 88 BluetoothBlacklist(); |
| 97 | 89 |
| 98 void PopulateWithDefaultValues(); | 90 void PopulateWithDefaultValues(); |
| 99 | 91 |
| 92 // Populates blacklist with values obtained dynamically from a server, able | |
| 93 // to be updated at any time. | |
|
Jeffrey Yasskin
2016/04/05 17:58:55
This is still only updated on restart, right?
scheib
2016/04/05 18:43:37
Done.
| |
| 94 void PopulateWithServerProvidedValues(); | |
| 95 | |
| 100 // Map of UUID to blacklisted value. | 96 // Map of UUID to blacklisted value. |
| 101 std::map<device::BluetoothUUID, Value> blacklisted_uuids_; | 97 std::map<device::BluetoothUUID, Value> blacklisted_uuids_; |
| 102 | 98 |
| 103 DISALLOW_COPY_AND_ASSIGN(BluetoothBlacklist); | 99 DISALLOW_COPY_AND_ASSIGN(BluetoothBlacklist); |
| 104 }; | 100 }; |
| 105 | 101 |
| 106 } // namespace content | 102 } // namespace content |
| 107 | 103 |
| 108 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_BLACKLIST_H_ | 104 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_BLACKLIST_H_ |
| OLD | NEW |