OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/infobars/translate_infobar_base.h" | 5 #include "chrome/browser/views/infobars/translate_infobar_base.h" |
6 | 6 |
7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
8 #include "app/slide_animation.h" | |
9 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/translate/translate_infobar_delegate.h" | 9 #include "chrome/browser/translate/translate_infobar_delegate.h" |
11 #include "chrome/browser/views/infobars/after_translate_infobar.h" | 10 #include "chrome/browser/views/infobars/after_translate_infobar.h" |
12 #include "chrome/browser/views/infobars/before_translate_infobar.h" | 11 #include "chrome/browser/views/infobars/before_translate_infobar.h" |
13 #include "chrome/browser/views/infobars/translate_message_infobar.h" | 12 #include "chrome/browser/views/infobars/translate_message_infobar.h" |
14 #include "chrome/browser/views/infobars/infobar_button_border.h" | 13 #include "chrome/browser/views/infobars/infobar_button_border.h" |
15 #include "gfx/canvas_skia.h" | 14 #include "gfx/canvas_skia.h" |
16 #include "grit/theme_resources.h" | 15 #include "grit/theme_resources.h" |
| 16 #include "ui/base/animation/slide_animation.h" |
17 #include "views/controls/button/menu_button.h" | 17 #include "views/controls/button/menu_button.h" |
18 #include "views/controls/image_view.h" | 18 #include "views/controls/image_view.h" |
19 | 19 |
20 TranslateInfoBarBase::TranslateInfoBarBase( | 20 TranslateInfoBarBase::TranslateInfoBarBase( |
21 TranslateInfoBarDelegate* delegate) | 21 TranslateInfoBarDelegate* delegate) |
22 : InfoBar(delegate), | 22 : InfoBar(delegate), |
23 normal_background_(InfoBarDelegate::PAGE_ACTION_TYPE), | 23 normal_background_(InfoBarDelegate::PAGE_ACTION_TYPE), |
24 error_background_(InfoBarDelegate::WARNING_TYPE) { | 24 error_background_(InfoBarDelegate::WARNING_TYPE) { |
25 icon_ = new views::ImageView; | 25 icon_ = new views::ImageView; |
26 SkBitmap* image = delegate->GetIcon(); | 26 SkBitmap* image = delegate->GetIcon(); |
27 if (image) | 27 if (image) |
28 icon_->SetImage(image); | 28 icon_->SetImage(image); |
29 AddChildView(icon_); | 29 AddChildView(icon_); |
30 | 30 |
31 TranslateInfoBarDelegate::BackgroundAnimationType animation = | 31 TranslateInfoBarDelegate::BackgroundAnimationType animation = |
32 delegate->background_animation_type(); | 32 delegate->background_animation_type(); |
33 if (animation != TranslateInfoBarDelegate::NONE) { | 33 if (animation != TranslateInfoBarDelegate::NONE) { |
34 background_color_animation_.reset(new SlideAnimation(this)); | 34 background_color_animation_.reset(new ui::SlideAnimation(this)); |
35 background_color_animation_->SetTweenType(Tween::LINEAR); | 35 background_color_animation_->SetTweenType(ui::Tween::LINEAR); |
36 background_color_animation_->SetSlideDuration(500); | 36 background_color_animation_->SetSlideDuration(500); |
37 if (animation == TranslateInfoBarDelegate::NORMAL_TO_ERROR) { | 37 if (animation == TranslateInfoBarDelegate::NORMAL_TO_ERROR) { |
38 background_color_animation_->Show(); | 38 background_color_animation_->Show(); |
39 } else { | 39 } else { |
40 DCHECK_EQ(TranslateInfoBarDelegate::ERROR_TO_NORMAL, animation); | 40 DCHECK_EQ(TranslateInfoBarDelegate::ERROR_TO_NORMAL, animation); |
41 // Hide() runs the animation in reverse. | 41 // Hide() runs the animation in reverse. |
42 background_color_animation_->Reset(1.0); | 42 background_color_animation_->Reset(1.0); |
43 background_color_animation_->Hide(); | 43 background_color_animation_->Hide(); |
44 } | 44 } |
45 } | 45 } |
(...skipping 28 matching lines...) Expand all Loading... |
74 GetBackground().Paint(canvas, this); | 74 GetBackground().Paint(canvas, this); |
75 return; | 75 return; |
76 } | 76 } |
77 | 77 |
78 FadeBackground(canvas, 1.0 - background_color_animation_->GetCurrentValue(), | 78 FadeBackground(canvas, 1.0 - background_color_animation_->GetCurrentValue(), |
79 normal_background_); | 79 normal_background_); |
80 FadeBackground(canvas, background_color_animation_->GetCurrentValue(), | 80 FadeBackground(canvas, background_color_animation_->GetCurrentValue(), |
81 error_background_); | 81 error_background_); |
82 } | 82 } |
83 | 83 |
84 void TranslateInfoBarBase::AnimationProgressed(const Animation* animation) { | 84 void TranslateInfoBarBase::AnimationProgressed(const ui::Animation* animation) { |
85 if (background_color_animation_.get() == animation) | 85 if (background_color_animation_.get() == animation) |
86 SchedulePaint(); // That'll trigger a PaintBackgroud. | 86 SchedulePaint(); // That'll trigger a PaintBackgroud. |
87 else | 87 else |
88 InfoBar::AnimationProgressed(animation); | 88 InfoBar::AnimationProgressed(animation); |
89 } | 89 } |
90 | 90 |
91 views::MenuButton* TranslateInfoBarBase::CreateMenuButton( | 91 views::MenuButton* TranslateInfoBarBase::CreateMenuButton( |
92 const string16& text, | 92 const string16& text, |
93 bool normal_has_border, | 93 bool normal_has_border, |
94 views::ViewMenuDelegate* menu_delegate) { | 94 views::ViewMenuDelegate* menu_delegate) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 infobar = new TranslateMessageInfoBar(this); | 169 infobar = new TranslateMessageInfoBar(this); |
170 break; | 170 break; |
171 default: | 171 default: |
172 NOTREACHED(); | 172 NOTREACHED(); |
173 } | 173 } |
174 // Set |infobar_view_| so that the model can notify the infobar when it | 174 // Set |infobar_view_| so that the model can notify the infobar when it |
175 // changes. | 175 // changes. |
176 infobar_view_ = infobar; | 176 infobar_view_ = infobar; |
177 return infobar; | 177 return infobar; |
178 } | 178 } |
OLD | NEW |