| 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_delegate2.h" | 10 #include "chrome/browser/translate/translate_infobar_delegate2.h" | 
| 11 #include "chrome/browser/views/infobars/after_translate_infobar.h" | 11 #include "chrome/browser/views/infobars/after_translate_infobar.h" | 
| 12 #include "chrome/browser/views/infobars/before_translate_infobar.h" | 12 #include "chrome/browser/views/infobars/before_translate_infobar.h" | 
| 13 #include "chrome/browser/views/infobars/translate_message_infobar.h" | 13 #include "chrome/browser/views/infobars/translate_message_infobar.h" | 
| 14 #include "chrome/browser/views/infobars/infobar_button_border.h" | 14 #include "chrome/browser/views/infobars/infobar_button_border.h" | 
| 15 #include "gfx/canvas.h" | 15 #include "gfx/canvas_skia.h" | 
| 16 #include "grit/app_resources.h" | 16 #include "grit/app_resources.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     TranslateInfoBarDelegate2* delegate) | 21     TranslateInfoBarDelegate2* 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::ERROR_TYPE) { | 24       error_background_(InfoBarDelegate::ERROR_TYPE) { | 
| 25   icon_ = new views::ImageView; | 25   icon_ = new views::ImageView; | 
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 141 | 141 | 
| 142 const InfoBarBackground& TranslateInfoBarBase::GetBackground() const { | 142 const InfoBarBackground& TranslateInfoBarBase::GetBackground() const { | 
| 143   return GetDelegate()->IsError() ? error_background_ : normal_background_; | 143   return GetDelegate()->IsError() ? error_background_ : normal_background_; | 
| 144 } | 144 } | 
| 145 | 145 | 
| 146 void TranslateInfoBarBase::FadeBackground(gfx::Canvas* canvas, | 146 void TranslateInfoBarBase::FadeBackground(gfx::Canvas* canvas, | 
| 147                                           double animation_value, | 147                                           double animation_value, | 
| 148                                           const InfoBarBackground& background) { | 148                                           const InfoBarBackground& background) { | 
| 149   // Draw the background into an offscreen buffer with alpha value per animation | 149   // Draw the background into an offscreen buffer with alpha value per animation | 
| 150   // value, then blend it back into the current canvas. | 150   // value, then blend it back into the current canvas. | 
| 151   canvas->saveLayerAlpha(NULL, static_cast<int>(animation_value * 255), | 151   canvas->AsCanvasSkia()->saveLayerAlpha( | 
| 152                          SkCanvas::kARGB_NoClipLayer_SaveFlag); | 152       NULL, static_cast<int>(animation_value * 255), | 
| 153   canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); | 153       SkCanvas::kARGB_NoClipLayer_SaveFlag); | 
|  | 154   canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); | 
| 154   background.Paint(canvas, this); | 155   background.Paint(canvas, this); | 
| 155   canvas->restore(); | 156   canvas->AsCanvasSkia()->restore(); | 
| 156 } | 157 } | 
| 157 | 158 | 
| 158 // TranslateInfoBarDelegate views specific method: | 159 // TranslateInfoBarDelegate views specific method: | 
| 159 InfoBar* TranslateInfoBarDelegate2::CreateInfoBar() { | 160 InfoBar* TranslateInfoBarDelegate2::CreateInfoBar() { | 
| 160   TranslateInfoBarBase* infobar = NULL; | 161   TranslateInfoBarBase* infobar = NULL; | 
| 161   switch (type_) { | 162   switch (type_) { | 
| 162     case BEFORE_TRANSLATE: | 163     case BEFORE_TRANSLATE: | 
| 163       infobar = new BeforeTranslateInfoBar(this); | 164       infobar = new BeforeTranslateInfoBar(this); | 
| 164       break; | 165       break; | 
| 165     case AFTER_TRANSLATE: | 166     case AFTER_TRANSLATE: | 
| 166       infobar = new AfterTranslateInfoBar(this); | 167       infobar = new AfterTranslateInfoBar(this); | 
| 167       break; | 168       break; | 
| 168     case TRANSLATING: | 169     case TRANSLATING: | 
| 169     case TRANSLATION_ERROR: | 170     case TRANSLATION_ERROR: | 
| 170       infobar = new TranslateMessageInfoBar(this); | 171       infobar = new TranslateMessageInfoBar(this); | 
| 171       break; | 172       break; | 
| 172     default: | 173     default: | 
| 173       NOTREACHED(); | 174       NOTREACHED(); | 
| 174   } | 175   } | 
| 175   // Set |infobar_view_| so that the model can notify the infobar when it | 176   // Set |infobar_view_| so that the model can notify the infobar when it | 
| 176   // changes. | 177   // changes. | 
| 177   infobar_view_ = infobar; | 178   infobar_view_ = infobar; | 
| 178   return infobar; | 179   return infobar; | 
| 179 } | 180 } | 
| OLD | NEW | 
|---|