Notify WebContentsObservers of user interactions.
This CL allows web contents observers to receive notifications of user
input when the contents is focused. User input is taken to be one of:
1. mouse down event
2. raw key down event
3. gesture tap event
The type of input is propagated to the observer, but all other details
are suppressed. This extends the existing
WebContentsObserver::OnUserGesture in two ways:
1. firing on all raw keypress events, instead of only enter and space;
2. providing the input type that triggered the call.
This CL refactors the site engagement service to use the new user
interaction notification in place of registering input callbacks on
RenderWidgetHost. It is intended that other consumers of
WebContentsObserver::OnUserGesture will be migrated to this new
method in a follow-up CL. Consumers of the RenderWidgetHost
mouse and keypress callback API may also be migrated to this
method.
BUG=548011,464234
Review URL: https://codereview.chromium.org/1388293002
Cr-Commit-Position: refs/heads/master@{#356772}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index fa61d69..108f8e92 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -4210,6 +4210,11 @@
rdh->OnUserGesture(this);
}
+void WebContentsImpl::OnUserInteraction(const blink::WebInputEvent::Type type) {
+ FOR_EACH_OBSERVER(WebContentsObserver, observers_,
+ DidGetUserInteraction(type));
+}
+
void WebContentsImpl::OnIgnoredUIEvent() {
// Notify observers.
FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetIgnoredUIEvent());