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/infobars/infobar.h" | 5 #include "chrome/browser/infobars/infobar.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 arrow_height_(0), | 47 arrow_height_(0), |
48 arrow_target_height_(kDefaultArrowTargetHeight), | 48 arrow_target_height_(kDefaultArrowTargetHeight), |
49 arrow_half_width_(0), | 49 arrow_half_width_(0), |
50 bar_height_(0), | 50 bar_height_(0), |
51 bar_target_height_(kDefaultBarTargetHeight) { | 51 bar_target_height_(kDefaultBarTargetHeight) { |
52 DCHECK(owner_ != NULL); | 52 DCHECK(owner_ != NULL); |
53 DCHECK(delegate_ != NULL); | 53 DCHECK(delegate_ != NULL); |
54 animation_.SetTweenType(ui::Tween::LINEAR); | 54 animation_.SetTweenType(ui::Tween::LINEAR); |
55 } | 55 } |
56 | 56 |
57 InfoBar::~InfoBar() { | 57 InfoBar::~InfoBar() { |
jochen (gone - plz use gerrit)
2011/11/28 08:36:24
I wonder whether we should delete the delegate her
marja
2011/11/28 09:40:30
Done. (I made delegate_ a scoped_ptr.)
marja
2011/11/28 15:50:36
Ouch, this was the wrong thing to do. InfoBarConta
| |
58 } | 58 } |
59 | 59 |
60 void InfoBar::Show(bool animate) { | 60 void InfoBar::Show(bool animate) { |
61 PlatformSpecificShow(animate); | 61 PlatformSpecificShow(animate); |
62 if (animate) { | 62 if (animate) { |
63 animation_.Show(); | 63 animation_.Show(); |
64 } else { | 64 } else { |
65 animation_.Reset(1.0); | 65 animation_.Reset(1.0); |
66 RecalculateHeights(true); | 66 RecalculateHeights(true); |
67 } | 67 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 PlatformSpecificOnHeightsRecalculated(); | 176 PlatformSpecificOnHeightsRecalculated(); |
177 | 177 |
178 if (container_ && (heights_differ || force_notify)) | 178 if (container_ && (heights_differ || force_notify)) |
179 container_->OnInfoBarStateChanged(animation_.is_animating()); | 179 container_->OnInfoBarStateChanged(animation_.is_animating()); |
180 } | 180 } |
181 | 181 |
182 void InfoBar::MaybeDelete() { | 182 void InfoBar::MaybeDelete() { |
183 if (!owner_ && delegate_ && (animation_.GetCurrentValue() == 0.0)) { | 183 if (!owner_ && delegate_ && (animation_.GetCurrentValue() == 0.0)) { |
184 if (container_) | 184 if (container_) |
185 container_->RemoveInfoBar(this); | 185 container_->RemoveInfoBar(this); |
186 delegate_->InfoBarClosed(); | 186 delete delegate_; |
187 delegate_ = NULL; | 187 delegate_ = NULL; |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
191 #endif // TOOLKIT_VIEWS || TOOLKIT_GTK | 191 #endif // TOOLKIT_VIEWS || TOOLKIT_GTK |
OLD | NEW |