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). |
| 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 |
| 29 protected: |
| 30 explicit SiteEngagementObserver(SiteEngagementService* service); |
| 31 |
| 32 SiteEngagementObserver(); |
| 33 |
| 34 ~SiteEngagementObserver(); |
| 35 |
| 36 // Returns the site engagement service which this object is observing. |
| 37 SiteEngagementService* GetSiteEngagementService() const; |
| 38 |
| 39 // Begin observing |service| for engagement increases. |
| 40 // To stop observing, call Observe(nullptr). |
| 41 void Observe(SiteEngagementService* service); |
| 42 |
| 43 private: |
| 44 FRIEND_TEST_ALL_PREFIXES(SiteEngagementServiceTest, Observers); |
| 45 SiteEngagementService* service_; |
| 46 |
| 47 DISALLOW_COPY_AND_ASSIGN(SiteEngagementObserver); |
| 48 }; |
| 49 |
| 50 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_OBSERVER_H_ |
OLD | NEW |