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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_INFOBARS_INFOBAR_RESPONDER_H_
6 #define CHROME_BROWSER_INFOBARS_INFOBAR_RESPONDER_H_
8 #include "base/macros.h"
9 #include "components/infobars/core/infobar_manager.h"
15 class ConfirmInfoBarDelegate
;
18 // Used by test code to asynchronously respond to the first infobar shown, which
19 // must have a ConfirmInfoBarDelegate. This can be used to ensure various
20 // interaction flows work correctly.
22 // The asynchronous response matches how real users will use the infobar.
23 class InfoBarResponder
: public infobars::InfoBarManager::Observer
{
25 enum AutoResponseType
{
31 // The responder will asynchronously perform the requested |response|.
32 InfoBarResponder(InfoBarService
* infobar_service
, AutoResponseType response
);
33 ~InfoBarResponder() override
;
35 // infobars::InfoBarManager::Observer:
36 void OnInfoBarAdded(infobars::InfoBar
* infobar
) override
;
37 void OnInfoBarReplaced(infobars::InfoBar
* old_infobar
,
38 infobars::InfoBar
* new_infobar
) override
;
41 void Respond(ConfirmInfoBarDelegate
* delegate
);
43 InfoBarService
* infobar_service_
;
44 AutoResponseType response_
;
46 DISALLOW_COPY_AND_ASSIGN(InfoBarResponder
);
49 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_RESPONDER_H_