OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_METRICS_DESKTOP_ENGAGEMENT_DESKTOP_ENGAGEMENT_OBSERVER_H_ | |
6 #define CHROME_BROWSER_METRICS_DESKTOP_ENGAGEMENT_DESKTOP_ENGAGEMENT_OBSERVER_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "content/public/browser/render_widget_host.h" | |
10 #include "content/public/browser/web_contents.h" | |
11 #include "content/public/browser/web_contents_observer.h" | |
12 #include "content/public/browser/web_contents_user_data.h" | |
13 #include "third_party/WebKit/public/web/WebInputEvent.h" | |
14 | |
15 namespace metrics { | |
16 | |
17 class DesktopEngagementService; | |
18 | |
19 // Tracks user input events from web contents and notifies | |
20 // |DesktopEngagementService|. | |
21 class DesktopEngagementObserver | |
22 : public content::WebContentsObserver, | |
23 public content::WebContentsUserData<DesktopEngagementObserver>, | |
24 public content::RenderWidgetHost::InputEventObserver { | |
25 public: | |
26 DesktopEngagementObserver(content::WebContents* web_contents, | |
27 DesktopEngagementService* service); | |
28 ~DesktopEngagementObserver() override; | |
29 | |
30 static DesktopEngagementObserver* CreateForWebContents( | |
31 content::WebContents* web_contents); | |
32 | |
33 private: | |
34 friend class content::WebContentsUserData<DesktopEngagementObserver>; | |
35 | |
36 // Register / Unregister input event callback to given RenderViewHost | |
37 void RegisterInputEventObserver(content::RenderViewHost* host); | |
38 void UnregisterInputEventObserver(content::RenderViewHost* host); | |
39 | |
40 // content::RenderWidgetHost::InputEventObserver: | |
41 void OnInputEvent(const blink::WebInputEvent& event) override; | |
42 | |
43 // content::WebContentsObserver: | |
44 void RenderViewHostChanged(content::RenderViewHost* old_host, | |
45 content::RenderViewHost* new_host) override; | |
46 | |
47 DesktopEngagementService* service_; | |
48 | |
49 DISALLOW_COPY_AND_ASSIGN(DesktopEngagementObserver); | |
50 }; | |
51 | |
52 } // namespace metrics | |
53 | |
54 #endif // CHROME_BROWSER_METRICS_DESKTOP_ENGAGEMENT_DESKTOP_ENGAGEMENT_OBSERVER
_H_ | |
OLD | NEW |