OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_HELPER_H_ | 5 #ifndef CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_HELPER_H_ |
6 #define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_HELPER_H_ | 6 #define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_HELPER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
10 #include "content/public/browser/render_view_host.h" | 10 #include "content/public/browser/render_view_host.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 // Pause listening for user input, restarting listening after | 56 // Pause listening for user input, restarting listening after |
57 // g_seconds_between_user_input_check seconds. | 57 // g_seconds_between_user_input_check seconds. |
58 void PauseTracking(content::RenderViewHost* host); | 58 void PauseTracking(content::RenderViewHost* host); |
59 | 59 |
60 // Restart listening for user input. | 60 // Restart listening for user input. |
61 void ResumeTracking(); | 61 void ResumeTracking(); |
62 | 62 |
63 // Stop listening for user input. | 63 // Stop listening for user input. |
64 void StopTracking(content::RenderViewHost* host); | 64 void StopTracking(content::RenderViewHost* host); |
65 | 65 |
66 // Returns whether a RenderViewHost is being tracked. | |
67 bool IsTracking(); | |
68 | |
66 // Set the timer object for testing purposes. | 69 // Set the timer object for testing purposes. |
67 void SetTimerForTesting(scoped_ptr<base::Timer> timer); | 70 void SetPauseTimerForTesting(scoped_ptr<base::Timer> timer); |
68 | |
69 bool callbacks_added() { return callbacks_added_; } | |
70 | 71 |
71 private: | 72 private: |
72 SiteEngagementHelper* helper_; | 73 SiteEngagementHelper* helper_; |
73 scoped_ptr<base::Timer> pause_timer_; | 74 scoped_ptr<base::Timer> pause_timer_; |
74 content::RenderWidgetHost::KeyPressEventCallback key_press_event_callback_; | 75 content::RenderWidgetHost::KeyPressEventCallback key_press_event_callback_; |
75 content::RenderWidgetHost::MouseEventCallback mouse_event_callback_; | 76 content::RenderWidgetHost::MouseEventCallback mouse_event_callback_; |
76 bool callbacks_added_; | 77 bool callbacks_added_; |
dominickn
2015/10/06 00:04:41
Nit: rename to is_tracking_ to match the function
calamity
2015/10/06 03:39:55
Done.
| |
77 }; | 78 }; |
78 | 79 |
79 explicit SiteEngagementHelper(content::WebContents* web_contents); | 80 explicit SiteEngagementHelper(content::WebContents* web_contents); |
80 friend class content::WebContentsUserData<SiteEngagementHelper>; | 81 friend class content::WebContentsUserData<SiteEngagementHelper>; |
81 friend class SiteEngagementServiceBrowserTest; | 82 friend class SiteEngagementServiceBrowserTest; |
82 | 83 |
83 // Ask the SiteEngagementService to record engagement via user input at the | 84 // Ask the SiteEngagementService to record engagement via user input at the |
84 // current contents location. | 85 // current contents location. |
85 void RecordUserInput(); | 86 void RecordUserInput(); |
86 | 87 |
87 bool ShouldRecordEngagement(); | 88 bool ShouldRecordEngagement(); |
dominickn
2015/10/06 00:04:41
Nit: remove this declaration since the function is
calamity
2015/10/06 03:39:55
Done.
| |
88 | 89 |
89 // content::WebContentsObserver overrides. | 90 // content::WebContentsObserver overrides. |
90 void DidNavigateMainFrame( | 91 void DidNavigateMainFrame( |
91 const content::LoadCommittedDetails& details, | 92 const content::LoadCommittedDetails& details, |
92 const content::FrameNavigateParams& params) override; | 93 const content::FrameNavigateParams& params) override; |
93 | |
94 void RenderViewHostChanged(content::RenderViewHost* old_host, | 94 void RenderViewHostChanged(content::RenderViewHost* old_host, |
95 content::RenderViewHost* new_host) override; | 95 content::RenderViewHost* new_host) override; |
96 | |
97 void WasShown() override; | 96 void WasShown() override; |
98 void WasHidden() override; | 97 void WasHidden() override; |
99 | 98 |
99 // Set the timer object for testing purposes. | |
100 void SetNavigationTimerForTesting(scoped_ptr<base::Timer> timer); | |
101 void OnNavigationTimerFired(); | |
102 | |
103 scoped_ptr<base::Timer> navigation_timer_; | |
100 InputTracker input_tracker_; | 104 InputTracker input_tracker_; |
101 bool record_engagement_; | 105 bool record_engagement_; |
106 bool visible_; | |
102 | 107 |
103 DISALLOW_COPY_AND_ASSIGN(SiteEngagementHelper); | 108 DISALLOW_COPY_AND_ASSIGN(SiteEngagementHelper); |
104 }; | 109 }; |
105 | 110 |
106 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_HELPER_H_ | 111 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_HELPER_H_ |
OLD | NEW |