| Index: chrome/browser/engagement/site_engagement_helper.h
|
| diff --git a/chrome/browser/engagement/site_engagement_helper.h b/chrome/browser/engagement/site_engagement_helper.h
|
| index c3883d5cf41a1363e67469f1c0e0bcf2d7635844..431da1d19a02e99d94a8ce920c3ed2f5a7dd5c89 100644
|
| --- a/chrome/browser/engagement/site_engagement_helper.h
|
| +++ b/chrome/browser/engagement/site_engagement_helper.h
|
| @@ -6,6 +6,8 @@
|
| #define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_HELPER_H_
|
|
|
| #include "base/macros.h"
|
| +#include "base/timer/timer.h"
|
| +#include "content/public/browser/render_view_host.h"
|
| #include "content/public/browser/web_contents_observer.h"
|
| #include "content/public/browser/web_contents_user_data.h"
|
|
|
| @@ -16,7 +18,14 @@ class WebContents;
|
| class GURL;
|
|
|
| // Per-WebContents class to handle updating the site engagement scores for
|
| -// origins as the user navigates.
|
| +// origins based on the time spent on site.
|
| +//
|
| +// Time on site is recorded by detecting any user input (mouse or keypress) per
|
| +// some discrete time unit. If there is user input, then record a positive site
|
| +// engagement.
|
| +//
|
| +// TODO(dominickn): account for use cases where user input is not a good proxy
|
| +// for time on site: e.g. watching videos.
|
| class SiteEngagementHelper
|
| : public content::WebContentsObserver,
|
| public content::WebContentsUserData<SiteEngagementHelper> {
|
| @@ -27,11 +36,42 @@ class SiteEngagementHelper
|
| explicit SiteEngagementHelper(content::WebContents* web_contents);
|
| friend class content::WebContentsUserData<SiteEngagementHelper>;
|
|
|
| + // Callback to register key press events from the RenderViewHost.
|
| + bool HandleKeyPressEvent(const content::NativeWebKeyboardEvent& event);
|
| +
|
| + // Callback to register mouse events from the RenderViewHost.
|
| + bool HandleMouseEvent(const blink::WebMouseEvent& event);
|
| +
|
| + void RegisterInputCallbacks(content::RenderViewHost* host);
|
| +
|
| + void RemoveInputCallbacks(content::RenderViewHost* host);
|
| +
|
| + void StartTimer();
|
| +
|
| + // Callback that is fired at regular intervals to record site engagement based
|
| + // on user input.
|
| + void TimerFired();
|
| +
|
| // content::WebContentsObserver overrides.
|
| void DidStartNavigationToPendingEntry(
|
| const GURL& url,
|
| content::NavigationController::ReloadType reload_type) override;
|
|
|
| + void RenderViewHostChanged(content::RenderViewHost* old_host,
|
| + content::RenderViewHost* new_host) override;
|
| +
|
| + void WasShown() override;
|
| +
|
| + void WasHidden() override;
|
| +
|
| + content::RenderWidgetHost::KeyPressEventCallback key_press_event_callback_;
|
| + content::RenderWidgetHost::MouseEventCallback mouse_event_callback_;
|
| +
|
| + bool user_input_recorded_;
|
| + bool callbacks_added_;
|
| + bool ignore_page_;
|
| + base::RepeatingTimer<SiteEngagementHelper> timer_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(SiteEngagementHelper);
|
| };
|
|
|
|
|