usb: Move WebUsbServiceImpl to //content
This CL moves the implementation of the blink::mojom::WebUsbService
mojo interface from the embedder layer to the content layer.
Ownership of the UsbDelegate is moved from WebUsbServiceImpl to
the ContentBrowserClient which now has a GetUsbDelegate method.
Previously, the lifetime of WebUsbServiceImpl was managed by
FrameUsbServices. Now it is a self-owned DocumentUserData with
the same lifetime.
Previously, UsbTabHelper managed the connected USB device state.
Now WebContentsImpl manages this state and clients observe
WebContents directly.
Browser tests (//chrome/browser/usb/usb_browsertest.cc) and unit
tests (//chrome/browser/usb/web_usb_service_impl_unittest.cc) are
moved to //content but the embedder-specific versions of the tests
are retained as chrome_usb_browsertest.cc and
chrome_usb_delegate_unittest.cc.
Bug: 991759, 1220314
Change-Id: I2ed528acc6dbc5667ae22b9219a1320226792a40
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3671829
Commit-Queue: Matt Reynolds <[email protected]>
Reviewed-by: Kinuko Yasuda <[email protected]>
Reviewed-by: Reilly Grant <[email protected]>
Reviewed-by: Dana Fried <[email protected]>
Reviewed-by: Francois Pierre Doray <[email protected]>
Reviewed-by: Brandon Jones <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1036771}
diff --git a/chrome/browser/usb/android/usb_bridge.cc b/chrome/browser/usb/android/usb_bridge.cc
index 6787faec..68e42622 100644
--- a/chrome/browser/usb/android/usb_bridge.cc
+++ b/chrome/browser/usb/android/usb_bridge.cc
@@ -3,15 +3,11 @@
// found in the LICENSE file.
#include "chrome/browser/usb/android/jni_headers/UsbBridge_jni.h"
-#include "chrome/browser/usb/usb_tab_helper.h"
#include "content/public/browser/web_contents.h"
jboolean JNI_UsbBridge_IsWebContentsConnectedToUsbDevice(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& java_web_contents) {
- content::WebContents* web_contents =
- content::WebContents::FromJavaWebContents(java_web_contents);
-
- UsbTabHelper* usb_tab_helper = UsbTabHelper::FromWebContents(web_contents);
- return (usb_tab_helper && usb_tab_helper->IsDeviceConnected());
+ return content::WebContents::FromJavaWebContents(java_web_contents)
+ ->IsConnectedToUsbDevice();
}