OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/sad_tab_view.h" | 5 #include "chrome/browser/views/sad_tab_view.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 "base/utf_string_conversions.h" |
9 #include "chrome/browser/google/google_util.h" | 10 #include "chrome/browser/google/google_util.h" |
10 #include "chrome/browser/tab_contents/tab_contents.h" | 11 #include "chrome/browser/tab_contents/tab_contents.h" |
11 #include "chrome/browser/tab_contents/tab_contents_delegate.h" | 12 #include "chrome/browser/tab_contents/tab_contents_delegate.h" |
12 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
13 #include "gfx/canvas.h" | 14 #include "gfx/canvas.h" |
14 #include "gfx/canvas_skia.h" | 15 #include "gfx/canvas_skia.h" |
15 #include "gfx/size.h" | 16 #include "gfx/size.h" |
16 #include "gfx/skia_util.h" | 17 #include "gfx/skia_util.h" |
17 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
18 #include "grit/locale_settings.h" | 19 #include "grit/locale_settings.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 icon_bounds_.SetRect(icon_x, icon_y, icon_width, icon_height); | 89 icon_bounds_.SetRect(icon_x, icon_y, icon_width, icon_height); |
89 | 90 |
90 int title_x = (width() - title_width_) / 2; | 91 int title_x = (width() - title_width_) / 2; |
91 int title_y = icon_bounds_.bottom() + kIconTitleSpacing; | 92 int title_y = icon_bounds_.bottom() + kIconTitleSpacing; |
92 int title_height = title_font_->GetHeight(); | 93 int title_height = title_font_->GetHeight(); |
93 title_bounds_.SetRect(title_x, title_y, title_width_, title_height); | 94 title_bounds_.SetRect(title_x, title_y, title_width_, title_height); |
94 | 95 |
95 gfx::CanvasSkia cc(0, 0, true); | 96 gfx::CanvasSkia cc(0, 0, true); |
96 int message_width = static_cast<int>(width() * kMessageSize); | 97 int message_width = static_cast<int>(width() * kMessageSize); |
97 int message_height = 0; | 98 int message_height = 0; |
98 cc.SizeStringInt(message_, *message_font_, &message_width, &message_height, | 99 cc.SizeStringInt(WideToUTF16Hack(message_), *message_font_, &message_width, |
99 gfx::Canvas::MULTI_LINE); | 100 &message_height, gfx::Canvas::MULTI_LINE); |
100 int message_x = (width() - message_width) / 2; | 101 int message_x = (width() - message_width) / 2; |
101 int message_y = title_bounds_.bottom() + kTitleMessageSpacing; | 102 int message_y = title_bounds_.bottom() + kTitleMessageSpacing; |
102 message_bounds_.SetRect(message_x, message_y, message_width, message_height); | 103 message_bounds_.SetRect(message_x, message_y, message_width, message_height); |
103 | 104 |
104 if (learn_more_link_ != NULL) { | 105 if (learn_more_link_ != NULL) { |
105 gfx::Size sz = learn_more_link_->GetPreferredSize(); | 106 gfx::Size sz = learn_more_link_->GetPreferredSize(); |
106 gfx::Insets insets = learn_more_link_->GetInsets(); | 107 gfx::Insets insets = learn_more_link_->GetInsets(); |
107 link_bounds_.SetRect((width() - sz.width()) / 2, | 108 link_bounds_.SetRect((width() - sz.width()) / 2, |
108 message_bounds_.bottom() + kTitleMessageSpacing - | 109 message_bounds_.bottom() + kTitleMessageSpacing - |
109 insets.top(), sz.width(), sz.height()); | 110 insets.top(), sz.width(), sz.height()); |
(...skipping 28 matching lines...) Expand all Loading... |
138 rb.GetFont(ResourceBundle::BaseFont).DeriveFont(1)); | 139 rb.GetFont(ResourceBundle::BaseFont).DeriveFont(1)); |
139 sad_tab_bitmap_ = rb.GetBitmapNamed(IDR_SAD_TAB); | 140 sad_tab_bitmap_ = rb.GetBitmapNamed(IDR_SAD_TAB); |
140 | 141 |
141 title_ = l10n_util::GetString(IDS_SAD_TAB_TITLE); | 142 title_ = l10n_util::GetString(IDS_SAD_TAB_TITLE); |
142 title_width_ = title_font_->GetStringWidth(title_); | 143 title_width_ = title_font_->GetStringWidth(title_); |
143 message_ = l10n_util::GetString(IDS_SAD_TAB_MESSAGE); | 144 message_ = l10n_util::GetString(IDS_SAD_TAB_MESSAGE); |
144 | 145 |
145 initialized = true; | 146 initialized = true; |
146 } | 147 } |
147 } | 148 } |
OLD | NEW |