Chromium Code Reviews| Index: chrome/browser/banners/app_banner_manager.h |
| diff --git a/chrome/browser/banners/app_banner_manager.h b/chrome/browser/banners/app_banner_manager.h |
| index 19fd112a6306fe571c3f4ae740a979694dbdb5bc..4f2dd6d0f1a8f757e9899e6ea013a239b9ef5112 100644 |
| --- a/chrome/browser/banners/app_banner_manager.h |
| +++ b/chrome/browser/banners/app_banner_manager.h |
| @@ -15,7 +15,8 @@ |
| #include "chrome/browser/installable/installable_logging.h" |
| #include "chrome/browser/installable/installable_manager.h" |
| #include "content/public/browser/web_contents_observer.h" |
| -#include "third_party/WebKit/public/platform/modules/app_banner/WebAppBannerPromptReply.h" |
| +#include "mojo/public/cpp/bindings/binding.h" |
| +#include "third_party/WebKit/public/platform/modules/app_banner/app_banner.mojom.h" |
| class SkBitmap; |
| struct WebApplicationInfo; |
| @@ -42,14 +43,21 @@ namespace banners { |
| // as well as no-op callbacks that the platform-specific implementations pass to |
| // base::Bind. This allows a WeakPtrFactory to be housed in this class. |
| // |
| -// The InstallableManager fetches and validate a site's eligibility for banners. |
| -// The manager is first called to fetch the manifest, so we can verify whether |
| -// the site is already installed (and on Android, divert the flow to a |
| +// The InstallableManager fetches and validates whether a site is eligible for |
| +// banners. The manager is first called to fetch the manifest, so we can verify |
| +// whether the site is already installed (and on Android, divert the flow to a |
| // native app banner if requested). The second call completes the checking for a |
| // web app banner (checking manifest validity, service worker, and icon). |
| class AppBannerManager : public content::WebContentsObserver, |
| + public blink::mojom::AppBannerService, |
| public SiteEngagementObserver { |
| public: |
| + static void Create(content::WebContents* web_contents); |
| + static AppBannerManager* Get(content::WebContents* web_contents); |
| + |
| + static void BindToMojoRequest(content::RenderFrameHost* render_frame_host, |
| + blink::mojom::AppBannerServiceRequest request); |
| + |
| static void DisableSecureSchemeCheckForTesting(); |
| // Returns the current time. |
| @@ -71,18 +79,27 @@ class AppBannerManager : public content::WebContentsObserver, |
| // pipeline will be reported to the devtools console. |
| virtual void RequestAppBanner(const GURL& validated_url, bool is_debug_mode); |
| - // Overridden and passed through base::Bind on desktop platforms. Called when |
| + // Sends a message to the renderer that the user accepted the banner. Does |
| + // nothing if |request_id| does not match the current request. |
| + void SendBannerAccepted(int request_id); |
| + |
| + // Sends a message to the renderer that the user dismissed the banner. Does |
| + // nothing if |request_id| does not match the current request. |
| + void SendBannerDismissed(int request_id); |
| + |
| + // Overridden and passed through base::Bind on desktop platforms. Called |
| + // when |
|
Sam McNally
2016/10/06 07:17:43
Reflow.
dominickn
2016/10/06 22:58:12
Done.
|
| // the bookmark app install initiated by a banner has completed. Not used on |
| // Android. |
| virtual void DidFinishCreatingBookmarkApp( |
| const extensions::Extension* extension, |
| - const WebApplicationInfo& web_app_info) { } |
| + const WebApplicationInfo& web_app_info) {} |
| // Overridden and passed through base::Bind on Android. Called when the |
| // download of a native app's icon is complete, as native banners use an icon |
| // provided from the Play Store rather than the web manifest. Not used on |
| // desktop platforms. |
| - virtual void OnAppIconFetched(const SkBitmap& bitmap) { } |
| + virtual void OnAppIconFetched(const SkBitmap& bitmap) {} |
| // Overridden and passed through base::Bind on Android. Called after a web app |
| // banner was successfully used to add a web app to homescreen to kick off an |
| @@ -198,6 +215,9 @@ class AppBannerManager : public content::WebContentsObserver, |
| // app banners. |
| std::string referrer_; |
| + // The app banner client which we are communicating with. |
| + blink::mojom::AppBannerClientPtr banner_client_; |
| + |
| private: |
| friend class AppBannerManagerTest; |
| @@ -212,21 +232,20 @@ class AppBannerManager : public content::WebContentsObserver, |
| // Returns true if the banner should be shown. |
| bool CheckIfShouldShowBanner(); |
| - bool OnMessageReceived(const IPC::Message& message, |
| - content::RenderFrameHost* render_frame_host) override; |
| - |
| // Called after the manager sends a message to the renderer regarding its |
| // intention to show a prompt. The renderer will send a message back with the |
| // opportunity to cancel. |
| - void OnBannerPromptReply(content::RenderFrameHost* render_frame_host, |
| - int request_id, |
| - blink::WebAppBannerPromptReply reply, |
| - std::string referrer); |
| + void OnBannerPromptReply(int request_id, |
| + blink::mojom::AppBannerPromptReply reply, |
| + mojo::String referrer); |
| + |
| + // blink::mojom::AppBannerService overrides. |
| + // Called when the client has prevented a banner from being shown, and is now |
| + // requesting that it be shown later. |
| + void DisplayAppBanner(int request_id) override; |
| - // Called when the client has prevented a banner from being shown, and is |
| - // now requesting that it be shown later. |
| - void OnRequestShowAppBanner(content::RenderFrameHost* render_frame_host, |
| - int request_id); |
| + // Sets the current beforeinstallprompt event. |
| + void SetEvent(blink::mojom::AppBannerEventPtr event) override; |
| // The type of navigation made to the page |
| ui::PageTransition last_transition_type_; |
| @@ -243,6 +262,11 @@ class AppBannerManager : public content::WebContentsObserver, |
| // background will appear when the tab is reactivated. |
| std::vector<MediaPlayerId> active_media_players_; |
| + std::unique_ptr<mojo::Binding<blink::mojom::AppBannerService>> binding_; |
| + |
| + // A pointer to the current beforeinstallprompt event (if it exists). |
| + std::unique_ptr<blink::mojom::AppBannerEventPtr> event_; |
| + |
| // Whether we are currently working on whether to show a banner. |
| bool is_active_; |