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

Unified Diff: device/usb/webusb_descriptors.cc

Issue 1739523002: WebUsb Android chooser UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase and added NoUnderlineClickableSpan.java to ui/android/BUILD.gn 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/usb/webusb_descriptors.h ('k') | ui/android/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/webusb_descriptors.cc
diff --git a/device/usb/webusb_descriptors.cc b/device/usb/webusb_descriptors.cc
index de2309e1a10f98c2b678df3585c2db71789a7af5..bdd23a78b60779bdeb4f5f35b8aea192ea92d0a8 100644
--- a/device/usb/webusb_descriptors.cc
+++ b/device/usb/webusb_descriptors.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "device/usb/webusb_descriptors.h"
+
#include <stddef.h>
#include <iterator>
@@ -12,9 +14,9 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/logging.h"
+#include "base/stl_util.h"
#include "components/device_event_log/device_event_log.h"
#include "device/usb/usb_device_handle.h"
-#include "device/usb/webusb_descriptors.h"
#include "net/base/io_buffer.h"
using net::IOBufferWithSize;
@@ -567,4 +569,26 @@ void ReadWebUsbDescriptors(scoped_refptr<UsbDeviceHandle> device_handle,
base::Bind(&OnReadBosDescriptorHeader, device_handle, callback));
}
+bool FindInWebUsbAllowedOrigins(
+ const device::WebUsbAllowedOrigins* allowed_origins,
+ const GURL& origin) {
+ if (!allowed_origins)
+ return false;
+
+ if (ContainsValue(allowed_origins->origins, origin))
+ return true;
+
+ for (const auto& config : allowed_origins->configurations) {
+ if (ContainsValue(config.origins, origin))
+ return true;
+
+ for (const auto& function : config.functions) {
+ if (ContainsValue(function.origins, origin))
+ return true;
+ }
+ }
+
+ return false;
+}
+
} // namespace device
« no previous file with comments | « device/usb/webusb_descriptors.h ('k') | ui/android/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698