| 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 COMPONENTS_INFOBARS_CORE_INFOBAR_MANAGER_H_ | 5 #ifndef COMPONENTS_INFOBARS_CORE_INFOBAR_MANAGER_H_ |
| 6 #define COMPONENTS_INFOBARS_CORE_INFOBAR_MANAGER_H_ | 6 #define COMPONENTS_INFOBARS_CORE_INFOBAR_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // | 86 // |
| 87 // Warning: Does not sanity check |index|. | 87 // Warning: Does not sanity check |index|. |
| 88 InfoBar* infobar_at(size_t index) { return infobars_[index]; } | 88 InfoBar* infobar_at(size_t index) { return infobars_[index]; } |
| 89 | 89 |
| 90 // Must be called when a navigation happens. | 90 // Must be called when a navigation happens. |
| 91 void OnNavigation(const InfoBarDelegate::NavigationDetails& details); | 91 void OnNavigation(const InfoBarDelegate::NavigationDetails& details); |
| 92 | 92 |
| 93 void AddObserver(Observer* obs); | 93 void AddObserver(Observer* obs); |
| 94 void RemoveObserver(Observer* obs); | 94 void RemoveObserver(Observer* obs); |
| 95 | 95 |
| 96 bool animations_enabled() const { return animations_enabled_; } |
| 97 |
| 96 // Returns the active entry ID. | 98 // Returns the active entry ID. |
| 97 virtual int GetActiveEntryID() = 0; | 99 virtual int GetActiveEntryID() = 0; |
| 98 | 100 |
| 99 // Returns a confirm infobar that owns |delegate|. | 101 // Returns a confirm infobar that owns |delegate|. |
| 100 virtual std::unique_ptr<infobars::InfoBar> CreateConfirmInfoBar( | 102 virtual std::unique_ptr<infobars::InfoBar> CreateConfirmInfoBar( |
| 101 std::unique_ptr<ConfirmInfoBarDelegate> delegate) = 0; | 103 std::unique_ptr<ConfirmInfoBarDelegate> delegate) = 0; |
| 102 | 104 |
| 103 // Opens a URL according to the specified |disposition|. | 105 // Opens a URL according to the specified |disposition|. |
| 104 virtual void OpenURL(const GURL& url, WindowOpenDisposition disposition) = 0; | 106 virtual void OpenURL(const GURL& url, WindowOpenDisposition disposition) = 0; |
| 105 | 107 |
| 106 protected: | 108 protected: |
| 109 void set_animations_enabled(bool animations_enabled) { |
| 110 animations_enabled_ = animations_enabled; |
| 111 } |
| 112 |
| 107 // Notifies the observer in |observer_list_|. | 113 // Notifies the observer in |observer_list_|. |
| 108 // TODO(droger): Absorb these methods back into their callers once virtual | 114 // TODO(droger): Absorb these methods back into their callers once virtual |
| 109 // overrides are removed (see http://crbug.com/354380). | 115 // overrides are removed (see http://crbug.com/354380). |
| 110 virtual void NotifyInfoBarAdded(InfoBar* infobar); | 116 virtual void NotifyInfoBarAdded(InfoBar* infobar); |
| 111 virtual void NotifyInfoBarRemoved(InfoBar* infobar, bool animate); | 117 virtual void NotifyInfoBarRemoved(InfoBar* infobar, bool animate); |
| 112 | 118 |
| 113 private: | 119 private: |
| 114 // InfoBars associated with this InfoBarManager. We own these pointers. | 120 // InfoBars associated with this InfoBarManager. We own these pointers. |
| 115 // However, this is not a ScopedVector, because we don't delete the infobars | 121 // However, this is not a ScopedVector, because we don't delete the infobars |
| 116 // directly once they've been added to this; instead, when we're done with an | 122 // directly once they've been added to this; instead, when we're done with an |
| 117 // infobar, we instruct it to delete itself and then orphan it. See | 123 // infobar, we instruct it to delete itself and then orphan it. See |
| 118 // RemoveInfoBarInternal(). | 124 // RemoveInfoBarInternal(). |
| 119 typedef std::vector<InfoBar*> InfoBars; | 125 typedef std::vector<InfoBar*> InfoBars; |
| 120 | 126 |
| 121 void RemoveInfoBarInternal(InfoBar* infobar, bool animate); | 127 void RemoveInfoBarInternal(InfoBar* infobar, bool animate); |
| 122 | 128 |
| 123 InfoBars infobars_; | 129 InfoBars infobars_; |
| 124 bool infobars_enabled_; | 130 bool infobars_enabled_ = true; |
| 131 bool animations_enabled_ = true; |
| 125 | 132 |
| 126 base::ObserverList<Observer, true> observer_list_; | 133 base::ObserverList<Observer, true> observer_list_; |
| 127 | 134 |
| 128 DISALLOW_COPY_AND_ASSIGN(InfoBarManager); | 135 DISALLOW_COPY_AND_ASSIGN(InfoBarManager); |
| 129 }; | 136 }; |
| 130 | 137 |
| 131 } // namespace infobars | 138 } // namespace infobars |
| 132 | 139 |
| 133 #endif // COMPONENTS_INFOBARS_CORE_INFOBAR_MANAGER_H_ | 140 #endif // COMPONENTS_INFOBARS_CORE_INFOBAR_MANAGER_H_ |
| OLD | NEW |