OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/usb/usb_common.h" |
| 6 |
| 7 #include "base/metrics/histogram_macros.h" |
| 8 #include "base/stl_util.h" |
| 9 #include "device/usb/webusb_descriptors.h" |
| 10 #include "url/gurl.h" |
| 11 |
| 12 void RecordChooserClosure(WebUsbChooserClosed disposition) { |
| 13 UMA_HISTOGRAM_ENUMERATION("WebUsb.ChooserClosed", disposition, |
| 14 WEBUSB_CHOOSER_CLOSED_MAX); |
| 15 } |
| 16 |
| 17 // Check if the origin is allowed. |
| 18 bool FindInAllowedOrigins(const device::WebUsbAllowedOrigins* allowed_origins, |
| 19 const GURL& origin) { |
| 20 if (!allowed_origins) |
| 21 return false; |
| 22 |
| 23 if (ContainsValue(allowed_origins->origins, origin)) |
| 24 return true; |
| 25 |
| 26 for (const auto& config : allowed_origins->configurations) { |
| 27 if (ContainsValue(config.origins, origin)) |
| 28 return true; |
| 29 |
| 30 for (const auto& function : config.functions) { |
| 31 if (ContainsValue(function.origins, origin)) |
| 32 return true; |
| 33 } |
| 34 } |
| 35 |
| 36 return false; |
| 37 } |
OLD | NEW |