Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(471)

Side by Side Diff: chrome/browser/views/infobars/translate_infobars.cc

Issue 2825018: Canvas refactoring part 3.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_infobars.h" 5 #include "chrome/browser/views/infobars/translate_infobars.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
11 #include "app/resource_bundle.h" 11 #include "app/resource_bundle.h"
12 #include "app/slide_animation.h" 12 #include "app/slide_animation.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "chrome/app/chrome_dll_resource.h" 14 #include "chrome/app/chrome_dll_resource.h"
15 #include "chrome/common/notification_service.h" 15 #include "chrome/common/notification_service.h"
16 #include "chrome/browser/tab_contents/tab_contents.h" 16 #include "chrome/browser/tab_contents/tab_contents.h"
17 #include "chrome/browser/translate/languages_menu_model.h" 17 #include "chrome/browser/translate/languages_menu_model.h"
18 #include "chrome/browser/translate/options_menu_model.h" 18 #include "chrome/browser/translate/options_menu_model.h"
19 #include "chrome/browser/translate/page_translated_details.h" 19 #include "chrome/browser/translate/page_translated_details.h"
20 #include "chrome/browser/views/infobars/infobar_button_border.h" 20 #include "chrome/browser/views/infobars/infobar_button_border.h"
21 #include "chrome/browser/views/infobars/infobar_text_button.h" 21 #include "chrome/browser/views/infobars/infobar_text_button.h"
22 #include "gfx/canvas.h" 22 #include "gfx/canvas_skia.h"
23 #include "grit/app_resources.h" 23 #include "grit/app_resources.h"
24 #include "grit/generated_resources.h" 24 #include "grit/generated_resources.h"
25 #include "grit/locale_settings.h" 25 #include "grit/locale_settings.h"
26 #include "grit/theme_resources.h" 26 #include "grit/theme_resources.h"
27 #include "views/controls/button/image_button.h" 27 #include "views/controls/button/image_button.h"
28 #include "views/controls/button/menu_button.h" 28 #include "views/controls/button/menu_button.h"
29 #include "views/controls/button/text_button.h" 29 #include "views/controls/button/text_button.h"
30 #include "views/controls/image_view.h" 30 #include "views/controls/image_view.h"
31 #include "views/controls/label.h" 31 #include "views/controls/label.h"
32 32
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 } 750 }
751 751
752 Layout(); 752 Layout();
753 SchedulePaint(); 753 SchedulePaint();
754 } 754 }
755 755
756 void TranslateInfoBar::FadeBackground(gfx::Canvas* canvas, 756 void TranslateInfoBar::FadeBackground(gfx::Canvas* canvas,
757 double animation_value, TranslateInfoBarDelegate::TranslateState state) { 757 double animation_value, TranslateInfoBarDelegate::TranslateState state) {
758 // Draw background into an offscreen buffer with alpha value per animation 758 // Draw background into an offscreen buffer with alpha value per animation
759 // value, then blend it back into the current canvas. 759 // value, then blend it back into the current canvas.
760 canvas->saveLayerAlpha(NULL, static_cast<int>(animation_value * 255), 760 canvas->AsCanvasSkia()->saveLayerAlpha(
761 NULL, static_cast<int>(animation_value * 255),
761 SkCanvas::kARGB_NoClipLayer_SaveFlag); 762 SkCanvas::kARGB_NoClipLayer_SaveFlag);
762 canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); 763 canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
763 GetBackground(state)->Paint(canvas, this); 764 GetBackground(state)->Paint(canvas, this);
764 canvas->restore(); 765 canvas->AsCanvasSkia()->restore();
765 } 766 }
766 767
767 inline TranslateInfoBarDelegate* TranslateInfoBar::GetDelegate() const { 768 inline TranslateInfoBarDelegate* TranslateInfoBar::GetDelegate() const {
768 return static_cast<TranslateInfoBarDelegate*>(delegate()); 769 return static_cast<TranslateInfoBarDelegate*>(delegate());
769 } 770 }
770 771
771 inline InfoBarBackground* TranslateInfoBar::GetBackground( 772 inline InfoBarBackground* TranslateInfoBar::GetBackground(
772 TranslateInfoBarDelegate::TranslateState state) const { 773 TranslateInfoBarDelegate::TranslateState state) const {
773 return (state == TranslateInfoBarDelegate::kTranslateError ? 774 return (state == TranslateInfoBarDelegate::kTranslateError ?
774 error_background_.get() : normal_background_.get()); 775 error_background_.get() : normal_background_.get());
775 } 776 }
776 777
777 inline int TranslateInfoBar::GetSpacingAfterFirstLanguageButton() const { 778 inline int TranslateInfoBar::GetSpacingAfterFirstLanguageButton() const {
778 return (state_ == TranslateInfoBarDelegate::kAfterTranslate ? 779 return (state_ == TranslateInfoBarDelegate::kAfterTranslate ?
779 kButtonInLabelSpacing : 10); 780 kButtonInLabelSpacing : 10);
780 } 781 }
781 782
782 // TranslateInfoBarDelegate, InfoBarDelegate overrides: ------------------ 783 // TranslateInfoBarDelegate, InfoBarDelegate overrides: ------------------
783 784
784 InfoBar* TranslateInfoBarDelegate::CreateInfoBar() { 785 InfoBar* TranslateInfoBarDelegate::CreateInfoBar() {
785 return new TranslateInfoBar(this); 786 return new TranslateInfoBar(this);
786 } 787 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698