Commit 48c8f319 authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Create InfobarOverlayBrowserAgent

InfobarOverlayBrowserAgent is an OverlayBrowserAgent subclass that
handles updating InfoBarDelegate state for user interaction with
infobar UI presented via OverlayPresenter.

For each InfobarType, an InfobarInteractionHandler will be created
that updates the infobar model layer for interactions with the UI.
These interaction handlers are provided to the InfobarBrowserAgent,
which sets up OverlayRequestCallbackInstallers to forward responses
from the UI to the interaction handlers.

InfobarBannerOverlayRequestCallbackInstaller is used to forward user
interaction events for infobar banner UI.  The interaction handlers
and the corresponding callback installers for detail sheet and modal
UI will be implemented in follow-up CLs.

This CL also updates AttachInfobarOverlayBrowserAgent() to install
the browser agent if the feature is enabled.  Subsequent CLs will
be added to provide the browser agent with interaction handlers for
each InfobarType.

Bug: 1030357
Change-Id: I131b03e8dd1e5e4228ade4d9e01730114545fa5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1989855
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#729991}
parent 01629498
...@@ -30,27 +30,15 @@ source_set("overlays") { ...@@ -30,27 +30,15 @@ source_set("overlays") {
] ]
} }
source_set("browser_agent_util") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"infobar_overlay_browser_agent_util.cc",
"infobar_overlay_browser_agent_util.h",
]
deps = [
"//base",
"//ios/chrome/browser/main:public",
"//ios/chrome/browser/ui/infobars:feature_flags",
]
}
source_set("util") { source_set("util") {
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
sources = [ sources = [
"overlay_request_infobar_type_util.h", "overlay_request_infobar_util.h",
"overlay_request_infobar_type_util.mm", "overlay_request_infobar_util.mm",
] ]
deps = [ deps = [
"//base", "//base",
"//ios/chrome/browser/infobars",
"//ios/chrome/browser/infobars:public", "//ios/chrome/browser/infobars:public",
"//ios/chrome/browser/overlays", "//ios/chrome/browser/overlays",
"//ios/chrome/browser/overlays/public/common/infobars", "//ios/chrome/browser/overlays/public/common/infobars",
......
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
source_set("browser_agent") {
configs += [ "//build/config/compiler:enable_arc" ]
friend = [ ":unit_tests" ]
public = [
"infobar_overlay_browser_agent.h",
]
sources = [
"infobar_banner_overlay_request_callback_installer.h",
"infobar_banner_overlay_request_callback_installer.mm",
"infobar_overlay_browser_agent.mm",
]
deps = [
"//base",
"//ios/chrome/browser/infobars:public",
"//ios/chrome/browser/infobars/overlays",
"//ios/chrome/browser/infobars/overlays:util",
"//ios/chrome/browser/infobars/overlays/browser_agent/interaction_handlers",
"//ios/chrome/browser/main:public",
"//ios/chrome/browser/overlays",
"//ios/chrome/browser/overlays/public/common/infobars",
"//ios/chrome/browser/overlays/public/infobar_banner",
"//ios/chrome/browser/ui/badges:public",
"//ios/chrome/browser/ui/badges:util",
]
}
source_set("browser_agent_util") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"infobar_overlay_browser_agent_util.h",
"infobar_overlay_browser_agent_util.mm",
]
deps = [
":browser_agent",
"//base",
"//ios/chrome/browser/main:public",
"//ios/chrome/browser/ui/infobars:feature_flags",
]
}
source_set("unit_tests") {
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
sources = [
"infobar_banner_overlay_request_callback_installer_unittest.mm",
"infobar_overlay_browser_agent_unittest.mm",
]
deps = [
":browser_agent",
"//base/test:test_support",
"//ios/chrome/browser/browser_state:test_support",
"//ios/chrome/browser/infobars",
"//ios/chrome/browser/infobars:public",
"//ios/chrome/browser/infobars/overlays/browser_agent/interaction_handlers/test",
"//ios/chrome/browser/infobars/test",
"//ios/chrome/browser/main",
"//ios/chrome/browser/main:test_support",
"//ios/chrome/browser/overlays",
"//ios/chrome/browser/overlays/public/common/infobars",
"//ios/chrome/browser/overlays/public/infobar_banner",
"//ios/chrome/browser/overlays/test",
"//ios/chrome/browser/web_state_list",
"//ios/chrome/browser/web_state_list:test_support",
"//ios/chrome/test:test_support",
"//ios/web/public/test",
"//ios/web/public/test/fakes",
"//testing/gmock",
"//testing/gtest",
]
}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_BROWSER_AGENT_INFOBAR_BANNER_OVERLAY_REQUEST_CALLBACK_INSTALLER_H_
#define IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_BROWSER_AGENT_INFOBAR_BANNER_OVERLAY_REQUEST_CALLBACK_INSTALLER_H_
#include "ios/chrome/browser/overlays/public/overlay_request_callback_installer.h"
class OverlayRequestSupport;
class InfobarBannerInteractionHandler;
// Installer for callbacks that are added to OverlayRequests for infobar
// banners.
class InfobarBannerOverlayRequestCallbackInstaller
: public OverlayRequestCallbackInstaller {
public:
// Constructor for an instance that installs callbacks for OverlayRequests
// supported by |request_support| that forward interaction events to
// |interaction_handler|.
explicit InfobarBannerOverlayRequestCallbackInstaller(
const OverlayRequestSupport* request_support,
InfobarBannerInteractionHandler* interaction_handler);
~InfobarBannerOverlayRequestCallbackInstaller() override;
private:
// Called as a dispatch callback for |request| when |response| is configured
// with an InfobarBannerMainActionResponse.
void MainActionButtonTapped(OverlayRequest* request,
OverlayResponse* response);
// Called as a dispatch callback for |request| when |response| is configured
// with an InfobarBannerShowModalResponse.
void ShowModalButtonTapped(OverlayRequest* request,
OverlayResponse* response);
// Called as a completion callback for |request|, where |response| is the
// completion response.
void BannerCompleted(OverlayRequest* request, OverlayResponse* response);
// OverlayRequestCallbackInstaller:
const OverlayRequestSupport* GetRequestSupport() const override;
void InstallCallbacksInternal(OverlayRequest* request) override;
// The request support for |interaction_handler_|.
const OverlayRequestSupport* request_support_ = nullptr;
// The handler for received responses.
InfobarBannerInteractionHandler* interaction_handler_ = nullptr;
base::WeakPtrFactory<InfobarBannerOverlayRequestCallbackInstaller>
weak_factory_{this};
};
#endif // IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_BROWSER_AGENT_INFOBAR_BANNER_OVERLAY_REQUEST_CALLBACK_INSTALLER_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/infobars/overlays/browser_agent/infobar_banner_overlay_request_callback_installer.h"
#include "base/bind.h"
#include "base/callback.h"
#include "base/logging.h"
#import "ios/chrome/browser/infobars/overlays/browser_agent/interaction_handlers/infobar_interaction_handler.h"
#include "ios/chrome/browser/infobars/overlays/overlay_request_infobar_util.h"
#import "ios/chrome/browser/overlays/public/common/infobars/infobar_overlay_request_config.h"
#include "ios/chrome/browser/overlays/public/infobar_banner/infobar_banner_overlay_responses.h"
#include "ios/chrome/browser/overlays/public/overlay_callback_manager.h"
#include "ios/chrome/browser/overlays/public/overlay_dispatch_callback.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
InfobarBannerOverlayRequestCallbackInstaller::
InfobarBannerOverlayRequestCallbackInstaller(
const OverlayRequestSupport* request_support,
InfobarBannerInteractionHandler* interaction_handler)
: request_support_(request_support),
interaction_handler_(interaction_handler) {
DCHECK(request_support_);
DCHECK(interaction_handler_);
}
InfobarBannerOverlayRequestCallbackInstaller::
~InfobarBannerOverlayRequestCallbackInstaller() = default;
#pragma mark - Private
void InfobarBannerOverlayRequestCallbackInstaller::MainActionButtonTapped(
OverlayRequest* request,
OverlayResponse* response) {
interaction_handler_->MainButtonTapped(GetOverlayRequestInfobar(request));
}
void InfobarBannerOverlayRequestCallbackInstaller::ShowModalButtonTapped(
OverlayRequest* request,
OverlayResponse* response) {
interaction_handler_->ShowModalButtonTapped(GetOverlayRequestInfobar(request),
request->GetQueueWebState());
}
void InfobarBannerOverlayRequestCallbackInstaller::BannerCompleted(
OverlayRequest* request,
OverlayResponse* response) {
bool user_initiated = false;
if (response) {
InfobarBannerCompletionResponse* banner_completion =
response->GetInfo<InfobarBannerCompletionResponse>();
user_initiated = banner_completion && banner_completion->user_initiated();
}
interaction_handler_->BannerCompleted(GetOverlayRequestInfobar(request),
user_initiated);
}
#pragma mark - OverlayRequestCallbackInstaller
const OverlayRequestSupport*
InfobarBannerOverlayRequestCallbackInstaller::GetRequestSupport() const {
return request_support_;
}
void InfobarBannerOverlayRequestCallbackInstaller::InstallCallbacksInternal(
OverlayRequest* request) {
OverlayCallbackManager* manager = request->GetCallbackManager();
manager->AddDispatchCallback(OverlayDispatchCallback(
base::BindRepeating(
&InfobarBannerOverlayRequestCallbackInstaller::MainActionButtonTapped,
weak_factory_.GetWeakPtr(), request),
InfobarBannerMainActionResponse::ResponseSupport()));
manager->AddDispatchCallback(OverlayDispatchCallback(
base::BindRepeating(
&InfobarBannerOverlayRequestCallbackInstaller::ShowModalButtonTapped,
weak_factory_.GetWeakPtr(), request),
InfobarBannerShowModalResponse::ResponseSupport()));
manager->AddCompletionCallback(base::BindOnce(
&InfobarBannerOverlayRequestCallbackInstaller::BannerCompleted,
weak_factory_.GetWeakPtr(), request));
}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/infobars/overlays/browser_agent/infobar_banner_overlay_request_callback_installer.h"
#import "ios/chrome/browser/infobars/overlays/browser_agent/interaction_handlers/test/mock_infobar_interaction_handler.h"
#import "ios/chrome/browser/infobars/test/fake_infobar_ios.h"
#import "ios/chrome/browser/overlays/public/common/infobars/infobar_overlay_request_config.h"
#include "ios/chrome/browser/overlays/public/infobar_banner/infobar_banner_overlay_responses.h"
#include "ios/chrome/browser/overlays/public/overlay_callback_manager.h"
#include "ios/chrome/browser/overlays/public/overlay_request.h"
#import "ios/chrome/browser/overlays/public/overlay_request_queue.h"
#include "ios/chrome/browser/overlays/public/overlay_response.h"
#include "ios/chrome/browser/overlays/test/fake_overlay_request_callback_installer.h"
#include "ios/chrome/browser/overlays/test/overlay_test_macros.h"
#import "ios/web/public/test/fakes/test_web_state.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/platform_test.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
// Test fixture for InfobarBannerOverlayRequestCallbackInstaller.
class InfobarBannerOverlayRequestCallbackInstallerTest : public PlatformTest {
public:
InfobarBannerOverlayRequestCallbackInstallerTest()
: installer_(InfobarOverlayRequestConfig::RequestSupport(),
&mock_handler_) {
std::unique_ptr<OverlayRequest> request =
OverlayRequest::CreateWithConfig<InfobarOverlayRequestConfig>(
&infobar_);
request_ = request.get();
queue()->AddRequest(std::move(request));
installer_.InstallCallbacks(request_);
}
OverlayCallbackManager* callback_manager() const {
return request_->GetCallbackManager();
}
OverlayRequestQueue* queue() {
return OverlayRequestQueue::FromWebState(&web_state_,
OverlayModality::kInfobarBanner);
}
protected:
FakeInfobarIOS infobar_;
web::TestWebState web_state_;
OverlayRequest* request_ = nullptr;
MockInfobarBannerInteractionHandler mock_handler_;
InfobarBannerOverlayRequestCallbackInstaller installer_;
};
// Tests that a dispatched InfobarBannerMainActionResponse calls
// InfobarBannerInteractionHandler::MainButtonTapped().
TEST_F(InfobarBannerOverlayRequestCallbackInstallerTest, MainAction) {
EXPECT_CALL(mock_handler_, MainButtonTapped(&infobar_));
callback_manager()->DispatchResponse(
OverlayResponse::CreateWithInfo<InfobarBannerMainActionResponse>());
}
// Tests that a dispatched InfobarBannerShowModalResponse calls
// InfobarBannerInteractionHandler::ShowModalButtonTapped().
TEST_F(InfobarBannerOverlayRequestCallbackInstallerTest, ShowModal) {
EXPECT_CALL(mock_handler_, ShowModalButtonTapped(&infobar_, &web_state_));
callback_manager()->DispatchResponse(
OverlayResponse::CreateWithInfo<InfobarBannerShowModalResponse>());
}
// Tests that the request's completion callback calls
// InfobarBannerInteractionHandler::BannerCompleted().
TEST_F(InfobarBannerOverlayRequestCallbackInstallerTest, Completion) {
bool user_initiated = true;
callback_manager()->SetCompletionResponse(
OverlayResponse::CreateWithInfo<InfobarBannerCompletionResponse>(
user_initiated));
EXPECT_CALL(mock_handler_, BannerCompleted(&infobar_, user_initiated));
queue()->CancelAllRequests();
}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_BROWSER_AGENT_INFOBAR_OVERLAY_BROWSER_AGENT_H_
#define IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_BROWSER_AGENT_INFOBAR_OVERLAY_BROWSER_AGENT_H_
#include <map>
#include <memory>
#include "base/scoped_observer.h"
#import "ios/chrome/browser/infobars/infobar_type.h"
#import "ios/chrome/browser/main/browser_user_data.h"
#import "ios/chrome/browser/overlays/public/overlay_browser_agent_base.h"
#include "ios/chrome/browser/overlays/public/overlay_presenter.h"
#include "ios/chrome/browser/overlays/public/overlay_presenter_observer.h"
class InfobarInteractionHandler;
// Browser agent class that handles the model-layer updates for infobars.
class InfobarOverlayBrowserAgent
: public OverlayBrowserAgentBase,
public BrowserUserData<InfobarOverlayBrowserAgent> {
public:
~InfobarOverlayBrowserAgent() override;
// Sets the InfobarInteractionHandler to make model-layer updates for
// interactions with infobars with |type|. OverlayCallbackInstallers will be
// created to forward interaction events to each interaction handler.
// |interaction_handler| must not be null. Must only be set once for each
// InfobarType.
void SetInfobarInteractionHandler(
InfobarType type,
std::unique_ptr<InfobarInteractionHandler> interaction_handler);
private:
// Constructor used by CreateForBrowser().
friend class BrowserUserData<InfobarOverlayBrowserAgent>;
explicit InfobarOverlayBrowserAgent(Browser* browser);
BROWSER_USER_DATA_KEY_DECL();
// Returns the interaction handler for the InfobarType of the infobar used to
// configure |request|.
InfobarInteractionHandler* GetInteractionHandler(OverlayRequest* request);
// Helper object that notifies interaction handler of changes in banner
// visibility.
class BannerVisibilityObserver : public OverlayPresenterObserver {
public:
BannerVisibilityObserver(Browser* browser,
InfobarOverlayBrowserAgent* browser_agent);
~BannerVisibilityObserver() override;
private:
// Notifies the BrowserAgent's interaction handler that the visibility of
// |request|'s banner UI has changed.
void BannerVisibilityChanged(OverlayRequest* request, bool visible);
// OverlayPresenterObserver:
const OverlayRequestSupport* GetRequestSupport(
OverlayPresenter* presenter) const override;
void DidShowOverlay(OverlayPresenter* presenter,
OverlayRequest* request) override;
void DidHideOverlay(OverlayPresenter* presenter,
OverlayRequest* request) override;
void OverlayPresenterDestroyed(OverlayPresenter* presenter) override;
InfobarOverlayBrowserAgent* browser_agent_ = nullptr;
ScopedObserver<OverlayPresenter, OverlayPresenterObserver> scoped_observer_;
};
// The interaction handlers for each InfobarType.
std::map<InfobarType, std::unique_ptr<InfobarInteractionHandler>>
interaction_handlers_;
// The observer for infobar banner presentations and dismissals.
BannerVisibilityObserver banner_visibility_observer_;
};
#endif // IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_BROWSER_AGENT_INFOBAR_OVERLAY_BROWSER_AGENT_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/infobars/overlays/browser_agent/infobar_overlay_browser_agent.h"
#include "base/logging.h"
#import "ios/chrome/browser/infobars/overlays/browser_agent/infobar_banner_overlay_request_callback_installer.h"
#import "ios/chrome/browser/infobars/overlays/browser_agent/interaction_handlers/infobar_interaction_handler.h"
#include "ios/chrome/browser/infobars/overlays/overlay_request_infobar_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#pragma mark - InfobarOverlayBrowserAgent
BROWSER_USER_DATA_KEY_IMPL(InfobarOverlayBrowserAgent)
InfobarOverlayBrowserAgent::InfobarOverlayBrowserAgent(Browser* browser)
: OverlayBrowserAgentBase(browser),
banner_visibility_observer_(browser, this) {}
InfobarOverlayBrowserAgent::~InfobarOverlayBrowserAgent() = default;
#pragma mark Public
void InfobarOverlayBrowserAgent::SetInfobarInteractionHandler(
InfobarType type,
std::unique_ptr<InfobarInteractionHandler> interaction_handler) {
// Only one installer should be set for a single request type. Otherwise, the
// previously-set handler will be destroyed and callbacks forwarded to it will
// crash.
DCHECK(!interaction_handlers_[type]);
// Create callback installers for each supported handler.
const OverlayRequestSupport* support = interaction_handler->request_support();
AddInstaller(std::make_unique<InfobarBannerOverlayRequestCallbackInstaller>(
support, interaction_handler->banner_handler()),
OverlayModality::kInfobarBanner);
InfobarDetailSheetInteractionHandler* sheet_handler =
interaction_handler->sheet_handler();
if (sheet_handler) {
// TODO(crbug.com/1030357): Install callbacks for detail sheet when
// implemented.
}
InfobarModalInteractionHandler* modal_handler =
interaction_handler->modal_handler();
if (modal_handler) {
// TODO(crbug.com/1030357): Install callbacks for modal when implemented.
}
// Add the interaction handler to the list.
interaction_handlers_[type] = std::move(interaction_handler);
}
#pragma mark Private
InfobarInteractionHandler* InfobarOverlayBrowserAgent::GetInteractionHandler(
OverlayRequest* request) {
auto& interaction_handler =
interaction_handlers_[GetOverlayRequestInfobarType(request)];
DCHECK(interaction_handler);
DCHECK(interaction_handler->request_support()->IsRequestSupported(request));
return interaction_handler.get();
}
#pragma mark - InfobarOverlayBrowserAgent::BannerVisibilityObserver
InfobarOverlayBrowserAgent::BannerVisibilityObserver::BannerVisibilityObserver(
Browser* browser,
InfobarOverlayBrowserAgent* browser_agent)
: browser_agent_(browser_agent), scoped_observer_(this) {
DCHECK(browser_agent_);
scoped_observer_.Add(
OverlayPresenter::FromBrowser(browser, OverlayModality::kInfobarBanner));
}
InfobarOverlayBrowserAgent::BannerVisibilityObserver::
~BannerVisibilityObserver() = default;
void InfobarOverlayBrowserAgent::BannerVisibilityObserver::
BannerVisibilityChanged(OverlayRequest* request, bool visible) {
browser_agent_->GetInteractionHandler(request)
->banner_handler()
->BannerVisibilityChanged(GetOverlayRequestInfobar(request), visible);
}
const OverlayRequestSupport*
InfobarOverlayBrowserAgent::BannerVisibilityObserver::GetRequestSupport(
OverlayPresenter* presenter) const {
return browser_agent_->GetRequestSupport(presenter->GetModality());
}
void InfobarOverlayBrowserAgent::BannerVisibilityObserver::DidShowOverlay(
OverlayPresenter* presenter,
OverlayRequest* request) {
BannerVisibilityChanged(request, /*visible=*/true);
}
void InfobarOverlayBrowserAgent::BannerVisibilityObserver::DidHideOverlay(
OverlayPresenter* presenter,
OverlayRequest* request) {
BannerVisibilityChanged(request, /*visible=*/false);
}
void InfobarOverlayBrowserAgent::BannerVisibilityObserver::
OverlayPresenterDestroyed(OverlayPresenter* presenter) {
scoped_observer_.Remove(presenter);
}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/infobars/overlays/browser_agent/infobar_overlay_browser_agent.h"
#import "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
#import "ios/chrome/browser/infobars/overlays/browser_agent/infobar_banner_overlay_request_callback_installer.h"
#import "ios/chrome/browser/infobars/overlays/browser_agent/interaction_handlers/test/mock_infobar_interaction_handler.h"
#import "ios/chrome/browser/infobars/test/fake_infobar_ios.h"
#import "ios/chrome/browser/main/browser_user_data.h"
#import "ios/chrome/browser/main/test_browser.h"
#import "ios/chrome/browser/overlays/public/common/infobars/infobar_overlay_request_config.h"
#include "ios/chrome/browser/overlays/public/infobar_banner/infobar_banner_overlay_responses.h"
#include "ios/chrome/browser/overlays/public/overlay_callback_manager.h"
#import "ios/chrome/browser/overlays/public/overlay_presenter.h"
#include "ios/chrome/browser/overlays/public/overlay_request.h"
#import "ios/chrome/browser/overlays/public/overlay_request_queue.h"
#include "ios/chrome/browser/overlays/public/overlay_response.h"
#include "ios/chrome/browser/overlays/test/fake_overlay_presentation_context.h"
#include "ios/chrome/browser/overlays/test/fake_overlay_request_callback_installer.h"
#include "ios/chrome/browser/overlays/test/overlay_test_macros.h"
#import "ios/chrome/browser/web_state_list/fake_web_state_list_delegate.h"
#import "ios/chrome/browser/web_state_list/web_state_list.h"
#import "ios/chrome/browser/web_state_list/web_state_opener.h"
#import "ios/web/public/test/fakes/test_web_state.h"
#include "ios/web/public/test/web_task_environment.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/platform_test.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
// Test fixture for InfobarOverlayBrowserAgent.
class InfobarOverlayBrowserAgentTest : public PlatformTest {
public:
InfobarOverlayBrowserAgentTest()
: browser_state_(browser_state_builder_.Build()),
web_state_list_(&web_state_list_delegate_),
browser_(browser_state_.get(), &web_state_list_) {
// Add an activated WebState into whose queues infobar OverlayRequests will
// be added.
std::unique_ptr<web::WebState> web_state =
std::make_unique<web::TestWebState>();
web_state_ = web_state.get();
web_state_list_.InsertWebState(/*index=*/0, std::move(web_state),
WebStateList::INSERT_ACTIVATE,
WebStateOpener());
// Set up the infobar banner OverlayPresenter's presentation context so that
// presentation can be faked.
banner_presenter()->SetPresentationContext(&banner_presentation_context_);
// Set up the browser agent.
InfobarOverlayBrowserAgent::CreateForBrowser(&browser_);
std::unique_ptr<MockInfobarInteractionHandler> interaction_handler =
std::make_unique<MockInfobarInteractionHandler>();
mock_interaction_handler_ = interaction_handler.get();
browser_agent()->SetInfobarInteractionHandler(
InfobarType::kInfobarTypeConfirm, std::move(interaction_handler));
}
~InfobarOverlayBrowserAgentTest() override {
banner_presenter()->SetPresentationContext(nullptr);
}
InfobarOverlayBrowserAgent* browser_agent() {
return InfobarOverlayBrowserAgent::FromBrowser(&browser_);
}
OverlayPresenter* banner_presenter() {
return OverlayPresenter::FromBrowser(&browser_,
OverlayModality::kInfobarBanner);
}
OverlayRequestQueue* banner_queue() const {
return OverlayRequestQueue::FromWebState(web_state_,
OverlayModality::kInfobarBanner);
}
protected:
web::WebTaskEnvironment task_environment_;
TestChromeBrowserState::Builder browser_state_builder_;
std::unique_ptr<ios::ChromeBrowserState> browser_state_;
FakeWebStateListDelegate web_state_list_delegate_;
WebStateList web_state_list_;
web::WebState* web_state_ = nullptr;
TestBrowser browser_;
FakeOverlayPresentationContext banner_presentation_context_;
FakeInfobarIOS infobar_;
MockInfobarInteractionHandler* mock_interaction_handler_ = nullptr;
};
// Tests that the interaction handler is notified of banner presentation and
// dismissal. The rest of InfobarBannerInteractionHandler's interface is tested
// by InfobarBannerOverlayRequestCallbackInstallerTest.
TEST_F(InfobarOverlayBrowserAgentTest, BannerPresentation) {
// Add an infobar request to the banner modality, expecting
// InfobarBannerInteractionHandler::BannerVisibilityChanged() to be called.
std::unique_ptr<OverlayRequest> added_request =
OverlayRequest::CreateWithConfig<InfobarOverlayRequestConfig>(&infobar_);
OverlayRequest* request = added_request.get();
MockInfobarBannerInteractionHandler& mock_banner_handler =
*mock_interaction_handler_->mock_banner_handler();
EXPECT_CALL(mock_banner_handler,
BannerVisibilityChanged(&infobar_, /*visible=*/true));
banner_queue()->AddRequest(std::move(added_request));
// Set up the completion response and expect for the interaction handler to
// receive the BannerCompleted() callback.
bool user_initiated = true;
request->GetCallbackManager()->SetCompletionResponse(
OverlayResponse::CreateWithInfo<InfobarBannerCompletionResponse>(
user_initiated));
EXPECT_CALL(mock_banner_handler, BannerCompleted(&infobar_, user_initiated));
// Simulate dismissal of the request's UI, expecting
// InfobarBannerInteractionHandler::BannerVisibilityChanged() to be called.
EXPECT_CALL(mock_banner_handler,
BannerVisibilityChanged(&infobar_, /*visible=*/false));
banner_presentation_context_.SimulateDismissalForRequest(
request, OverlayDismissalReason::kUserInteraction);
}
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_INFOBAR_OVERLAY_BROWSER_AGENT_UTIL_H_ #ifndef IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_BROWSER_AGENT_INFOBAR_OVERLAY_BROWSER_AGENT_UTIL_H_
#define IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_INFOBAR_OVERLAY_BROWSER_AGENT_UTIL_H_ #define IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_BROWSER_AGENT_INFOBAR_OVERLAY_BROWSER_AGENT_UTIL_H_
class Browser; class Browser;
// Attaches browser agents to |browser| that manage the model changes for // Attaches browser agents to |browser| that manage the model changes for
// infobar UI presented via OverlayPresenter. // infobar UI presented via OverlayPresenter.
void AttachInfobarOverlayBrowserAgents(Browser* browser); void AttachInfobarOverlayBrowserAgent(Browser* browser);
#endif // IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_INFOBAR_OVERLAY_BROWSER_AGENT_UTIL_H_ #endif // IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_BROWSER_AGENT_INFOBAR_OVERLAY_BROWSER_AGENT_UTIL_H_
...@@ -2,13 +2,20 @@ ...@@ -2,13 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ios/chrome/browser/infobars/overlays/infobar_overlay_browser_agent_util.h" #include "ios/chrome/browser/infobars/overlays/browser_agent/infobar_overlay_browser_agent_util.h"
#include "base/feature_list.h" #include "base/feature_list.h"
#import "ios/chrome/browser/infobars/overlays/browser_agent/infobar_overlay_browser_agent.h"
#import "ios/chrome/browser/ui/infobars/infobar_feature.h" #import "ios/chrome/browser/ui/infobars/infobar_feature.h"
void AttachInfobarOverlayBrowserAgents(Browser* browser) { #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
void AttachInfobarOverlayBrowserAgent(Browser* browser) {
if (!base::FeatureList::IsEnabled(kInfobarOverlayUI)) if (!base::FeatureList::IsEnabled(kInfobarOverlayUI))
return; return;
// TODO(crbug.com/1030357): Create browser agents. InfobarOverlayBrowserAgent::CreateForBrowser(browser);
// TODO(crbug.com/1030357): Add InfobarInteractionHandlers for each
// InfobarType when implemented.
} }
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
source_set("interaction_handlers") {
configs += [ "//build/config/compiler:enable_arc" ]
friend = [ ":unit_tests" ]
sources = [
"infobar_interaction_handler.h",
"infobar_interaction_handler.mm",
]
deps = [
"//base",
"//ios/chrome/browser/overlays",
]
}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_BROWSER_AGENT_INTERACTION_HANDLERS_INFOBAR_INTERACTION_HANDLER_H_
#define IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_BROWSER_AGENT_INTERACTION_HANDLERS_INFOBAR_INTERACTION_HANDLER_H_
#include <memory>
#include "ios/chrome/browser/overlays/public/overlay_request_support.h"
class InfoBarIOS;
namespace web {
class WebState;
}
// Handler for infobar banner user interaction events.
class InfobarBannerInteractionHandler {
public:
virtual ~InfobarBannerInteractionHandler() = default;
// Updates the model when the visibility of |infobar|'s banner is changed.
virtual void BannerVisibilityChanged(InfoBarIOS* infobar, bool visible) = 0;
// Updates the model when the main button is tapped for |infobar|'s banner.
virtual void MainButtonTapped(InfoBarIOS* infobar) = 0;
// Shows the modal when the modal button is tapped for |infobar|'s banner.
// |web_state| is the WebState associated with |infobar|'s InfoBarManager.
virtual void ShowModalButtonTapped(InfoBarIOS* infobar,
web::WebState* web_state) = 0;
// Called when the banner overlay for |infobar| is completed. Called when the
// banner UI is dismissed by user interaction or when its request is
// cancelled. |user_initiated| describes whether the banner was dismissed for
// user interaction.
virtual void BannerCompleted(InfoBarIOS* infobar, bool user_initiated) = 0;
};
// Handler for infobar detail sheet user interaction events.
class InfobarDetailSheetInteractionHandler {
public:
virtual ~InfobarDetailSheetInteractionHandler() = default;
// TODO(crbug.com/1030357): Add interaction handling for detail sheets.
};
// Handler for infobar modal user interaction events.
class InfobarModalInteractionHandler {
public:
virtual ~InfobarModalInteractionHandler() = default;
// TODO(crbug.com/1030357): Add interaction handling for modals.
};
// Helper object, intended to be subclassed, that encapsulates the model-layer
// updates required for interaction with each type of UI used to display an
// infobar. Subclasses should be created for each InfobarType to manage the
// user interaction for InfoBars of that type.
class InfobarInteractionHandler {
public:
virtual ~InfobarInteractionHandler();
// Returns the request support for the handler. Interaction events will only
// be handled for supported requests. Guaranteed to be non-null.
const OverlayRequestSupport* request_support() const {
return request_support_;
}
// Returns the handlers for each InfobarOverlayType. Guaranteed to be
// non-null.
InfobarBannerInteractionHandler* banner_handler() const {
return banner_handler_.get();
}
// Returns the detail sheet handler for this interaction handler.
InfobarDetailSheetInteractionHandler* sheet_handler() const {
return sheet_handler_.get();
}
// Returns the modal handler for this interaction handler.
InfobarModalInteractionHandler* modal_handler() const {
return modal_handler_.get();
}
protected:
// Initializer used by subclasses that return the passed handlers from the
// getters above. |banner_handler| must be non-null for all InfobarTypes.
// |sheet_handler| and |modal_handler| may be null if the infobar whose
// interactions are being handled do not support these overlay types.
InfobarInteractionHandler(
const OverlayRequestSupport* request_support,
std::unique_ptr<InfobarBannerInteractionHandler> banner_handler,
std::unique_ptr<InfobarDetailSheetInteractionHandler> sheet_handler,
std::unique_ptr<InfobarModalInteractionHandler> modal_handler);
// The request support passed on initialization. Only interactions with
// supported requests should be handled by this instance.
const OverlayRequestSupport* request_support_ = nullptr;
// The interaction handlers passed on initialization.
std::unique_ptr<InfobarBannerInteractionHandler> banner_handler_;
std::unique_ptr<InfobarDetailSheetInteractionHandler> sheet_handler_;
std::unique_ptr<InfobarModalInteractionHandler> modal_handler_;
};
#endif // IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_BROWSER_AGENT_INTERACTION_HANDLERS_INFOBAR_INTERACTION_HANDLER_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/infobars/overlays/browser_agent/interaction_handlers/infobar_interaction_handler.h"
#include "base/logging.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
InfobarInteractionHandler::InfobarInteractionHandler(
const OverlayRequestSupport* request_support,
std::unique_ptr<InfobarBannerInteractionHandler> banner_handler,
std::unique_ptr<InfobarDetailSheetInteractionHandler> sheet_handler,
std::unique_ptr<InfobarModalInteractionHandler> modal_handler)
: request_support_(request_support),
banner_handler_(std::move(banner_handler)),
sheet_handler_(std::move(sheet_handler)),
modal_handler_(std::move(modal_handler)) {
DCHECK(request_support_);
DCHECK(banner_handler_.get());
}
InfobarInteractionHandler::~InfobarInteractionHandler() = default;
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
source_set("test") {
testonly = true
sources = [
"mock_infobar_interaction_handler.h",
"mock_infobar_interaction_handler.mm",
]
configs += [ "//build/config/compiler:enable_arc" ]
deps = [
"//base",
"//ios/chrome/browser/infobars/overlays/browser_agent/interaction_handlers",
"//ios/chrome/browser/overlays",
"//ios/chrome/browser/overlays/public/common/infobars",
"//ios/chrome/browser/overlays/public/infobar_banner",
"//ios/chrome/browser/overlays/test",
"//ios/web/public/test/fakes",
"//testing/gmock",
"//testing/gtest",
]
}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_BROWSER_AGENT_INTERACTION_HANDLERS_TEST_MOCK_INFOBAR_INTERACTION_HANDLER_H_
#define IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_BROWSER_AGENT_INTERACTION_HANDLERS_TEST_MOCK_INFOBAR_INTERACTION_HANDLER_H_
#import "ios/chrome/browser/infobars/overlays/browser_agent/interaction_handlers/infobar_interaction_handler.h"
#include "testing/gmock/include/gmock/gmock.h"
// Mock version of InfobarBannerInteractionHandler.
class MockInfobarBannerInteractionHandler
: public InfobarBannerInteractionHandler {
public:
MockInfobarBannerInteractionHandler();
~MockInfobarBannerInteractionHandler() override;
MOCK_METHOD2(BannerVisibilityChanged,
void(InfoBarIOS* infobar, bool visible));
MOCK_METHOD1(MainButtonTapped, void(InfoBarIOS* infobar));
MOCK_METHOD2(ShowModalButtonTapped,
void(InfoBarIOS* infobar, web::WebState* web_state));
MOCK_METHOD2(BannerCompleted, void(InfoBarIOS* infobar, bool user_initiated));
};
// Mock version of InfobarDetailSheetInteractionHandler.
class MockInfobarDetailSheetInteractionHandler
: public InfobarDetailSheetInteractionHandler {
public:
MockInfobarDetailSheetInteractionHandler();
~MockInfobarDetailSheetInteractionHandler() override;
// TODO(crbug.com/1030357): Add mock interaction handling for detail sheets.
};
// Mock version of MockInfobarModalInteractionHandler.
class MockInfobarModalInteractionHandler
: public InfobarModalInteractionHandler {
public:
MockInfobarModalInteractionHandler();
~MockInfobarModalInteractionHandler() override;
// TODO(crbug.com/1030357): Add mock interaction handling for modals.
};
// InfobarModalInteractionHandler subclass that returns mock versions of the
// banner, detail sheet, and modal interaction handlers.
class MockInfobarInteractionHandler : public InfobarInteractionHandler {
public:
MockInfobarInteractionHandler();
~MockInfobarInteractionHandler() override;
MockInfobarBannerInteractionHandler* mock_banner_handler() {
return mock_banner_handler_;
}
MockInfobarDetailSheetInteractionHandler* mock_sheet_handler() {
return mock_sheet_handler_;
}
MockInfobarModalInteractionHandler* mock_modal_handler() {
return mock_modal_handler_;
}
private:
// Pointers to the mock handlers passed to the InfobarInteractionHandler
// constructor. Guaranteed to be non-null for the lifetime of the object.
MockInfobarBannerInteractionHandler* mock_banner_handler_ = nullptr;
MockInfobarDetailSheetInteractionHandler* mock_sheet_handler_ = nullptr;
MockInfobarModalInteractionHandler* mock_modal_handler_ = nullptr;
};
#endif // IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_BROWSER_AGENT_INTERACTION_HANDLERS_TEST_MOCK_INFOBAR_INTERACTION_HANDLER_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/infobars/overlays/browser_agent/interaction_handlers/test/mock_infobar_interaction_handler.h"
#import "ios/chrome/browser/overlays/public/common/infobars/infobar_overlay_request_config.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
#pragma mark - MockInfobarBannerInteractionHandler
MockInfobarBannerInteractionHandler::MockInfobarBannerInteractionHandler() =
default;
MockInfobarBannerInteractionHandler::~MockInfobarBannerInteractionHandler() =
default;
#pragma mark - MockInfobarDetailSheetInteractionHandler
MockInfobarDetailSheetInteractionHandler::
MockInfobarDetailSheetInteractionHandler() = default;
MockInfobarDetailSheetInteractionHandler::
~MockInfobarDetailSheetInteractionHandler() = default;
#pragma mark - MockInfobarModalInteractionHandler
MockInfobarModalInteractionHandler::MockInfobarModalInteractionHandler() =
default;
MockInfobarModalInteractionHandler::~MockInfobarModalInteractionHandler() =
default;
#pragma mark - MockInfobarModalInteractionHandler
MockInfobarInteractionHandler::MockInfobarInteractionHandler()
: InfobarInteractionHandler(
InfobarOverlayRequestConfig::RequestSupport(),
std::make_unique<MockInfobarBannerInteractionHandler>(),
std::make_unique<MockInfobarDetailSheetInteractionHandler>(),
std::make_unique<MockInfobarModalInteractionHandler>()) {
mock_banner_handler_ =
static_cast<MockInfobarBannerInteractionHandler*>(banner_handler());
mock_sheet_handler_ =
static_cast<MockInfobarDetailSheetInteractionHandler*>(sheet_handler());
mock_modal_handler_ =
static_cast<MockInfobarModalInteractionHandler*>(modal_handler());
}
MockInfobarInteractionHandler::~MockInfobarInteractionHandler() = default;
...@@ -2,13 +2,18 @@ ...@@ -2,13 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_OVERLAY_REQUEST_INFOBAR_TYPE_UTIL_H_ #ifndef IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_OVERLAY_REQUEST_INFOBAR_UTIL_H_
#define IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_OVERLAY_REQUEST_INFOBAR_TYPE_UTIL_H_ #define IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_OVERLAY_REQUEST_INFOBAR_UTIL_H_
#import "ios/chrome/browser/infobars/infobar_type.h" #import "ios/chrome/browser/infobars/infobar_type.h"
class InfoBarIOS;
class OverlayRequest; class OverlayRequest;
// Returns the InfoBarIOS used to configure |request|, or nullptr if it was not
// created with an infobar config.
InfoBarIOS* GetOverlayRequestInfobar(OverlayRequest* request);
// Returns the InfobarType of the InfoBar used to configure |request|. // Returns the InfobarType of the InfoBar used to configure |request|.
// |request| must be non-null and configured with an // |request| must be non-null and configured with an
// InfobarOverlayRequestConfig. // InfobarOverlayRequestConfig.
...@@ -16,4 +21,4 @@ class OverlayRequest; ...@@ -16,4 +21,4 @@ class OverlayRequest;
// InfobarType::kNone once added. // InfobarType::kNone once added.
InfobarType GetOverlayRequestInfobarType(OverlayRequest* request); InfobarType GetOverlayRequestInfobarType(OverlayRequest* request);
#endif // IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_OVERLAY_REQUEST_INFOBAR_TYPE_UTIL_H_ #endif // IOS_CHROME_BROWSER_INFOBARS_OVERLAYS_OVERLAY_REQUEST_INFOBAR_UTIL_H_
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ios/chrome/browser/infobars/overlays/overlay_request_infobar_type_util.h" #include "ios/chrome/browser/infobars/overlays/overlay_request_infobar_util.h"
#include "ios/chrome/browser/infobars/infobar_ios.h"
#import "ios/chrome/browser/overlays/public/common/infobars/infobar_overlay_request_config.h" #import "ios/chrome/browser/overlays/public/common/infobars/infobar_overlay_request_config.h"
#include "ios/chrome/browser/overlays/public/overlay_request.h" #include "ios/chrome/browser/overlays/public/overlay_request.h"
...@@ -11,6 +12,12 @@ ...@@ -11,6 +12,12 @@
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
InfoBarIOS* GetOverlayRequestInfobar(OverlayRequest* request) {
InfobarOverlayRequestConfig* config =
request->GetConfig<InfobarOverlayRequestConfig>();
return config ? config->infobar() : nullptr;
}
InfobarType GetOverlayRequestInfobarType(OverlayRequest* request) { InfobarType GetOverlayRequestInfobarType(OverlayRequest* request) {
return request->GetConfig<InfobarOverlayRequestConfig>()->infobar_type(); return request->GetConfig<InfobarOverlayRequestConfig>()->infobar_type();
} }
...@@ -33,12 +33,11 @@ source_set("main") { ...@@ -33,12 +33,11 @@ source_set("main") {
"//ios/chrome/browser/browser_state", "//ios/chrome/browser/browser_state",
"//ios/chrome/browser/crash_report/breadcrumbs", "//ios/chrome/browser/crash_report/breadcrumbs",
"//ios/chrome/browser/crash_report/breadcrumbs:feature_flags", "//ios/chrome/browser/crash_report/breadcrumbs:feature_flags",
"//ios/chrome/browser/infobars/overlays:browser_agent_util", "//ios/chrome/browser/infobars/overlays/browser_agent:browser_agent_util",
"//ios/chrome/browser/sessions:serialisation", "//ios/chrome/browser/sessions:serialisation",
"//ios/chrome/browser/sessions:session_service", "//ios/chrome/browser/sessions:session_service",
"//ios/chrome/browser/tabs", "//ios/chrome/browser/tabs",
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/infobars:feature_flags",
"//ios/chrome/browser/web_state_list", "//ios/chrome/browser/web_state_list",
"//ios/public/provider/chrome/browser", "//ios/public/provider/chrome/browser",
] ]
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "base/feature_list.h" #include "base/feature_list.h"
#include "ios/chrome/browser/crash_report/breadcrumbs/breadcrumb_manager_browser_agent.h" #include "ios/chrome/browser/crash_report/breadcrumbs/breadcrumb_manager_browser_agent.h"
#include "ios/chrome/browser/crash_report/breadcrumbs/features.h" #include "ios/chrome/browser/crash_report/breadcrumbs/features.h"
#include "ios/chrome/browser/infobars/overlays/infobar_overlay_browser_agent_util.h" #include "ios/chrome/browser/infobars/overlays/browser_agent/infobar_overlay_browser_agent_util.h"
#import "ios/chrome/browser/web_state_list/tab_insertion_browser_agent.h" #import "ios/chrome/browser/web_state_list/tab_insertion_browser_agent.h"
#include "ios/public/provider/chrome/browser/chrome_browser_provider.h" #include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
...@@ -20,7 +20,7 @@ void AttachBrowserAgents(Browser* browser) { ...@@ -20,7 +20,7 @@ void AttachBrowserAgents(Browser* browser) {
BreadcrumbManagerBrowserAgent::CreateForBrowser(browser); BreadcrumbManagerBrowserAgent::CreateForBrowser(browser);
} }
TabInsertionBrowserAgent::CreateForBrowser(browser); TabInsertionBrowserAgent::CreateForBrowser(browser);
AttachInfobarOverlayBrowserAgents(browser); AttachInfobarOverlayBrowserAgent(browser);
// This needs to be called last in case any downstream browser agents need to // This needs to be called last in case any downstream browser agents need to
// access upstream agents created earlier in this function. // access upstream agents created earlier in this function.
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "ios/chrome/browser/infobars/infobar_badge_tab_helper_delegate.h" #include "ios/chrome/browser/infobars/infobar_badge_tab_helper_delegate.h"
#include "ios/chrome/browser/infobars/infobar_metrics_recorder.h" #include "ios/chrome/browser/infobars/infobar_metrics_recorder.h"
#import "ios/chrome/browser/infobars/infobar_type.h" #import "ios/chrome/browser/infobars/infobar_type.h"
#include "ios/chrome/browser/infobars/overlays/overlay_request_infobar_type_util.h" #include "ios/chrome/browser/infobars/overlays/overlay_request_infobar_util.h"
#include "ios/chrome/browser/main/browser.h" #include "ios/chrome/browser/main/browser.h"
#import "ios/chrome/browser/overlays/public/overlay_presenter.h" #import "ios/chrome/browser/overlays/public/overlay_presenter.h"
#import "ios/chrome/browser/overlays/public/overlay_presenter_observer_bridge.h" #import "ios/chrome/browser/overlays/public/overlay_presenter_observer_bridge.h"
......
...@@ -191,6 +191,7 @@ test("ios_chrome_unittests") { ...@@ -191,6 +191,7 @@ test("ios_chrome_unittests") {
"//ios/chrome/browser/history:unit_tests", "//ios/chrome/browser/history:unit_tests",
"//ios/chrome/browser/infobars:unit_tests", "//ios/chrome/browser/infobars:unit_tests",
"//ios/chrome/browser/infobars/overlays:unit_tests", "//ios/chrome/browser/infobars/overlays:unit_tests",
"//ios/chrome/browser/infobars/overlays/browser_agent:unit_tests",
"//ios/chrome/browser/itunes_urls:unit_tests", "//ios/chrome/browser/itunes_urls:unit_tests",
"//ios/chrome/browser/json_parser:unit_tests", "//ios/chrome/browser/json_parser:unit_tests",
"//ios/chrome/browser/language:unit_tests", "//ios/chrome/browser/language:unit_tests",
......
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