Use the origin/name of the main frame in chooser dialogs

Permissions dialogs (for WebUSB, WebHID, and Web Serial) should request
permission for the main origin (the origin embedding the iframe) and not
the site hosting the iframe as per crbug.com/802945. Update the UI code
to accurately display the main origin (or extension name) and add tests.

Bug: 1280233
Change-Id: Ia3bf9274eb49c1d842e204a518635cc1187f3d3d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3353956
Reviewed-by: Scott Violet <[email protected]>
Reviewed-by: Andy Paicu <[email protected]>
Commit-Queue: Reilly Grant <[email protected]>
Cr-Commit-Position: refs/heads/main@{#963184}
diff --git a/chrome/browser/chooser_controller/title_util.cc b/chrome/browser/chooser_controller/title_util.cc
index 439247f..7c45abe 100644
--- a/chrome/browser/chooser_controller/title_util.cc
+++ b/chrome/browser/chooser_controller/title_util.cc
@@ -22,6 +22,8 @@
     int title_string_id_extension) {
   if (!render_frame_host)
     return u"";
+  // Ensure the permission request is attributed to the main frame.
+  render_frame_host = render_frame_host->GetMainFrame();
 
 #if BUILDFLAG(ENABLE_EXTENSIONS)
   url::Origin origin = render_frame_host->GetLastCommittedOrigin();