| 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/gtk/translate/translate_infobar_base_gtk.h" | 5 #include "chrome/browser/gtk/translate/translate_infobar_base_gtk.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "app/slide_animation.h" | 9 #include "app/slide_animation.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 LANGUAGE_COMBO_COLUMN_NAME, | 29 LANGUAGE_COMBO_COLUMN_NAME, |
| 30 LANGUAGE_COMBO_COLUMN_COUNT | 30 LANGUAGE_COMBO_COLUMN_COUNT |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 } // namespace | 33 } // namespace |
| 34 | 34 |
| 35 TranslateInfoBarBase::TranslateInfoBarBase(TranslateInfoBarDelegate* delegate) | 35 TranslateInfoBarBase::TranslateInfoBarBase(TranslateInfoBarDelegate* delegate) |
| 36 : InfoBar(delegate) { | 36 : InfoBar(delegate) { |
| 37 TranslateInfoBarDelegate::BackgroundAnimationType animation = | 37 TranslateInfoBarDelegate::BackgroundAnimationType animation = |
| 38 delegate->background_animation_type(); | 38 delegate->background_animation_type(); |
| 39 if (animation != TranslateInfoBarDelegate::kNone) { | 39 if (animation != TranslateInfoBarDelegate::NONE) { |
| 40 background_color_animation_.reset(new SlideAnimation(this)); | 40 background_color_animation_.reset(new SlideAnimation(this)); |
| 41 background_color_animation_->SetTweenType(Tween::LINEAR); | 41 background_color_animation_->SetTweenType(Tween::LINEAR); |
| 42 background_color_animation_->SetSlideDuration(500); | 42 background_color_animation_->SetSlideDuration(500); |
| 43 if (animation == TranslateInfoBarDelegate::kNormalToError) { | 43 if (animation == TranslateInfoBarDelegate::NORMAL_TO_ERROR) { |
| 44 background_color_animation_->Show(); | 44 background_color_animation_->Show(); |
| 45 } else { | 45 } else { |
| 46 DCHECK_EQ(TranslateInfoBarDelegate::kErrorToNormal, animation); | 46 DCHECK_EQ(TranslateInfoBarDelegate::ERROR_TO_NORMAL, animation); |
| 47 // Hide() runs the animation in reverse. | 47 // Hide() runs the animation in reverse. |
| 48 background_color_animation_->Reset(1.0); | 48 background_color_animation_->Reset(1.0); |
| 49 background_color_animation_->Hide(); | 49 background_color_animation_->Hide(); |
| 50 } | 50 } |
| 51 } else { | 51 } else { |
| 52 background_error_percent_ = delegate->IsError() ? 1 : 0; | 52 background_error_percent_ = delegate->IsError() ? 1 : 0; |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 | 55 |
| 56 TranslateInfoBarBase::~TranslateInfoBarBase() { | 56 TranslateInfoBarBase::~TranslateInfoBarBase() { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 options_menu_model_.reset(new OptionsMenuModel(GetDelegate())); | 211 options_menu_model_.reset(new OptionsMenuModel(GetDelegate())); |
| 212 options_menu_menu_.reset(new MenuGtk(NULL, options_menu_model_.get())); | 212 options_menu_menu_.reset(new MenuGtk(NULL, options_menu_model_.get())); |
| 213 } | 213 } |
| 214 options_menu_menu_->Popup(sender, 1, gtk_get_current_event_time()); | 214 options_menu_menu_->Popup(sender, 1, gtk_get_current_event_time()); |
| 215 } | 215 } |
| 216 | 216 |
| 217 // TranslateInfoBarDelegate specific method: | 217 // TranslateInfoBarDelegate specific method: |
| 218 InfoBar* TranslateInfoBarDelegate::CreateInfoBar() { | 218 InfoBar* TranslateInfoBarDelegate::CreateInfoBar() { |
| 219 TranslateInfoBarBase* infobar = NULL; | 219 TranslateInfoBarBase* infobar = NULL; |
| 220 switch (type_) { | 220 switch (type_) { |
| 221 case kBeforeTranslate: | 221 case BEFORE_TRANSLATE: |
| 222 infobar = new BeforeTranslateInfoBar(this); | 222 infobar = new BeforeTranslateInfoBar(this); |
| 223 break; | 223 break; |
| 224 case kAfterTranslate: | 224 case AFTER_TRANSLATE: |
| 225 infobar = new AfterTranslateInfoBar(this); | 225 infobar = new AfterTranslateInfoBar(this); |
| 226 break; | 226 break; |
| 227 case kTranslating: | 227 case TRANSLATING: |
| 228 case kTranslationError: | 228 case TRANSLATION_ERROR: |
| 229 infobar = new TranslateMessageInfoBar(this); | 229 infobar = new TranslateMessageInfoBar(this); |
| 230 break; | 230 break; |
| 231 default: | 231 default: |
| 232 NOTREACHED(); | 232 NOTREACHED(); |
| 233 } | 233 } |
| 234 infobar->Init(); | 234 infobar->Init(); |
| 235 // Set |infobar_view_| so that the model can notify the infobar when it | 235 // Set |infobar_view_| so that the model can notify the infobar when it |
| 236 // changes. | 236 // changes. |
| 237 infobar_view_ = infobar; | 237 infobar_view_ = infobar; |
| 238 return infobar; | 238 return infobar; |
| 239 } | 239 } |
| OLD | NEW |