| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // Overridden and passed through base::Bind on Android. Called after a web app | 97 // Overridden and passed through base::Bind on Android. Called after a web app |
| 98 // banner was successfully used to add a web app to homescreen to kick off an | 98 // banner was successfully used to add a web app to homescreen to kick off an |
| 99 // asynchronous fetch of a splash screen icon. Not used on desktop platforms. | 99 // asynchronous fetch of a splash screen icon. Not used on desktop platforms. |
| 100 virtual base::Closure FetchWebappSplashScreenImageCallback( | 100 virtual base::Closure FetchWebappSplashScreenImageCallback( |
| 101 const std::string& webapp_id); | 101 const std::string& webapp_id); |
| 102 | 102 |
| 103 protected: | 103 protected: |
| 104 explicit AppBannerManager(content::WebContents* web_contents); | 104 explicit AppBannerManager(content::WebContents* web_contents); |
| 105 ~AppBannerManager() override; | 105 ~AppBannerManager() override; |
| 106 | 106 |
| 107 // Returns true if the banner should be shown. Returns false if the banner has |
| 108 // been shown too recently, or if the app has already been installed. |
| 109 // GetAppIdentifier() must return a valid value for this method to work. |
| 110 bool CheckIfShouldShowBanner(); |
| 111 |
| 107 // Return a string identifying this app for metrics. | 112 // Return a string identifying this app for metrics. |
| 108 virtual std::string GetAppIdentifier(); | 113 virtual std::string GetAppIdentifier(); |
| 109 | 114 |
| 110 // Return a string describing what type of banner is being created. Used when | 115 // Return a string describing what type of banner is being created. Used when |
| 111 // alerting websites that a banner is about to be created. | 116 // alerting websites that a banner is about to be created. |
| 112 virtual std::string GetBannerType(); | 117 virtual std::string GetBannerType(); |
| 113 | 118 |
| 114 // Returns a string parameter for a devtools console message corresponding to | 119 // Returns a string parameter for a devtools console message corresponding to |
| 115 // |code|. Returns the empty string if |code| requires no parameter. | 120 // |code|. Returns the empty string if |code| requires no parameter. |
| 116 std::string GetStatusParam(InstallableStatusCode code); | 121 std::string GetStatusParam(InstallableStatusCode code); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 friend class AppBannerManagerTest; | 219 friend class AppBannerManagerTest; |
| 215 | 220 |
| 216 // Record that the banner could be shown at this point, if the triggering | 221 // Record that the banner could be shown at this point, if the triggering |
| 217 // heuristic allowed. | 222 // heuristic allowed. |
| 218 void RecordCouldShowBanner(); | 223 void RecordCouldShowBanner(); |
| 219 | 224 |
| 220 // Creates a banner for the app. Overridden by subclasses as the infobar is | 225 // Creates a banner for the app. Overridden by subclasses as the infobar is |
| 221 // platform-specific. | 226 // platform-specific. |
| 222 virtual void ShowBanner() = 0; | 227 virtual void ShowBanner() = 0; |
| 223 | 228 |
| 224 // Returns true if the banner should be shown. | |
| 225 bool CheckIfShouldShowBanner(); | |
| 226 | |
| 227 // Called after the manager sends a message to the renderer regarding its | 229 // Called after the manager sends a message to the renderer regarding its |
| 228 // intention to show a prompt. The renderer will send a message back with the | 230 // intention to show a prompt. The renderer will send a message back with the |
| 229 // opportunity to cancel. | 231 // opportunity to cancel. |
| 230 void OnBannerPromptReply(blink::mojom::AppBannerPromptReply reply, | 232 void OnBannerPromptReply(blink::mojom::AppBannerPromptReply reply, |
| 231 const std::string& referrer); | 233 const std::string& referrer); |
| 232 | 234 |
| 233 // blink::mojom::AppBannerService overrides. | 235 // blink::mojom::AppBannerService overrides. |
| 234 // Called when Blink has prevented a banner from being shown, and is now | 236 // Called when Blink has prevented a banner from being shown, and is now |
| 235 // requesting that it be shown later. | 237 // requesting that it be shown later. |
| 236 void DisplayAppBanner() override; | 238 void DisplayAppBanner() override; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 // scoped to the WebContents which they are observing. This allows us to use | 277 // scoped to the WebContents which they are observing. This allows us to use |
| 276 // weak pointers for callbacks. | 278 // weak pointers for callbacks. |
| 277 base::WeakPtrFactory<AppBannerManager> weak_factory_; | 279 base::WeakPtrFactory<AppBannerManager> weak_factory_; |
| 278 | 280 |
| 279 DISALLOW_COPY_AND_ASSIGN(AppBannerManager); | 281 DISALLOW_COPY_AND_ASSIGN(AppBannerManager); |
| 280 }; | 282 }; |
| 281 | 283 |
| 282 } // namespace banners | 284 } // namespace banners |
| 283 | 285 |
| 284 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_ | 286 #endif // CHROME_BROWSER_BANNERS_APP_BANNER_MANAGER_H_ |
| OLD | NEW |