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_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ |
6 #define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ | 6 #define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 void SetLastShortcutLaunchTime(const GURL& url); | 130 void SetLastShortcutLaunchTime(const GURL& url); |
131 | 131 |
132 void HelperCreated(SiteEngagementService::Helper* helper); | 132 void HelperCreated(SiteEngagementService::Helper* helper); |
133 void HelperDeleted(SiteEngagementService::Helper* helper); | 133 void HelperDeleted(SiteEngagementService::Helper* helper); |
134 | 134 |
135 // Overridden from SiteEngagementScoreProvider. | 135 // Overridden from SiteEngagementScoreProvider. |
136 double GetScore(const GURL& url) const override; | 136 double GetScore(const GURL& url) const override; |
137 double GetTotalEngagementPoints() const override; | 137 double GetTotalEngagementPoints() const override; |
138 | 138 |
139 private: | 139 private: |
| 140 // TODO(dominickn): remove this friend when we have notification observers. |
| 141 friend class PlatformNotificationServiceImpl; |
140 friend class SiteEngagementObserver; | 142 friend class SiteEngagementObserver; |
141 friend class SiteEngagementServiceAndroid; | 143 friend class SiteEngagementServiceAndroid; |
142 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CheckHistograms); | 144 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CheckHistograms); |
143 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CleanupEngagementScores); | 145 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CleanupEngagementScores); |
144 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, | 146 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, |
145 CleanupMovesScoreBackToNow); | 147 CleanupMovesScoreBackToNow); |
146 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, | 148 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, |
147 CleanupMovesScoreBackToRebase); | 149 CleanupMovesScoreBackToRebase); |
148 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, | 150 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, |
149 CleanupEngagementScoresProportional); | 151 CleanupEngagementScoresProportional); |
150 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, ClearHistoryForURLs); | 152 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, ClearHistoryForURLs); |
151 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, GetMedianEngagement); | 153 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, GetMedianEngagement); |
152 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, GetTotalNavigationPoints); | 154 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, GetTotalNavigationPoints); |
153 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, GetTotalUserInputPoints); | 155 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, GetTotalUserInputPoints); |
| 156 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, |
| 157 GetTotalNotificationPoints); |
154 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, RestrictedToHTTPAndHTTPS); | 158 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, RestrictedToHTTPAndHTTPS); |
155 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, LastShortcutLaunch); | 159 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, LastShortcutLaunch); |
156 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, NotificationPermission); | 160 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, NotificationPermission); |
157 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, | 161 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, |
158 CleanupOriginsOnHistoryDeletion); | 162 CleanupOriginsOnHistoryDeletion); |
159 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, IsBootstrapped); | 163 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, IsBootstrapped); |
160 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, EngagementLevel); | 164 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, EngagementLevel); |
161 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, Observers); | 165 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, Observers); |
162 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, ScoreDecayHistograms); | 166 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, ScoreDecayHistograms); |
163 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, LastEngagementTime); | 167 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, LastEngagementTime); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 // Update the engagement score of the origin loaded in |web_contents| for | 228 // Update the engagement score of the origin loaded in |web_contents| for |
225 // navigation. | 229 // navigation. |
226 void HandleNavigation(content::WebContents* web_contents, | 230 void HandleNavigation(content::WebContents* web_contents, |
227 ui::PageTransition transition); | 231 ui::PageTransition transition); |
228 | 232 |
229 // Update the engagement score of the origin loaded in |web_contents| for | 233 // Update the engagement score of the origin loaded in |web_contents| for |
230 // time-on-site, based on user input. | 234 // time-on-site, based on user input. |
231 void HandleUserInput(content::WebContents* web_contents, | 235 void HandleUserInput(content::WebContents* web_contents, |
232 SiteEngagementMetrics::EngagementType type); | 236 SiteEngagementMetrics::EngagementType type); |
233 | 237 |
| 238 // Update the engagement score of |url| for a notification interaction. |
| 239 void HandleNotificationInteraction(const GURL& url); |
| 240 |
234 // Called if |url| changes to |level| engagement, and informs every Helper of | 241 // Called if |url| changes to |level| engagement, and informs every Helper of |
235 // the change. | 242 // the change. |
236 void SendLevelChangeToHelpers(const GURL& url, | 243 void SendLevelChangeToHelpers(const GURL& url, |
237 blink::mojom::EngagementLevel level); | 244 blink::mojom::EngagementLevel level); |
238 | 245 |
239 // Returns true if the last engagement increasing event seen by the site | 246 // Returns true if the last engagement increasing event seen by the site |
240 // engagement service was sufficiently long ago that we need to reset all | 247 // engagement service was sufficiently long ago that we need to reset all |
241 // scores to be relative to now. This ensures that users who do not use the | 248 // scores to be relative to now. This ensures that users who do not use the |
242 // browser for an extended period of time do not have their engagement decay. | 249 // browser for an extended period of time do not have their engagement decay. |
243 bool IsLastEngagementStale() const; | 250 bool IsLastEngagementStale() const; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 // A list of observers. When any origin registers an engagement-increasing | 295 // A list of observers. When any origin registers an engagement-increasing |
289 // event, each observer's OnEngagementIncreased method will be called. | 296 // event, each observer's OnEngagementIncreased method will be called. |
290 base::ObserverList<SiteEngagementObserver> observer_list_; | 297 base::ObserverList<SiteEngagementObserver> observer_list_; |
291 | 298 |
292 base::WeakPtrFactory<SiteEngagementService> weak_factory_; | 299 base::WeakPtrFactory<SiteEngagementService> weak_factory_; |
293 | 300 |
294 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService); | 301 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService); |
295 }; | 302 }; |
296 | 303 |
297 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ | 304 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ |
OLD | NEW |