Chromium Code Reviews| 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.h" | 5 #include "components/infobars/core/infobar.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 } | 46 } |
| 47 | 47 |
| 48 void InfoBar::SetOwner(InfoBarManager* owner) { | 48 void InfoBar::SetOwner(InfoBarManager* owner) { |
| 49 DCHECK(!owner_); | 49 DCHECK(!owner_); |
| 50 owner_ = owner; | 50 owner_ = owner; |
| 51 delegate_->set_nav_entry_id(owner->GetActiveEntryID()); | 51 delegate_->set_nav_entry_id(owner->GetActiveEntryID()); |
| 52 PlatformSpecificSetOwner(); | 52 PlatformSpecificSetOwner(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void InfoBar::Show(bool animate) { | 55 void InfoBar::Show(bool animate) { |
| 56 DCHECK(owner_); | |
| 57 if (!owner_->animations_enabled()) | |
| 58 animate = false; | |
|
Peter Kasting
2017/02/23 00:33:55
Nit: Shorter:
animate &= owner_->animations_ena
samuong
2017/02/23 00:45:26
Done.
| |
| 56 PlatformSpecificShow(animate); | 59 PlatformSpecificShow(animate); |
| 57 if (animate) { | 60 if (animate) { |
| 58 animation_.Show(); | 61 animation_.Show(); |
| 59 } else { | 62 } else { |
| 60 animation_.Reset(1.0); | 63 animation_.Reset(1.0); |
| 61 RecalculateHeights(true); | 64 RecalculateHeights(true); |
| 62 } | 65 } |
| 63 } | 66 } |
| 64 | 67 |
| 65 void InfoBar::Hide(bool animate) { | 68 void InfoBar::Hide(bool animate) { |
| 69 DCHECK(owner_); | |
| 70 if (!owner_->animations_enabled()) | |
| 71 animate = false; | |
| 66 PlatformSpecificHide(animate); | 72 PlatformSpecificHide(animate); |
| 67 if (animate) { | 73 if (animate) { |
| 68 animation_.Hide(); | 74 animation_.Hide(); |
| 69 } else { | 75 } else { |
| 70 animation_.Reset(0.0); | 76 animation_.Reset(0.0); |
| 71 // We want to remove ourselves from the container immediately even if we | 77 // We want to remove ourselves from the container immediately even if we |
| 72 // still have an owner, which MaybeDelete() won't do. | 78 // still have an owner, which MaybeDelete() won't do. |
| 73 DCHECK(container_); | 79 DCHECK(container_); |
| 74 container_->RemoveInfoBar(this); | 80 container_->RemoveInfoBar(this); |
| 75 MaybeDelete(); // Necessary if the infobar was already closing. | 81 MaybeDelete(); // Necessary if the infobar was already closing. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 | 151 |
| 146 void InfoBar::MaybeDelete() { | 152 void InfoBar::MaybeDelete() { |
| 147 if (!owner_ && (animation_.GetCurrentValue() == 0.0)) { | 153 if (!owner_ && (animation_.GetCurrentValue() == 0.0)) { |
| 148 if (container_) | 154 if (container_) |
| 149 container_->RemoveInfoBar(this); | 155 container_->RemoveInfoBar(this); |
| 150 delete this; | 156 delete this; |
| 151 } | 157 } |
| 152 } | 158 } |
| 153 | 159 |
| 154 } // namespace infobars | 160 } // namespace infobars |
| OLD | NEW |