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

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

Issue 2788413003: Add SiteEngagementService::GetAllDetails(), to return detailed scores. (Closed)
Patch Set: Created 3 years, 8 months 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
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_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>
11 11
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/observer_list.h" 15 #include "base/observer_list.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "chrome/browser/engagement/site_engagement_details.mojom.h"
18 #include "chrome/browser/engagement/site_engagement_metrics.h" 19 #include "chrome/browser/engagement/site_engagement_metrics.h"
19 #include "chrome/browser/engagement/site_engagement_observer.h" 20 #include "chrome/browser/engagement/site_engagement_observer.h"
20 #include "components/history/core/browser/history_service_observer.h" 21 #include "components/history/core/browser/history_service_observer.h"
21 #include "components/keyed_service/core/keyed_service.h" 22 #include "components/keyed_service/core/keyed_service.h"
22 #include "third_party/WebKit/public/platform/site_engagement.mojom.h" 23 #include "third_party/WebKit/public/platform/site_engagement.mojom.h"
23 #include "ui/base/page_transition_types.h" 24 #include "ui/base/page_transition_types.h"
24 25
25 namespace base { 26 namespace base {
26 class Clock; 27 class Clock;
27 } 28 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 105
105 explicit SiteEngagementService(Profile* profile); 106 explicit SiteEngagementService(Profile* profile);
106 ~SiteEngagementService() override; 107 ~SiteEngagementService() override;
107 108
108 // KeyedService support: 109 // KeyedService support:
109 void Shutdown() override; 110 void Shutdown() override;
110 111
111 // Returns the engagement level of |url|. 112 // Returns the engagement level of |url|.
112 blink::mojom::EngagementLevel GetEngagementLevel(const GURL& url) const; 113 blink::mojom::EngagementLevel GetEngagementLevel(const GURL& url) const;
113 114
115 // Returns SiteEngagementDetails structures describing the score details for
116 // all stored origins.
117 std::vector<mojom::SiteEngagementDetails> GetScoreDetails() const;
118
114 // Returns a map of all stored origins and their engagement scores. 119 // Returns a map of all stored origins and their engagement scores.
120 // TODO(wez): Remove this!
115 std::map<GURL, double> GetScoreMap() const; 121 std::map<GURL, double> GetScoreMap() const;
116 122
117 // Update the engagement score of |url| for a notification interaction. 123 // Update the engagement score of |url| for a notification interaction.
118 void HandleNotificationInteraction(const GURL& url); 124 void HandleNotificationInteraction(const GURL& url);
119 125
120 // Returns whether the engagement service has enough data to make meaningful 126 // Returns whether the engagement service has enough data to make meaningful
121 // decisions. Clients should avoid using engagement in their heuristic until 127 // decisions. Clients should avoid using engagement in their heuristic until
122 // this is true. 128 // this is true.
123 bool IsBootstrapped() const; 129 bool IsBootstrapped() const;
124 130
125 // Returns whether |url| has at least the given |level| of engagement. 131 // Returns whether |url| has at least the given |level| of engagement.
126 bool IsEngagementAtLeast(const GURL& url, 132 bool IsEngagementAtLeast(const GURL& url,
127 blink::mojom::EngagementLevel level) const; 133 blink::mojom::EngagementLevel level) const;
128 134
129 // Resets the base engagement for |url| to |score|, clearing daily limits. Any 135 // Resets the base engagement for |url| to |score|, clearing daily limits. Any
130 // bonus engagement that |url| has acquired is not affected by this method, so 136 // bonus engagement that |url| has acquired is not affected by this method, so
131 // the result of GetScore(|url|) may not be the same as |score|. 137 // the result of GetScore(|url|) may not be the same as |score|.
132 void ResetBaseScoreForURL(const GURL& url, double score); 138 void ResetBaseScoreForURL(const GURL& url, double score);
133 139
134 // Update the last time |url| was opened from an installed shortcut to be 140 // Update the last time |url| was opened from an installed shortcut to be
135 // clock_->Now(). 141 // clock_->Now().
136 void SetLastShortcutLaunchTime(const GURL& url); 142 void SetLastShortcutLaunchTime(const GURL& url);
137 143
138 void HelperCreated(SiteEngagementService::Helper* helper); 144 void HelperCreated(SiteEngagementService::Helper* helper);
139 void HelperDeleted(SiteEngagementService::Helper* helper); 145 void HelperDeleted(SiteEngagementService::Helper* helper);
140 146
147 // Returns the site engagement details for the specified |url|.
148 mojom::SiteEngagementDetails GetScoreDetails(const GURL& url) const;
149
141 // Overridden from SiteEngagementScoreProvider. 150 // Overridden from SiteEngagementScoreProvider.
142 double GetScore(const GURL& url) const override; 151 double GetScore(const GURL& url) const override;
143 double GetTotalEngagementPoints() const override; 152 double GetTotalEngagementPoints() const override;
144 153
145 private: 154 private:
146 friend class SiteEngagementObserver; 155 friend class SiteEngagementObserver;
147 friend class SiteEngagementServiceAndroid; 156 friend class SiteEngagementServiceAndroid;
148 friend class SiteEngagementServiceTest; 157 friend class SiteEngagementServiceTest;
149 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CheckHistograms); 158 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CheckHistograms);
150 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CleanupEngagementScores); 159 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, CleanupEngagementScores);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 // A list of observers. When any origin registers an engagement-increasing 306 // A list of observers. When any origin registers an engagement-increasing
298 // event, each observer's OnEngagementIncreased method will be called. 307 // event, each observer's OnEngagementIncreased method will be called.
299 base::ObserverList<SiteEngagementObserver> observer_list_; 308 base::ObserverList<SiteEngagementObserver> observer_list_;
300 309
301 base::WeakPtrFactory<SiteEngagementService> weak_factory_; 310 base::WeakPtrFactory<SiteEngagementService> weak_factory_;
302 311
303 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService); 312 DISALLOW_COPY_AND_ASSIGN(SiteEngagementService);
304 }; 313 };
305 314
306 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_ 315 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698