| 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 #include "content/browser/bluetooth/bluetooth_blacklist.h" | 5 #include "content/browser/bluetooth/bluetooth_blacklist.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "content/common/bluetooth/bluetooth_scan_filter.h" | 10 #include "content/common/bluetooth/bluetooth_scan_filter.h" |
| 11 #include "content/public/browser/content_browser_client.h" |
| 11 | 12 |
| 12 using device::BluetoothUUID; | 13 using device::BluetoothUUID; |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 static base::LazyInstance<content::BluetoothBlacklist>::Leaky g_singleton = | 17 static base::LazyInstance<content::BluetoothBlacklist>::Leaky g_singleton = |
| 17 LAZY_INSTANCE_INITIALIZER; | 18 LAZY_INSTANCE_INITIALIZER; |
| 18 | 19 |
| 19 void RecordUMAParsedNonEmptyString(bool success) { | 20 void RecordUMAParsedNonEmptyString(bool success) { |
| 20 UMA_HISTOGRAM_BOOLEAN("Bluetooth.Web.Blacklist.ParsedNonEmptyString", | 21 UMA_HISTOGRAM_BOOLEAN("Bluetooth.Web.Blacklist.ParsedNonEmptyString", |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 it = uuids->erase(it); | 121 it = uuids->erase(it); |
| 121 } else { | 122 } else { |
| 122 it++; | 123 it++; |
| 123 } | 124 } |
| 124 } | 125 } |
| 125 } | 126 } |
| 126 | 127 |
| 127 void BluetoothBlacklist::ResetToDefaultValuesForTest() { | 128 void BluetoothBlacklist::ResetToDefaultValuesForTest() { |
| 128 blacklisted_uuids_.clear(); | 129 blacklisted_uuids_.clear(); |
| 129 PopulateWithDefaultValues(); | 130 PopulateWithDefaultValues(); |
| 131 PopulateWithServerProvidedValues(); |
| 130 } | 132 } |
| 131 | 133 |
| 132 BluetoothBlacklist::BluetoothBlacklist() { | 134 BluetoothBlacklist::BluetoothBlacklist() { |
| 133 PopulateWithDefaultValues(); | 135 PopulateWithDefaultValues(); |
| 136 PopulateWithServerProvidedValues(); |
| 134 } | 137 } |
| 135 | 138 |
| 136 void BluetoothBlacklist::PopulateWithDefaultValues() { | 139 void BluetoothBlacklist::PopulateWithDefaultValues() { |
| 137 blacklisted_uuids_.clear(); | 140 blacklisted_uuids_.clear(); |
| 138 | 141 |
| 139 // Blacklist UUIDs updated 2016-02-12 from: | 142 // Blacklist UUIDs updated 2016-02-12 from: |
| 140 // https://github.com/WebBluetoothCG/registries/blob/master/gatt_blacklist.txt | 143 // https://github.com/WebBluetoothCG/registries/blob/master/gatt_blacklist.txt |
| 141 // Short UUIDs are used for readability of this list. | 144 // Short UUIDs are used for readability of this list. |
| 142 // | 145 // |
| 143 // Testing from Layout Tests Note: | 146 // Testing from Layout Tests Note: |
| (...skipping 21 matching lines...) Expand all Loading... |
| 165 Value::EXCLUDE_READS); | 168 Value::EXCLUDE_READS); |
| 166 // Descriptors: | 169 // Descriptors: |
| 167 Add(BluetoothUUID("2902"), Value::EXCLUDE_WRITES); | 170 Add(BluetoothUUID("2902"), Value::EXCLUDE_WRITES); |
| 168 Add(BluetoothUUID("2903"), Value::EXCLUDE_WRITES); | 171 Add(BluetoothUUID("2903"), Value::EXCLUDE_WRITES); |
| 169 // Descriptors for Layout Tests: | 172 // Descriptors for Layout Tests: |
| 170 Add(BluetoothUUID("bad2ddcf-60db-45cd-bef9-fd72b153cf7c"), Value::EXCLUDE); | 173 Add(BluetoothUUID("bad2ddcf-60db-45cd-bef9-fd72b153cf7c"), Value::EXCLUDE); |
| 171 Add(BluetoothUUID("bad3ec61-3cc3-4954-9702-7977df514114"), | 174 Add(BluetoothUUID("bad3ec61-3cc3-4954-9702-7977df514114"), |
| 172 Value::EXCLUDE_READS); | 175 Value::EXCLUDE_READS); |
| 173 } | 176 } |
| 174 | 177 |
| 178 void BluetoothBlacklist::PopulateWithServerProvidedValues() { |
| 179 Add(GetContentClient()->browser()->GetWebBluetoothBlacklist()); |
| 180 } |
| 181 |
| 175 } // namespace content | 182 } // namespace content |
| OLD | NEW |