1 // Copyright 2014 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 IOS_CHROME_BROWSER_INFOBARS_INFOBAR_MANAGER_IMPL_H_
6 #define IOS_CHROME_BROWSER_INFOBARS_INFOBAR_MANAGER_IMPL_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "components/infobars/core/infobar_manager.h"
10 #include "ios/web/public/web_state/web_state_observer.h"
11 #include "ios/web/public/web_state/web_state_user_data.h"
18 struct LoadCommittedDetails
;
22 // Associates a Tab to an InfoBarManager and manages its lifetime.
23 // It responds to navigation events.
24 class InfoBarManagerImpl
: public infobars::InfoBarManager
,
25 public web::WebStateObserver
,
26 public web::WebStateUserData
<InfoBarManagerImpl
> {
28 // This function must only be called on infobars that are owned by an
29 // InfoBarManagerImpl instance (or not owned at all, in which case this
31 static web::WebState
* WebStateFromInfoBar(infobars::InfoBar
* infobar
);
34 friend class web::WebStateUserData
<InfoBarManagerImpl
>;
36 explicit InfoBarManagerImpl(web::WebState
* web_state
);
37 ~InfoBarManagerImpl() override
;
39 // InfoBarManager implementation.
40 int GetActiveEntryID() override
;
41 scoped_ptr
<infobars::InfoBar
> CreateConfirmInfoBar(
42 scoped_ptr
<ConfirmInfoBarDelegate
> delegate
) override
;
44 // web::WebStateObserver implementation.
45 void NavigationItemCommitted(
46 const web::LoadCommittedDetails
& load_details
) override
;
47 void WebStateDestroyed() override
;
49 DISALLOW_COPY_AND_ASSIGN(InfoBarManagerImpl
);
52 #endif // IOS_CHROME_BROWSER_INFOBARS_INFOBAR_MANAGER_IMPL_H_