OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/views/infobars/translate_infobar_base.h" | 5 #include "chrome/browser/ui/views/infobars/translate_infobar_base.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/infobars/infobar.h" |
8 #include "chrome/browser/infobars/infobar_tab_helper.h" | 9 #include "chrome/browser/infobars/infobar_tab_helper.h" |
9 #include "chrome/browser/translate/translate_infobar_delegate.h" | 10 #include "chrome/browser/translate/translate_infobar_delegate.h" |
10 #include "chrome/browser/ui/views/infobars/after_translate_infobar.h" | 11 #include "chrome/browser/ui/views/infobars/after_translate_infobar.h" |
11 #include "chrome/browser/ui/views/infobars/before_translate_infobar.h" | 12 #include "chrome/browser/ui/views/infobars/before_translate_infobar.h" |
12 #include "chrome/browser/ui/views/infobars/translate_message_infobar.h" | 13 #include "chrome/browser/ui/views/infobars/translate_message_infobar.h" |
13 #include "grit/theme_resources.h" | 14 #include "grit/theme_resources.h" |
14 #include "ui/base/animation/slide_animation.h" | 15 #include "ui/base/animation/slide_animation.h" |
15 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
16 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" |
17 #include "ui/views/controls/button/menu_button.h" | 18 #include "ui/views/controls/button/menu_button.h" |
(...skipping 23 matching lines...) Expand all Loading... |
41 } | 42 } |
42 | 43 |
43 // TranslateInfoBarBase ------------------------------------------------------- | 44 // TranslateInfoBarBase ------------------------------------------------------- |
44 | 45 |
45 // static | 46 // static |
46 const int TranslateInfoBarBase::kButtonInLabelSpacing = 5; | 47 const int TranslateInfoBarBase::kButtonInLabelSpacing = 5; |
47 | 48 |
48 TranslateInfoBarBase::TranslateInfoBarBase(InfoBarTabHelper* owner, | 49 TranslateInfoBarBase::TranslateInfoBarBase(InfoBarTabHelper* owner, |
49 TranslateInfoBarDelegate* delegate) | 50 TranslateInfoBarDelegate* delegate) |
50 : InfoBarView(owner, delegate), | 51 : InfoBarView(owner, delegate), |
51 error_background_(InfoBarDelegate::WARNING_TYPE) { | 52 error_background_(GetInfoBarTopColor(InfoBarDelegate::WARNING_TYPE), |
| 53 GetInfoBarBottomColor(InfoBarDelegate::WARNING_TYPE)) { |
52 } | 54 } |
53 | 55 |
54 TranslateInfoBarBase::~TranslateInfoBarBase() { | 56 TranslateInfoBarBase::~TranslateInfoBarBase() { |
55 } | 57 } |
56 | 58 |
57 void TranslateInfoBarBase::ViewHierarchyChanged(bool is_add, | 59 void TranslateInfoBarBase::ViewHierarchyChanged(bool is_add, |
58 View* parent, | 60 View* parent, |
59 View* child) { | 61 View* child) { |
60 if (is_add && (child == this) && (background_color_animation_ == NULL)) { | 62 if (is_add && (child == this) && (background_color_animation_ == NULL)) { |
61 background_color_animation_.reset(new ui::SlideAnimation(this)); | 63 background_color_animation_.reset(new ui::SlideAnimation(this)); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 void TranslateInfoBarBase::FadeBackground(gfx::Canvas* canvas, | 130 void TranslateInfoBarBase::FadeBackground(gfx::Canvas* canvas, |
129 double animation_value, | 131 double animation_value, |
130 const views::Background& background) { | 132 const views::Background& background) { |
131 // Draw the background into an offscreen buffer with alpha value per animation | 133 // Draw the background into an offscreen buffer with alpha value per animation |
132 // value, then blend it back into the current canvas. | 134 // value, then blend it back into the current canvas. |
133 canvas->SaveLayerAlpha(static_cast<int>(animation_value * 255)); | 135 canvas->SaveLayerAlpha(static_cast<int>(animation_value * 255)); |
134 canvas->sk_canvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); | 136 canvas->sk_canvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); |
135 background.Paint(canvas, this); | 137 background.Paint(canvas, this); |
136 canvas->Restore(); | 138 canvas->Restore(); |
137 } | 139 } |
OLD | NEW |