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

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

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

Powered by Google App Engine
This is Rietveld 408576698