OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/views/infobars/infobar.h" | 5 #include "chrome/browser/ui/views/infobars/infobar.h" |
6 | 6 |
7 #include "ui/base/animation/slide_animation.h" | 7 #include "ui/base/animation/slide_animation.h" |
8 #include "chrome/browser/tab_contents/infobar_delegate.h" | 8 #include "chrome/browser/tab_contents/infobar_delegate.h" |
9 #include "chrome/browser/ui/views/infobars/infobar_container.h" | 9 #include "chrome/browser/ui/views/infobars/infobar_container.h" |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 PlatformSpecificHide(animate); | 32 PlatformSpecificHide(animate); |
33 if (animate) { | 33 if (animate) { |
34 animation_->Hide(); | 34 animation_->Hide(); |
35 } else { | 35 } else { |
36 animation_->Reset(0.0); | 36 animation_->Reset(0.0); |
37 AnimationEnded(NULL); | 37 AnimationEnded(NULL); |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 void InfoBar::AnimationProgressed(const ui::Animation* animation) { | 41 void InfoBar::AnimationProgressed(const ui::Animation* animation) { |
42 if (container_) | 42 RecalculateHeight(); |
43 container_->OnInfoBarAnimated(false); | |
44 } | 43 } |
45 | 44 |
46 void InfoBar::RemoveInfoBar() { | 45 void InfoBar::RemoveInfoBar() { |
47 if (container_) | 46 if (container_) |
48 container_->RemoveDelegate(delegate_); | 47 container_->RemoveDelegate(delegate_); |
49 } | 48 } |
50 | 49 |
51 void InfoBar::PlatformSpecificHide(bool animate) { | 50 void InfoBar::RecalculateHeight() { |
| 51 PlatformSpecificRecalculateHeight(); |
| 52 if (container_) |
| 53 container_->OnInfoBarHeightChanged(animation_->is_animating()); |
52 } | 54 } |
53 | 55 |
54 void InfoBar::AnimationEnded(const ui::Animation* animation) { | 56 void InfoBar::AnimationEnded(const ui::Animation* animation) { |
55 if (container_) | 57 RecalculateHeight(); |
56 container_->OnInfoBarAnimated(true); | |
57 MaybeDelete(); | 58 MaybeDelete(); |
58 } | 59 } |
59 | 60 |
60 void InfoBar::MaybeDelete() { | 61 void InfoBar::MaybeDelete() { |
61 if (delegate_ && (animation_->GetCurrentValue() == 0.0)) { | 62 if (delegate_ && (animation_->GetCurrentValue() == 0.0)) { |
62 if (container_) | 63 if (container_) |
63 container_->RemoveInfoBar(this); | 64 container_->RemoveInfoBar(this); |
64 // Note that we only tell the delegate we're closed here, and not when we're | 65 // Note that we only tell the delegate we're closed here, and not when we're |
65 // simply destroyed (by virtue of a tab switch or being moved from window to | 66 // simply destroyed (by virtue of a tab switch or being moved from window to |
66 // window), since this action can cause the delegate to destroy itself. | 67 // window), since this action can cause the delegate to destroy itself. |
67 delegate_->InfoBarClosed(); | 68 delegate_->InfoBarClosed(); |
68 delegate_ = NULL; | 69 delegate_ = NULL; |
69 } | 70 } |
70 } | 71 } |
OLD | NEW |