| OLD | NEW | 
|---|
| 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_BANNERS_APP_BANNER_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_ | 
| 6 #define CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_ | 6 #define CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_ | 
| 7 | 7 | 
| 8 #include <memory> | 8 #include <memory> | 
| 9 #include <vector> | 9 #include <vector> | 
| 10 | 10 | 
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 51 class AppBannerManager : public content::WebContentsObserver, | 51 class AppBannerManager : public content::WebContentsObserver, | 
| 52                          public blink::mojom::AppBannerService, | 52                          public blink::mojom::AppBannerService, | 
| 53                          public SiteEngagementObserver { | 53                          public SiteEngagementObserver { | 
| 54  public: | 54  public: | 
| 55   // Returns the current time. | 55   // Returns the current time. | 
| 56   static base::Time GetCurrentTime(); | 56   static base::Time GetCurrentTime(); | 
| 57 | 57 | 
| 58   // Fast-forwards the current time for testing. | 58   // Fast-forwards the current time for testing. | 
| 59   static void SetTimeDeltaForTesting(int days); | 59   static void SetTimeDeltaForTesting(int days); | 
| 60 | 60 | 
| 61   // Sets the weights applied to direct and indirect navigations for triggering | 61   // Sets the total engagement required for triggering the banner in testing. | 
| 62   // the banner. Deprecated and will be removed when app banners fully migrates | 62   static void SetTotalEngagementToTrigger(double engagement); | 
| 63   // to using site engagement as a trigger. |  | 
| 64   static void SetEngagementWeights(double direct_engagement, |  | 
| 65                                    double indirect_engagement); |  | 
| 66 | 63 | 
| 67   // Returns whether or not the URLs match for everything except for the ref. | 64   // Returns whether or not the URLs match for everything except for the ref. | 
| 68   static bool URLsAreForTheSamePage(const GURL& first, const GURL& second); | 65   static bool URLsAreForTheSamePage(const GURL& first, const GURL& second); | 
| 69 | 66 | 
| 70   // Requests an app banner. If |is_debug_mode| is true, any failure in the | 67   // Requests an app banner. If |is_debug_mode| is true, any failure in the | 
| 71   // pipeline will be reported to the devtools console. | 68   // pipeline will be reported to the devtools console. | 
| 72   virtual void RequestAppBanner(const GURL& validated_url, bool is_debug_mode); | 69   virtual void RequestAppBanner(const GURL& validated_url, bool is_debug_mode); | 
| 73 | 70 | 
| 74   // Sends a message to the renderer that the user accepted the banner. Does | 71   // Sends a message to the renderer that the user accepted the banner. Does | 
| 75   // nothing if |request_id| does not match the current request. | 72   // nothing if |request_id| does not match the current request. | 
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 153   void ReportStatus(content::WebContents* web_contents, | 150   void ReportStatus(content::WebContents* web_contents, | 
| 154                     InstallableStatusCode code); | 151                     InstallableStatusCode code); | 
| 155 | 152 | 
| 156   // Stops the banner pipeline, preventing any outstanding callbacks from | 153   // Stops the banner pipeline, preventing any outstanding callbacks from | 
| 157   // running and resetting the manager state. This method is virtual to allow | 154   // running and resetting the manager state. This method is virtual to allow | 
| 158   // tests to intercept it and verify correct behaviour. | 155   // tests to intercept it and verify correct behaviour. | 
| 159   virtual void Stop(); | 156   virtual void Stop(); | 
| 160 | 157 | 
| 161   // Sends a message to the renderer that the page has met the requirements to | 158   // Sends a message to the renderer that the page has met the requirements to | 
| 162   // show a banner. The page can respond to cancel the banner (and possibly | 159   // show a banner. The page can respond to cancel the banner (and possibly | 
| 163   // display it later), or otherwise allow it to be shown. This is virtual to | 160   // display it later), or otherwise allow it to be shown. | 
| 164   // allow tests to mock out the renderer IPC. | 161   void SendBannerPromptRequest(); | 
| 165   virtual void SendBannerPromptRequest(); |  | 
| 166 | 162 | 
| 167   // content::WebContentsObserver overrides. | 163   // content::WebContentsObserver overrides. | 
| 168   void DidStartNavigation(content::NavigationHandle* handle) override; | 164   void DidStartNavigation(content::NavigationHandle* handle) override; | 
| 169   void DidFinishNavigation(content::NavigationHandle* handle) override; | 165   void DidFinishNavigation(content::NavigationHandle* handle) override; | 
| 170   void DidFinishLoad(content::RenderFrameHost* render_frame_host, | 166   void DidFinishLoad(content::RenderFrameHost* render_frame_host, | 
| 171                      const GURL& validated_url) override; | 167                      const GURL& validated_url) override; | 
| 172   void MediaStartedPlaying(const MediaPlayerInfo& media_info, | 168   void MediaStartedPlaying(const MediaPlayerInfo& media_info, | 
| 173                            const MediaPlayerId& id) override; | 169                            const MediaPlayerId& id) override; | 
| 174   void MediaStoppedPlaying(const MediaPlayerInfo& media_info, | 170   void MediaStoppedPlaying(const MediaPlayerInfo& media_info, | 
| 175                            const MediaPlayerId& id) override; | 171                            const MediaPlayerId& id) override; | 
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 276   // scoped to the WebContents which they are observing. This allows us to use | 272   // scoped to the WebContents which they are observing. This allows us to use | 
| 277   // weak pointers for callbacks. | 273   // weak pointers for callbacks. | 
| 278   base::WeakPtrFactory<AppBannerManager> weak_factory_; | 274   base::WeakPtrFactory<AppBannerManager> weak_factory_; | 
| 279 | 275 | 
| 280   DISALLOW_COPY_AND_ASSIGN(AppBannerManager); | 276   DISALLOW_COPY_AND_ASSIGN(AppBannerManager); | 
| 281 }; | 277 }; | 
| 282 | 278 | 
| 283 }  // namespace banners | 279 }  // namespace banners | 
| 284 | 280 | 
| 285 #endif  // CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_ | 281 #endif  // CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_ | 
| OLD | NEW | 
|---|