OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef IOS_CHROME_BROWSER_INFOBARS_INFOBAR_MANAGER_IMPL_H_ | 5 #ifndef IOS_CHROME_BROWSER_INFOBARS_INFOBAR_MANAGER_IMPL_H_ |
6 #define IOS_CHROME_BROWSER_INFOBARS_INFOBAR_MANAGER_IMPL_H_ | 6 #define IOS_CHROME_BROWSER_INFOBARS_INFOBAR_MANAGER_IMPL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "components/infobars/core/infobar_manager.h" | 11 #include "components/infobars/core/infobar_manager.h" |
12 #include "ios/web/public/web_state/web_state_observer.h" | 12 #include "ios/web/public/web_state/web_state_observer.h" |
13 #include "ios/web/public/web_state/web_state_user_data.h" | 13 #include "ios/web/public/web_state/web_state_user_data.h" |
14 | 14 |
15 namespace infobars { | 15 namespace infobars { |
16 class InfoBar; | 16 class InfoBar; |
17 } | 17 } |
18 | 18 |
19 namespace web { | 19 namespace web { |
20 struct LoadCommittedDetails; | 20 struct LoadCommittedDetails; |
21 class WebState; | 21 class WebState; |
22 } | 22 } |
23 | 23 |
24 // Associates a Tab to an InfoBarManager and manages its lifetime. | 24 // Associates a Tab to an InfoBarManager and manages its lifetime. |
25 // It responds to navigation events. | 25 // It responds to navigation events. |
26 class InfoBarManagerImpl : public infobars::InfoBarManager, | 26 class InfoBarManagerImpl : public infobars::InfoBarManager, |
27 public web::WebStateObserver, | 27 public web::WebStateObserver, |
28 public web::WebStateUserData<InfoBarManagerImpl> { | 28 public web::WebStateUserData<InfoBarManagerImpl> { |
29 public: | 29 public: |
| 30 ~InfoBarManagerImpl() override; |
| 31 |
30 // This function must only be called on infobars that are owned by an | 32 // This function must only be called on infobars that are owned by an |
31 // InfoBarManagerImpl instance (or not owned at all, in which case this | 33 // InfoBarManagerImpl instance (or not owned at all, in which case this |
32 // returns null). | 34 // returns null). |
33 static web::WebState* WebStateFromInfoBar(infobars::InfoBar* infobar); | 35 static web::WebState* WebStateFromInfoBar(infobars::InfoBar* infobar); |
34 | 36 |
35 private: | 37 private: |
36 friend class web::WebStateUserData<InfoBarManagerImpl>; | 38 friend class web::WebStateUserData<InfoBarManagerImpl>; |
37 | 39 |
38 explicit InfoBarManagerImpl(web::WebState* web_state); | 40 explicit InfoBarManagerImpl(web::WebState* web_state); |
39 ~InfoBarManagerImpl() override; | |
40 | 41 |
41 // InfoBarManager implementation. | 42 // InfoBarManager implementation. |
42 int GetActiveEntryID() override; | 43 int GetActiveEntryID() override; |
43 std::unique_ptr<infobars::InfoBar> CreateConfirmInfoBar( | 44 std::unique_ptr<infobars::InfoBar> CreateConfirmInfoBar( |
44 std::unique_ptr<ConfirmInfoBarDelegate> delegate) override; | 45 std::unique_ptr<ConfirmInfoBarDelegate> delegate) override; |
45 | 46 |
46 // web::WebStateObserver implementation. | 47 // web::WebStateObserver implementation. |
47 void NavigationItemCommitted( | 48 void NavigationItemCommitted( |
48 const web::LoadCommittedDetails& load_details) override; | 49 const web::LoadCommittedDetails& load_details) override; |
49 void WebStateDestroyed() override; | 50 void WebStateDestroyed() override; |
50 | 51 |
51 // Opens a URL according to the specified |disposition|. | 52 // Opens a URL according to the specified |disposition|. |
52 void OpenURL(const GURL& url, WindowOpenDisposition disposition) override; | 53 void OpenURL(const GURL& url, WindowOpenDisposition disposition) override; |
53 | 54 |
54 DISALLOW_COPY_AND_ASSIGN(InfoBarManagerImpl); | 55 DISALLOW_COPY_AND_ASSIGN(InfoBarManagerImpl); |
55 }; | 56 }; |
56 | 57 |
57 #endif // IOS_CHROME_BROWSER_INFOBARS_INFOBAR_MANAGER_IMPL_H_ | 58 #endif // IOS_CHROME_BROWSER_INFOBARS_INFOBAR_MANAGER_IMPL_H_ |
OLD | NEW |