Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_OBSERVER_H_ | |
| 6 #define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_OBSERVER_H_ | |
| 7 | |
| 8 #include "base/gtest_prod_util.h" | |
| 9 #include "base/macros.h" | |
| 10 | |
| 11 namespace content { | |
| 12 class WebContents; | |
| 13 } | |
| 14 | |
| 15 class GURL; | |
| 16 class SiteEngagementService; | |
| 17 | |
| 18 class SiteEngagementObserver { | |
| 19 public: | |
| 20 // Called when the engagement for |url| loaded in |web_contents| increases to | |
| 21 // |score|. |is_hidden| is true if the engagement occurred when |web_contents| | |
| 22 // was hidden (e.g. in the background). | |
|
benwells
2016/06/11 09:31:23
Why is the hidden field necessary?
dominickn
2016/06/11 15:05:50
Passing it through means that clients don't need t
benwells
2016/06/14 07:25:34
Let's chat about this. I think it would be better
| |
| 23 // This method may be run on user input, so observers *must not* perform any | |
| 24 // expensive tasks here. | |
| 25 virtual void OnEngagementIncreased(content::WebContents* web_contents, | |
| 26 const GURL& url, | |
| 27 double score, | |
| 28 bool is_hidden) {} | |
| 29 | |
| 30 protected: | |
| 31 explicit SiteEngagementObserver(SiteEngagementService* service); | |
| 32 | |
| 33 SiteEngagementObserver(); | |
| 34 | |
| 35 ~SiteEngagementObserver(); | |
| 36 | |
| 37 // Returns the site engagement service which this object is observing. | |
| 38 SiteEngagementService* GetSiteEngagementService() const; | |
| 39 | |
| 40 // Begin observing |service| for engagement increases. | |
| 41 // To stop observing, call Observe(nullptr). | |
| 42 void Observe(SiteEngagementService* service); | |
| 43 | |
| 44 private: | |
| 45 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, Observers); | |
| 46 SiteEngagementService* service_; | |
| 47 | |
| 48 DISALLOW_COPY_AND_ASSIGN(SiteEngagementObserver); | |
| 49 }; | |
| 50 | |
| 51 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_OBSERVER_H_ | |
| OLD | NEW |