| 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(); | |
| 58 PlatformSpecificSetOwner(); | 57 PlatformSpecificSetOwner(); |
| 59 } | 58 } |
| 60 | 59 |
| 60 void InfoBar::StoreActiveEntryUniqueID(int entry_id) { |
| 61 delegate_->StoreActiveEntryUniqueID(entry_id); |
| 62 } |
| 63 |
| 61 void InfoBar::Show(bool animate) { | 64 void InfoBar::Show(bool animate) { |
| 62 PlatformSpecificShow(animate); | 65 PlatformSpecificShow(animate); |
| 63 if (animate) { | 66 if (animate) { |
| 64 animation_.Show(); | 67 animation_.Show(); |
| 65 } else { | 68 } else { |
| 66 animation_.Reset(1.0); | 69 animation_.Reset(1.0); |
| 67 RecalculateHeights(true); | 70 RecalculateHeights(true); |
| 68 } | 71 } |
| 69 } | 72 } |
| 70 | 73 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 container_->OnInfoBarStateChanged(animation_.is_animating()); | 169 container_->OnInfoBarStateChanged(animation_.is_animating()); |
| 167 } | 170 } |
| 168 | 171 |
| 169 void InfoBar::MaybeDelete() { | 172 void InfoBar::MaybeDelete() { |
| 170 if (!owner_ && (animation_.GetCurrentValue() == 0.0)) { | 173 if (!owner_ && (animation_.GetCurrentValue() == 0.0)) { |
| 171 if (container_) | 174 if (container_) |
| 172 container_->RemoveInfoBar(this); | 175 container_->RemoveInfoBar(this); |
| 173 delete this; | 176 delete this; |
| 174 } | 177 } |
| 175 } | 178 } |
| OLD | NEW |