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" | 8 #include "app/slide_animation.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/translate/translate_infobar_delegate.h" | 10 #include "chrome/browser/translate/translate_infobar_delegate.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 normal_background_(InfoBarDelegate::PAGE_ACTION_TYPE), | 23 normal_background_(InfoBarDelegate::PAGE_ACTION_TYPE), |
24 error_background_(InfoBarDelegate::ERROR_TYPE) { | 24 error_background_(InfoBarDelegate::ERROR_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::kNone) { | 33 if (animation != TranslateInfoBarDelegate::NONE) { |
34 background_color_animation_.reset(new SlideAnimation(this)); | 34 background_color_animation_.reset(new SlideAnimation(this)); |
35 background_color_animation_->SetTweenType(Tween::LINEAR); | 35 background_color_animation_->SetTweenType(Tween::LINEAR); |
36 background_color_animation_->SetSlideDuration(500); | 36 background_color_animation_->SetSlideDuration(500); |
37 if (animation == TranslateInfoBarDelegate::kNormalToError) { | 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::kErrorToNormal, 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 } |
46 } | 46 } |
47 | 47 |
48 TranslateInfoBarBase::~TranslateInfoBarBase() { | 48 TranslateInfoBarBase::~TranslateInfoBarBase() { |
49 } | 49 } |
50 | 50 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 canvas->SaveLayerAlpha(static_cast<int>(animation_value * 255)); | 151 canvas->SaveLayerAlpha(static_cast<int>(animation_value * 255)); |
152 canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); | 152 canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); |
153 background.Paint(canvas, this); | 153 background.Paint(canvas, this); |
154 canvas->Restore(); | 154 canvas->Restore(); |
155 } | 155 } |
156 | 156 |
157 // TranslateInfoBarDelegate views specific method: | 157 // TranslateInfoBarDelegate views specific method: |
158 InfoBar* TranslateInfoBarDelegate::CreateInfoBar() { | 158 InfoBar* TranslateInfoBarDelegate::CreateInfoBar() { |
159 TranslateInfoBarBase* infobar = NULL; | 159 TranslateInfoBarBase* infobar = NULL; |
160 switch (type_) { | 160 switch (type_) { |
161 case kBeforeTranslate: | 161 case BEFORE_TRANSLATE: |
162 infobar = new BeforeTranslateInfoBar(this); | 162 infobar = new BeforeTranslateInfoBar(this); |
163 break; | 163 break; |
164 case kAfterTranslate: | 164 case AFTER_TRANSLATE: |
165 infobar = new AfterTranslateInfoBar(this); | 165 infobar = new AfterTranslateInfoBar(this); |
166 break; | 166 break; |
167 case kTranslating: | 167 case TRANSLATING: |
168 case kTranslationError: | 168 case TRANSLATION_ERROR: |
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 |