Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Unified Diff: chrome/browser/banners/app_banner_manager.h

Issue 2393513004: Convert app banners to use Mojo. (Closed)
Patch Set: Add TODO Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..be247fa0ea9d27c4397e637ea44f1f46ae9f208e 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,12 +43,13 @@ 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 DisableSecureSchemeCheckForTesting();
@@ -71,18 +73,26 @@ class AppBannerManager : public content::WebContentsObserver,
// pipeline will be reported to the devtools console.
virtual void RequestAppBanner(const GURL& validated_url, bool is_debug_mode);
+ // 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
// 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
@@ -212,21 +222,16 @@ 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(blink::mojom::AppBannerPromptReply reply,
+ const std::string& referrer);
- // 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);
+ // blink::mojom::AppBannerService overrides.
+ // Called when Blink has prevented a banner from being shown, and is now
+ // requesting that it be shown later.
+ void DisplayAppBanner() override;
// The type of navigation made to the page
ui::PageTransition last_transition_type_;
@@ -243,6 +248,11 @@ class AppBannerManager : public content::WebContentsObserver,
// background will appear when the tab is reactivated.
std::vector<MediaPlayerId> active_media_players_;
+ // Mojo bindings and interface pointers.
+ mojo::Binding<blink::mojom::AppBannerService> binding_;
+ blink::mojom::AppBannerEventPtr event_;
+ blink::mojom::AppBannerControllerPtr controller_;
+
// Whether we are currently working on whether to show a banner.
bool is_active_;
« no previous file with comments | « chrome/browser/banners/app_banner_infobar_delegate_desktop.cc ('k') | chrome/browser/banners/app_banner_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698