| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_SCORE_H_ | 5 #ifndef CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SCORE_H_ |
| 6 #define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SCORE_H_ | 6 #define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SCORE_H_ |
| 7 | 7 |
| 8 #include <array> | 8 #include <array> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "third_party/WebKit/public/platform/site_engagement.mojom.h" |
| 15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 16 | 17 |
| 17 namespace base { | 18 namespace base { |
| 18 class Clock; | 19 class Clock; |
| 19 } | 20 } |
| 20 | 21 |
| 21 class HostContentSettingsMap; | 22 class HostContentSettingsMap; |
| 22 | 23 |
| 23 class SiteEngagementScore { | 24 class SiteEngagementScore { |
| 24 public: | 25 public: |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 123 |
| 123 // Adds |points| to this score, respecting daily limits and the maximum | 124 // Adds |points| to this score, respecting daily limits and the maximum |
| 124 // possible score. Decays the score if it has not been updated recently | 125 // possible score. Decays the score if it has not been updated recently |
| 125 // enough. | 126 // enough. |
| 126 void AddPoints(double points); | 127 void AddPoints(double points); |
| 127 double GetScore() const; | 128 double GetScore() const; |
| 128 | 129 |
| 129 // Writes the values in this score into |settings_map_|. | 130 // Writes the values in this score into |settings_map_|. |
| 130 void Commit(); | 131 void Commit(); |
| 131 | 132 |
| 133 // Returns the discrete engagement level for this score. |
| 134 blink::mojom::EngagementLevel GetEngagementLevel() const; |
| 135 |
| 132 // Returns true if the maximum number of points today has been added. | 136 // Returns true if the maximum number of points today has been added. |
| 133 bool MaxPointsPerDayAdded() const; | 137 bool MaxPointsPerDayAdded() const; |
| 134 | 138 |
| 135 // Resets the score to |points| and resets the daily point limit. If | 139 // Resets the score to |points| and resets the daily point limit. If |
| 136 // |updated_time| is non-null, sets the last engagement time to that value. | 140 // |updated_time| is non-null, sets the last engagement time to that value. |
| 137 void Reset(double points, const base::Time updated_time); | 141 void Reset(double points, const base::Time updated_time); |
| 138 | 142 |
| 139 // Get/set the last time this origin was launched from an installed shortcut. | 143 // Get/set the last time this origin was launched from an installed shortcut. |
| 140 base::Time last_shortcut_launch_time() const { | 144 base::Time last_shortcut_launch_time() const { |
| 141 return last_shortcut_launch_time_; | 145 return last_shortcut_launch_time_; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 // The origin this score represents. | 225 // The origin this score represents. |
| 222 GURL origin_; | 226 GURL origin_; |
| 223 | 227 |
| 224 // The settings to write this score to when Commit() is called. | 228 // The settings to write this score to when Commit() is called. |
| 225 HostContentSettingsMap* settings_map_; | 229 HostContentSettingsMap* settings_map_; |
| 226 | 230 |
| 227 DISALLOW_COPY_AND_ASSIGN(SiteEngagementScore); | 231 DISALLOW_COPY_AND_ASSIGN(SiteEngagementScore); |
| 228 }; | 232 }; |
| 229 | 233 |
| 230 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SCORE_H_ | 234 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SCORE_H_ |
| OLD | NEW |