Thread triggering event info into OpenURLParams

The OpenURLParams has knowledge of user_gesture, which is great to feed
into the existing popup blocking heuristics. However, it is very common
for sites to "steal" a user gesture to use for script-initiated
(click-jacking) popups / navigations.

This CL threads an additional bit of information through via IPC to
the OpenURLParams: the trusted state of the JS triggering event which led to
this navigation request.

Docs for Event.isTrusted can be found here:
https://developer.mozilla.org/en-US/docs/Web/API/Event/isTrusted

This extra bit can be used to explore additional popup blocking heuristics,
and is planned to be used in conjunction with the subresource_filter
component.

Bug: 733330
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_site_isolation
Change-Id: Iac45ed4800989b45a006483b5e6a6b943e6c5af9
Reviewed-on: https://chromium-review.googlesource.com/539898
Commit-Queue: Charlie Harrison <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Nasko Oskov <[email protected]>
Cr-Commit-Position: refs/heads/master@{#481112}
diff --git a/content/browser/frame_host/navigator.h b/content/browser/frame_host/navigator.h
index 424d828..c21d286 100644
--- a/content/browser/frame_host/navigator.h
+++ b/content/browser/frame_host/navigator.h
@@ -11,6 +11,7 @@
 #include "content/browser/frame_host/navigator_delegate.h"
 #include "content/common/content_export.h"
 #include "content/public/browser/navigation_controller.h"
+#include "third_party/WebKit/public/web/WebTriggeringEventInfo.h"
 #include "ui/base/window_open_disposition.h"
 
 class GURL;
@@ -123,7 +124,8 @@
       WindowOpenDisposition disposition,
       bool force_new_process_for_new_contents,
       bool should_replace_current_entry,
-      bool user_gesture) {}
+      bool user_gesture,
+      blink::WebTriggeringEventInfo triggering_event_info) {}
 
   // The RenderFrameHostImpl wants to transfer the request to a new renderer.
   // |redirect_chain| contains any redirect URLs (excluding |url|) that happened
diff --git a/content/browser/frame_host/navigator_impl.cc b/content/browser/frame_host/navigator_impl.cc
index c51df45d..f21afa5 100644
--- a/content/browser/frame_host/navigator_impl.cc
+++ b/content/browser/frame_host/navigator_impl.cc
@@ -725,7 +725,8 @@
     WindowOpenDisposition disposition,
     bool force_new_process_for_new_contents,
     bool should_replace_current_entry,
-    bool user_gesture) {
+    bool user_gesture,
+    blink::WebTriggeringEventInfo triggering_event_info) {
   // Note: This can be called for subframes (even when OOPIFs are not possible)
   // if the disposition calls for a different window.
 
@@ -775,6 +776,7 @@
     params.redirect_chain = redirect_chain;
   params.should_replace_current_entry = should_replace_current_entry;
   params.user_gesture = user_gesture;
+  params.triggering_event_info = triggering_event_info;
 
   // RequestOpenURL is used only for local frames, so we can get here only if
   // the navigation is initiated by a frame in the same SiteInstance as this
diff --git a/content/browser/frame_host/navigator_impl.h b/content/browser/frame_host/navigator_impl.h
index 648e209..32fabc7 100644
--- a/content/browser/frame_host/navigator_impl.h
+++ b/content/browser/frame_host/navigator_impl.h
@@ -64,16 +64,18 @@
                               bool is_same_document_history_load) override;
   bool NavigateNewChildFrame(RenderFrameHostImpl* render_frame_host,
                              const GURL& default_url) override;
-  void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
-                      const GURL& url,
-                      bool uses_post,
-                      const scoped_refptr<ResourceRequestBodyImpl>& body,
-                      const std::string& extra_headers,
-                      const Referrer& referrer,
-                      WindowOpenDisposition disposition,
-                      bool force_new_process_for_new_contents,
-                      bool should_replace_current_entry,
-                      bool user_gesture) override;
+  void RequestOpenURL(
+      RenderFrameHostImpl* render_frame_host,
+      const GURL& url,
+      bool uses_post,
+      const scoped_refptr<ResourceRequestBodyImpl>& body,
+      const std::string& extra_headers,
+      const Referrer& referrer,
+      WindowOpenDisposition disposition,
+      bool force_new_process_for_new_contents,
+      bool should_replace_current_entry,
+      bool user_gesture,
+      blink::WebTriggeringEventInfo triggering_event_info) override;
   void RequestTransferURL(RenderFrameHostImpl* render_frame_host,
                           const GURL& url,
                           SiteInstance* source_site_instance,
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc
index c1a3487..09ea3e64 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -1287,7 +1287,7 @@
       this, validated_url, params.uses_post, params.resource_request_body,
       params.extra_headers, params.referrer, params.disposition,
       kForceNewProcessForNewContents, params.should_replace_current_entry,
-      params.user_gesture);
+      params.user_gesture, params.triggering_event_info);
 }
 
 void RenderFrameHostImpl::OnCancelInitialHistoryLoad() {