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 "base/logging.h" | 9 #include "base/logging.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "chrome/browser/infobars/infobar_container.h" | 11 #include "chrome/browser/infobars/infobar_container.h" |
12 #include "chrome/browser/infobars/infobar_service.h" | 12 #include "chrome/browser/infobars/infobar_manager.h" |
13 #include "ui/gfx/animation/slide_animation.h" | 13 #include "ui/gfx/animation/slide_animation.h" |
14 | 14 |
15 InfoBar::InfoBar(scoped_ptr<InfoBarDelegate> delegate) | 15 InfoBar::InfoBar(scoped_ptr<InfoBarDelegate> delegate) |
16 : owner_(NULL), | 16 : owner_(NULL), |
17 delegate_(delegate.Pass()), | 17 delegate_(delegate.Pass()), |
18 container_(NULL), | 18 container_(NULL), |
19 animation_(this), | 19 animation_(this), |
20 arrow_height_(0), | 20 arrow_height_(0), |
21 arrow_target_height_(kDefaultArrowTargetHeight), | 21 arrow_target_height_(kDefaultArrowTargetHeight), |
22 arrow_half_width_(0), | 22 arrow_half_width_(0), |
(...skipping 21 matching lines...) Expand all Loading... |
44 // static | 44 // static |
45 SkColor InfoBar::GetBottomColor(InfoBarDelegate::Type infobar_type) { | 45 SkColor InfoBar::GetBottomColor(InfoBarDelegate::Type infobar_type) { |
46 static const SkColor kWarningBackgroundColorBottom = | 46 static const SkColor kWarningBackgroundColorBottom = |
47 SkColorSetRGB(250, 230, 145); // Yellow | 47 SkColorSetRGB(250, 230, 145); // Yellow |
48 static const SkColor kPageActionBackgroundColorBottom = | 48 static const SkColor kPageActionBackgroundColorBottom = |
49 SkColorSetRGB(217, 217, 217); // Gray | 49 SkColorSetRGB(217, 217, 217); // Gray |
50 return (infobar_type == InfoBarDelegate::WARNING_TYPE) ? | 50 return (infobar_type == InfoBarDelegate::WARNING_TYPE) ? |
51 kWarningBackgroundColorBottom : kPageActionBackgroundColorBottom; | 51 kWarningBackgroundColorBottom : kPageActionBackgroundColorBottom; |
52 } | 52 } |
53 | 53 |
54 void InfoBar::SetOwner(InfoBarService* owner) { | 54 void InfoBar::SetOwner(InfoBarManager* owner) { |
55 DCHECK(!owner_); | 55 DCHECK(!owner_); |
56 owner_ = owner; | 56 owner_ = owner; |
57 delegate_->StoreActiveEntryUniqueID(); | 57 delegate_->StoreActiveEntryUniqueID(); |
58 PlatformSpecificSetOwner(); | 58 PlatformSpecificSetOwner(); |
59 } | 59 } |
60 | 60 |
61 void InfoBar::Show(bool animate) { | 61 void InfoBar::Show(bool animate) { |
62 PlatformSpecificShow(animate); | 62 PlatformSpecificShow(animate); |
63 if (animate) { | 63 if (animate) { |
64 animation_.Show(); | 64 animation_.Show(); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 container_->OnInfoBarStateChanged(animation_.is_animating()); | 166 container_->OnInfoBarStateChanged(animation_.is_animating()); |
167 } | 167 } |
168 | 168 |
169 void InfoBar::MaybeDelete() { | 169 void InfoBar::MaybeDelete() { |
170 if (!owner_ && (animation_.GetCurrentValue() == 0.0)) { | 170 if (!owner_ && (animation_.GetCurrentValue() == 0.0)) { |
171 if (container_) | 171 if (container_) |
172 container_->RemoveInfoBar(this); | 172 container_->RemoveInfoBar(this); |
173 delete this; | 173 delete this; |
174 } | 174 } |
175 } | 175 } |
OLD | NEW |