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

Side by Side Diff: chrome/browser/usb/usb_common.cc

Issue 1739523002: WebUsb Android chooser UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address reillgy@'s comments Created 4 years, 9 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
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698