Commit 3b9d29c0 authored by Chris Lu's avatar Chris Lu Committed by Commit Bot

[ios] Refactor CreateBannerInstaller implementation for Infobar banners

This change is necessary since SaveCard needs its own CallbackInstaller
for its unique Infobar Main action that requires parameters to be passed
through to the delegate. This will occur by SaveCard's InteractionHandler
subclassing CreateBannerInstaller. Otherwise, the default use of
InfobarBannerOverlayRequestCallbackInstaller is fine for every other
class.

Bug: 1071914
Change-Id: I9a773cc000355c309f08c140bb92b94aae9e1e7d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2246835Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Commit-Queue: Chris Lu <thegreenfrog@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779025}
parent 039882fc
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#import "ios/chrome/browser/infobars/overlays/browser_agent/interaction_handlers/infobar_interaction_handler.h" #import "ios/chrome/browser/infobars/overlays/browser_agent/interaction_handlers/infobar_interaction_handler.h"
class OverlayRequestSupport; class OverlayRequestSupport;
class InfobarBannerOverlayRequestCallbackInstaller;
namespace web { namespace web {
class WebState; class WebState;
...@@ -43,7 +44,10 @@ class InfobarBannerInteractionHandler ...@@ -43,7 +44,10 @@ class InfobarBannerInteractionHandler
std::unique_ptr<OverlayRequestCallbackInstaller> CreateInstaller() override; std::unique_ptr<OverlayRequestCallbackInstaller> CreateInstaller() override;
void InfobarVisibilityChanged(InfoBarIOS* infobar, bool visible) override; void InfobarVisibilityChanged(InfoBarIOS* infobar, bool visible) override;
private: // Creates the infobar banner callback installer for this handler.
virtual std::unique_ptr<InfobarBannerOverlayRequestCallbackInstaller>
CreateBannerInstaller();
// The request support passed on initialization. Only interactions with // The request support passed on initialization. Only interactions with
// supported requests should be handled by this instance. // supported requests should be handled by this instance.
const OverlayRequestSupport* request_support_ = nullptr; const OverlayRequestSupport* request_support_ = nullptr;
......
...@@ -34,8 +34,7 @@ InfobarBannerInteractionHandler::~InfobarBannerInteractionHandler() = default; ...@@ -34,8 +34,7 @@ InfobarBannerInteractionHandler::~InfobarBannerInteractionHandler() = default;
std::unique_ptr<OverlayRequestCallbackInstaller> std::unique_ptr<OverlayRequestCallbackInstaller>
InfobarBannerInteractionHandler::CreateInstaller() { InfobarBannerInteractionHandler::CreateInstaller() {
return std::make_unique<InfobarBannerOverlayRequestCallbackInstaller>( return CreateBannerInstaller();
request_support_, this);
} }
void InfobarBannerInteractionHandler::ShowModalButtonTapped( void InfobarBannerInteractionHandler::ShowModalButtonTapped(
...@@ -68,3 +67,9 @@ void InfobarBannerInteractionHandler::InfobarVisibilityChanged( ...@@ -68,3 +67,9 @@ void InfobarBannerInteractionHandler::InfobarVisibilityChanged(
bool visible) { bool visible) {
BannerVisibilityChanged(infobar, visible); BannerVisibilityChanged(infobar, visible);
} }
std::unique_ptr<InfobarBannerOverlayRequestCallbackInstaller>
InfobarBannerInteractionHandler::CreateBannerInstaller() {
return std::make_unique<InfobarBannerOverlayRequestCallbackInstaller>(
request_support_, this);
}
...@@ -23,6 +23,10 @@ class InfobarBannerOverlayRequestCallbackInstaller ...@@ -23,6 +23,10 @@ class InfobarBannerOverlayRequestCallbackInstaller
InfobarBannerInteractionHandler* interaction_handler); InfobarBannerInteractionHandler* interaction_handler);
~InfobarBannerOverlayRequestCallbackInstaller() override; ~InfobarBannerOverlayRequestCallbackInstaller() override;
protected:
// OverlayRequestCallbackInstaller:
void InstallCallbacksInternal(OverlayRequest* request) override;
private: private:
// Used as a callback for OverlayResponses dispatched through |request|'s // Used as a callback for OverlayResponses dispatched through |request|'s
// callback manager. The OverlayDispatchCallback is created with an // callback manager. The OverlayDispatchCallback is created with an
...@@ -45,7 +49,6 @@ class InfobarBannerOverlayRequestCallbackInstaller ...@@ -45,7 +49,6 @@ class InfobarBannerOverlayRequestCallbackInstaller
// OverlayRequestCallbackInstaller: // OverlayRequestCallbackInstaller:
const OverlayRequestSupport* GetRequestSupport() const override; const OverlayRequestSupport* GetRequestSupport() const override;
void InstallCallbacksInternal(OverlayRequest* request) override;
// The request support for |interaction_handler_|. // The request support for |interaction_handler_|.
const OverlayRequestSupport* request_support_ = nullptr; const OverlayRequestSupport* request_support_ = nullptr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment