| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "components/infobars/core/infobar_delegate.h" | 12 #include "components/infobars/core/infobar_delegate.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 class WebContents; | 15 class WebContents; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace infobars { | 18 namespace infobars { |
| 19 | 19 |
| 20 class InfoBar; | 20 class InfoBar; |
| 21 struct InfoBarConstants; |
| 21 | 22 |
| 22 // Provides access to creating, removing and enumerating info bars | 23 // Provides access to creating, removing and enumerating info bars |
| 23 // attached to a tab. | 24 // attached to a tab. |
| 24 class InfoBarManager { | 25 class InfoBarManager { |
| 25 public: | 26 public: |
| 26 // Observer class for infobar events. | 27 // Observer class for infobar events. |
| 27 class Observer { | 28 class Observer { |
| 28 public: | 29 public: |
| 29 virtual ~Observer(); | 30 virtual ~Observer(); |
| 30 | 31 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 88 |
| 88 // Must be called when a navigation happens. | 89 // Must be called when a navigation happens. |
| 89 void OnNavigation(const InfoBarDelegate::NavigationDetails& details); | 90 void OnNavigation(const InfoBarDelegate::NavigationDetails& details); |
| 90 | 91 |
| 91 void AddObserver(Observer* obs); | 92 void AddObserver(Observer* obs); |
| 92 void RemoveObserver(Observer* obs); | 93 void RemoveObserver(Observer* obs); |
| 93 | 94 |
| 94 // Returns the active entry ID. | 95 // Returns the active entry ID. |
| 95 virtual int GetActiveEntryID() = 0; | 96 virtual int GetActiveEntryID() = 0; |
| 96 | 97 |
| 98 // Returns the constants to use for InfoBar animations. |
| 99 virtual const InfoBarConstants& GetInfoBarConstants() const = 0; |
| 100 |
| 97 protected: | 101 protected: |
| 98 // Notifies the observer in |observer_list_|. | 102 // Notifies the observer in |observer_list_|. |
| 99 // TODO(droger): Absorb these methods back into their callers once virtual | 103 // TODO(droger): Absorb these methods back into their callers once virtual |
| 100 // overrides are removed (see http://crbug.com/354380). | 104 // overrides are removed (see http://crbug.com/354380). |
| 101 virtual void NotifyInfoBarAdded(InfoBar* infobar); | 105 virtual void NotifyInfoBarAdded(InfoBar* infobar); |
| 102 virtual void NotifyInfoBarRemoved(InfoBar* infobar, bool animate); | 106 virtual void NotifyInfoBarRemoved(InfoBar* infobar, bool animate); |
| 103 | 107 |
| 104 private: | 108 private: |
| 105 // InfoBars associated with this InfoBarManager. We own these pointers. | 109 // InfoBars associated with this InfoBarManager. We own these pointers. |
| 106 // However, this is not a ScopedVector, because we don't delete the infobars | 110 // However, this is not a ScopedVector, because we don't delete the infobars |
| 107 // directly once they've been added to this; instead, when we're done with an | 111 // directly once they've been added to this; instead, when we're done with an |
| 108 // infobar, we instruct it to delete itself and then orphan it. See | 112 // infobar, we instruct it to delete itself and then orphan it. See |
| 109 // RemoveInfoBarInternal(). | 113 // RemoveInfoBarInternal(). |
| 110 typedef std::vector<InfoBar*> InfoBars; | 114 typedef std::vector<InfoBar*> InfoBars; |
| 111 | 115 |
| 112 void RemoveInfoBarInternal(InfoBar* infobar, bool animate); | 116 void RemoveInfoBarInternal(InfoBar* infobar, bool animate); |
| 113 | 117 |
| 114 InfoBars infobars_; | 118 InfoBars infobars_; |
| 115 bool infobars_enabled_; | 119 bool infobars_enabled_; |
| 116 | 120 |
| 117 ObserverList<Observer, true> observer_list_; | 121 ObserverList<Observer, true> observer_list_; |
| 118 | 122 |
| 119 DISALLOW_COPY_AND_ASSIGN(InfoBarManager); | 123 DISALLOW_COPY_AND_ASSIGN(InfoBarManager); |
| 120 }; | 124 }; |
| 121 | 125 |
| 122 } // namespace infobars | 126 } // namespace infobars |
| 123 | 127 |
| 124 #endif // COMPONENTS_INFOBARS_CORE_INFOBAR_MANAGER_H_ | 128 #endif // COMPONENTS_INFOBARS_CORE_INFOBAR_MANAGER_H_ |
| OLD | NEW |