OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/sad_tab_view.h" | 5 #include "chrome/browser/ui/views/sad_tab_view.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/google/google_util.h" | 8 #include "chrome/browser/google/google_util.h" |
9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
10 #include "content/browser/tab_contents/tab_contents.h" | 10 #include "content/browser/tab_contents/tab_contents.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 void SadTabView::OnPaint(gfx::Canvas* canvas) { | 75 void SadTabView::OnPaint(gfx::Canvas* canvas) { |
76 SkPaint paint; | 76 SkPaint paint; |
77 SkSafeUnref(paint.setShader( | 77 SkSafeUnref(paint.setShader( |
78 gfx::CreateGradientShader( | 78 gfx::CreateGradientShader( |
79 0, | 79 0, |
80 height(), | 80 height(), |
81 kind_ == CRASHED ? kCrashBackgroundColor : kKillBackgroundColor, | 81 kind_ == CRASHED ? kCrashBackgroundColor : kKillBackgroundColor, |
82 kind_ == CRASHED ? | 82 kind_ == CRASHED ? |
83 kCrashBackgroundEndColor : kKillBackgroundEndColor))); | 83 kCrashBackgroundEndColor : kKillBackgroundEndColor))); |
84 paint.setStyle(SkPaint::kFill_Style); | 84 paint.setStyle(SkPaint::kFill_Style); |
85 canvas->AsCanvasSkia()->drawRectCoords( | 85 canvas->AsCanvasSkia()->skia_canvas()->drawRectCoords( |
86 0, 0, SkIntToScalar(width()), SkIntToScalar(height()), paint); | 86 0, 0, SkIntToScalar(width()), SkIntToScalar(height()), paint); |
87 | 87 |
88 canvas->DrawBitmapInt(*sad_tab_bitmap_, icon_bounds_.x(), icon_bounds_.y()); | 88 canvas->DrawBitmapInt(*sad_tab_bitmap_, icon_bounds_.x(), icon_bounds_.y()); |
89 | 89 |
90 canvas->DrawStringInt(WideToUTF16Hack(title_), *title_font_, kTitleColor, | 90 canvas->DrawStringInt(WideToUTF16Hack(title_), *title_font_, kTitleColor, |
91 title_bounds_.x(), title_bounds_.y(), | 91 title_bounds_.x(), title_bounds_.y(), |
92 title_bounds_.width(), title_bounds_.height(), | 92 title_bounds_.width(), title_bounds_.height(), |
93 gfx::Canvas::TEXT_ALIGN_CENTER); | 93 gfx::Canvas::TEXT_ALIGN_CENTER); |
94 | 94 |
95 canvas->DrawStringInt(WideToUTF16Hack(message_), *message_font_, | 95 canvas->DrawStringInt(WideToUTF16Hack(message_), *message_font_, |
(...skipping 11 matching lines...) Expand all Loading... |
107 int icon_height = sad_tab_bitmap_->height(); | 107 int icon_height = sad_tab_bitmap_->height(); |
108 int icon_x = (width() - icon_width) / 2; | 108 int icon_x = (width() - icon_width) / 2; |
109 int icon_y = ((height() - icon_height) / 2) + kSadTabOffset; | 109 int icon_y = ((height() - icon_height) / 2) + kSadTabOffset; |
110 icon_bounds_.SetRect(icon_x, icon_y, icon_width, icon_height); | 110 icon_bounds_.SetRect(icon_x, icon_y, icon_width, icon_height); |
111 | 111 |
112 int title_x = (width() - title_width_) / 2; | 112 int title_x = (width() - title_width_) / 2; |
113 int title_y = icon_bounds_.bottom() + kIconTitleSpacing; | 113 int title_y = icon_bounds_.bottom() + kIconTitleSpacing; |
114 int title_height = title_font_->GetHeight(); | 114 int title_height = title_font_->GetHeight(); |
115 title_bounds_.SetRect(title_x, title_y, title_width_, title_height); | 115 title_bounds_.SetRect(title_x, title_y, title_width_, title_height); |
116 | 116 |
117 gfx::CanvasSkia cc(0, 0, true); | 117 gfx::CanvasSkia cc; |
| 118 cc.Init(0, 0, true); |
118 int message_width = static_cast<int>(width() * kMessageSize); | 119 int message_width = static_cast<int>(width() * kMessageSize); |
119 int message_height = 0; | 120 int message_height = 0; |
120 cc.SizeStringInt(WideToUTF16Hack(message_), *message_font_, &message_width, | 121 cc.SizeStringInt(WideToUTF16Hack(message_), *message_font_, &message_width, |
121 &message_height, gfx::Canvas::MULTI_LINE); | 122 &message_height, gfx::Canvas::MULTI_LINE); |
122 int message_x = (width() - message_width) / 2; | 123 int message_x = (width() - message_width) / 2; |
123 int message_y = title_bounds_.bottom() + kTitleMessageSpacing; | 124 int message_y = title_bounds_.bottom() + kTitleMessageSpacing; |
124 message_bounds_.SetRect(message_x, message_y, message_width, message_height); | 125 message_bounds_.SetRect(message_x, message_y, message_width, message_height); |
125 | 126 |
126 if (learn_more_link_ != NULL) { | 127 if (learn_more_link_ != NULL) { |
127 gfx::Size sz = learn_more_link_->GetPreferredSize(); | 128 gfx::Size sz = learn_more_link_->GetPreferredSize(); |
(...skipping 29 matching lines...) Expand all Loading... |
157 | 158 |
158 title_ = UTF16ToWide(l10n_util::GetStringUTF16( | 159 title_ = UTF16ToWide(l10n_util::GetStringUTF16( |
159 kind == CRASHED ? IDS_SAD_TAB_TITLE : IDS_KILLED_TAB_TITLE)); | 160 kind == CRASHED ? IDS_SAD_TAB_TITLE : IDS_KILLED_TAB_TITLE)); |
160 title_width_ = title_font_->GetStringWidth(WideToUTF16Hack(title_)); | 161 title_width_ = title_font_->GetStringWidth(WideToUTF16Hack(title_)); |
161 message_ = UTF16ToWide(l10n_util::GetStringUTF16( | 162 message_ = UTF16ToWide(l10n_util::GetStringUTF16( |
162 kind == CRASHED ? IDS_SAD_TAB_MESSAGE : IDS_KILLED_TAB_MESSAGE)); | 163 kind == CRASHED ? IDS_SAD_TAB_MESSAGE : IDS_KILLED_TAB_MESSAGE)); |
163 | 164 |
164 initialized = true; | 165 initialized = true; |
165 } | 166 } |
166 } | 167 } |
OLD | NEW |