| 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 #include "components/infobars/core/infobar_manager.h" | 5 #include "components/infobars/core/infobar_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "components/infobars/core/infobar.h" | 10 #include "components/infobars/core/infobar.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 void InfoBarManager::Observer::OnInfoBarReplaced(InfoBar* old_infobar, | 28 void InfoBarManager::Observer::OnInfoBarReplaced(InfoBar* old_infobar, |
| 29 InfoBar* new_infobar) { | 29 InfoBar* new_infobar) { |
| 30 } | 30 } |
| 31 | 31 |
| 32 void InfoBarManager::Observer::OnManagerShuttingDown(InfoBarManager* manager) { | 32 void InfoBarManager::Observer::OnManagerShuttingDown(InfoBarManager* manager) { |
| 33 } | 33 } |
| 34 | 34 |
| 35 | 35 |
| 36 // InfoBarManager -------------------------------------------------------------- | 36 // InfoBarManager -------------------------------------------------------------- |
| 37 | 37 |
| 38 InfoBar* InfoBarManager::AddInfoBar(scoped_ptr<InfoBar> infobar) { | 38 InfoBar* InfoBarManager::AddInfoBar(std::unique_ptr<InfoBar> infobar) { |
| 39 DCHECK(infobar); | 39 DCHECK(infobar); |
| 40 if (!infobars_enabled_) | 40 if (!infobars_enabled_) |
| 41 return NULL; | 41 return NULL; |
| 42 | 42 |
| 43 for (InfoBars::const_iterator i(infobars_.begin()); i != infobars_.end(); | 43 for (InfoBars::const_iterator i(infobars_.begin()); i != infobars_.end(); |
| 44 ++i) { | 44 ++i) { |
| 45 if ((*i)->delegate()->EqualsDelegate(infobar->delegate())) { | 45 if ((*i)->delegate()->EqualsDelegate(infobar->delegate())) { |
| 46 DCHECK_NE((*i)->delegate(), infobar->delegate()); | 46 DCHECK_NE((*i)->delegate(), infobar->delegate()); |
| 47 return NULL; | 47 return NULL; |
| 48 } | 48 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 60 void InfoBarManager::RemoveInfoBar(InfoBar* infobar) { | 60 void InfoBarManager::RemoveInfoBar(InfoBar* infobar) { |
| 61 RemoveInfoBarInternal(infobar, true); | 61 RemoveInfoBarInternal(infobar, true); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void InfoBarManager::RemoveAllInfoBars(bool animate) { | 64 void InfoBarManager::RemoveAllInfoBars(bool animate) { |
| 65 while (!infobars_.empty()) | 65 while (!infobars_.empty()) |
| 66 RemoveInfoBarInternal(infobars_.back(), animate); | 66 RemoveInfoBarInternal(infobars_.back(), animate); |
| 67 } | 67 } |
| 68 | 68 |
| 69 InfoBar* InfoBarManager::ReplaceInfoBar(InfoBar* old_infobar, | 69 InfoBar* InfoBarManager::ReplaceInfoBar(InfoBar* old_infobar, |
| 70 scoped_ptr<InfoBar> new_infobar) { | 70 std::unique_ptr<InfoBar> new_infobar) { |
| 71 DCHECK(old_infobar); | 71 DCHECK(old_infobar); |
| 72 if (!infobars_enabled_) | 72 if (!infobars_enabled_) |
| 73 return AddInfoBar(std::move(new_infobar)); // Deletes the infobar. | 73 return AddInfoBar(std::move(new_infobar)); // Deletes the infobar. |
| 74 DCHECK(new_infobar); | 74 DCHECK(new_infobar); |
| 75 | 75 |
| 76 InfoBars::iterator i(std::find(infobars_.begin(), infobars_.end(), | 76 InfoBars::iterator i(std::find(infobars_.begin(), infobars_.end(), |
| 77 old_infobar)); | 77 old_infobar)); |
| 78 DCHECK(i != infobars_.end()); | 78 DCHECK(i != infobars_.end()); |
| 79 | 79 |
| 80 InfoBar* new_infobar_ptr = new_infobar.release(); | 80 InfoBar* new_infobar_ptr = new_infobar.release(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 infobars_.erase(i); | 153 infobars_.erase(i); |
| 154 | 154 |
| 155 // This notification must happen before the call to CloseSoon() below, since | 155 // This notification must happen before the call to CloseSoon() below, since |
| 156 // observers may want to access |infobar| and that call can delete it. | 156 // observers may want to access |infobar| and that call can delete it. |
| 157 NotifyInfoBarRemoved(infobar, animate); | 157 NotifyInfoBarRemoved(infobar, animate); |
| 158 | 158 |
| 159 infobar->CloseSoon(); | 159 infobar->CloseSoon(); |
| 160 } | 160 } |
| 161 | 161 |
| 162 } // namespace infobars | 162 } // namespace infobars |
| OLD | NEW |