Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: chrome/browser/engagement/site_engagement_helper.h

Issue 1478643002: Refactor media out of WebContentsImpl to MediaWebContentsObserver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix namespace for cast. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/engagement/site_engagement_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/engagement/site_engagement_metrics.h" 10 #include "chrome/browser/engagement/site_engagement_metrics.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // 123 //
124 // When media begins playing in the main frame of a tab, the tracker is 124 // When media begins playing in the main frame of a tab, the tracker is
125 // triggered with an initial delay. It then wakes up every 125 // triggered with an initial delay. It then wakes up every
126 // |g_seconds_to_pause_engagement_detection| and notes the visible/hidden 126 // |g_seconds_to_pause_engagement_detection| and notes the visible/hidden
127 // state of the tab, as well as whether media is still playing. 127 // state of the tab, as well as whether media is still playing.
128 class MediaTracker : public PeriodicTracker, 128 class MediaTracker : public PeriodicTracker,
129 public content::WebContentsObserver { 129 public content::WebContentsObserver {
130 public: 130 public:
131 MediaTracker(SiteEngagementHelper* helper, 131 MediaTracker(SiteEngagementHelper* helper,
132 content::WebContents* web_contents); 132 content::WebContents* web_contents);
133 ~MediaTracker() override;
133 134
134 private: 135 private:
135 friend class SiteEngagementHelperTest; 136 friend class SiteEngagementHelperTest;
136 137
137 void TrackingStarted() override; 138 void TrackingStarted() override;
138 139
139 // content::WebContentsObserver overrides. 140 // content::WebContentsObserver overrides.
140 void MediaStartedPlaying() override; 141 void MediaStartedPlaying(const MediaPlayerId& id) override;
141 void MediaPaused() override; 142 void MediaStoppedPlaying(const MediaPlayerId& id) override;
142 void WasShown() override; 143 void WasShown() override;
143 void WasHidden() override; 144 void WasHidden() override;
144 145
145 bool is_hidden_; 146 bool is_hidden_;
146 bool is_playing_; 147 std::vector<MediaPlayerId> active_media_players_;
147 }; 148 };
148 149
149 explicit SiteEngagementHelper(content::WebContents* web_contents); 150 explicit SiteEngagementHelper(content::WebContents* web_contents);
150 friend class content::WebContentsUserData<SiteEngagementHelper>; 151 friend class content::WebContentsUserData<SiteEngagementHelper>;
151 friend class SiteEngagementHelperTest; 152 friend class SiteEngagementHelperTest;
152 153
153 // Ask the SiteEngagementService to record engagement via user input at the 154 // Ask the SiteEngagementService to record engagement via user input at the
154 // current WebContents URL. 155 // current WebContents URL.
155 void RecordUserInput(SiteEngagementMetrics::EngagementType type); 156 void RecordUserInput(SiteEngagementMetrics::EngagementType type);
156 157
157 // Ask the SiteEngagementService to record engagement via media playing at the 158 // Ask the SiteEngagementService to record engagement via media playing at the
158 // current WebContents URL. 159 // current WebContents URL.
159 void RecordMediaPlaying(bool is_hidden); 160 void RecordMediaPlaying(bool is_hidden);
160 161
161 InputTracker input_tracker_; 162 InputTracker input_tracker_;
162 MediaTracker media_tracker_; 163 MediaTracker media_tracker_;
163 bool record_engagement_; 164 bool record_engagement_;
164 165
165 DISALLOW_COPY_AND_ASSIGN(SiteEngagementHelper); 166 DISALLOW_COPY_AND_ASSIGN(SiteEngagementHelper);
166 }; 167 };
167 168
168 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_HELPER_H_ 169 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_HELPER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/engagement/site_engagement_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698