| 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/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/google/google_util.h" | 9 #include "chrome/browser/google/google_util.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 0, views::GridLayout::USE_PREF, 0, 0); | 94 0, views::GridLayout::USE_PREF, 0, 0); |
| 95 columns->AddPaddingColumn(1, kPadding); | 95 columns->AddPaddingColumn(1, kPadding); |
| 96 | 96 |
| 97 views::ImageView* image = new views::ImageView(); | 97 views::ImageView* image = new views::ImageView(); |
| 98 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 98 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 99 image->SetImage( | 99 image->SetImage( |
| 100 rb.GetBitmapNamed((kind_ == CRASHED) ? IDR_SAD_TAB : IDR_KILLED_TAB)); | 100 rb.GetBitmapNamed((kind_ == CRASHED) ? IDR_SAD_TAB : IDR_KILLED_TAB)); |
| 101 layout->StartRowWithPadding(0, column_set_id, 1, kPadding); | 101 layout->StartRowWithPadding(0, column_set_id, 1, kPadding); |
| 102 layout->AddView(image); | 102 layout->AddView(image); |
| 103 | 103 |
| 104 views::Label* title = new views::Label(l10n_util::GetStringUTF16( | 104 views::Label* title = new views::Label(UTF16ToWide(l10n_util::GetStringUTF16( |
| 105 (kind_ == CRASHED) ? IDS_SAD_TAB_TITLE : IDS_KILLED_TAB_TITLE)); | 105 (kind_ == CRASHED) ? IDS_SAD_TAB_TITLE : IDS_KILLED_TAB_TITLE))); |
| 106 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); | 106 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); |
| 107 title->SetFont(base_font.DeriveFont(kTitleFontSizeDelta, gfx::Font::BOLD)); | 107 title->SetFont(base_font.DeriveFont(kTitleFontSizeDelta, gfx::Font::BOLD)); |
| 108 title->SetColor(kTextColor); | 108 title->SetColor(kTextColor); |
| 109 layout->StartRowWithPadding(0, column_set_id, 0, kPadding); | 109 layout->StartRowWithPadding(0, column_set_id, 0, kPadding); |
| 110 layout->AddView(title); | 110 layout->AddView(title); |
| 111 | 111 |
| 112 message_ = new views::Label(l10n_util::GetStringUTF16( | 112 message_ = new views::Label(UTF16ToWide(l10n_util::GetStringUTF16( |
| 113 (kind_ == CRASHED) ? IDS_SAD_TAB_MESSAGE : IDS_KILLED_TAB_MESSAGE)); | 113 (kind_ == CRASHED) ? IDS_SAD_TAB_MESSAGE : IDS_KILLED_TAB_MESSAGE))); |
| 114 message_->SetFont(base_font.DeriveFont(kMessageFontSizeDelta)); | 114 message_->SetFont(base_font.DeriveFont(kMessageFontSizeDelta)); |
| 115 message_->SetColor(kTextColor); | 115 message_->SetColor(kTextColor); |
| 116 message_->SetMultiLine(true); | 116 message_->SetMultiLine(true); |
| 117 layout->StartRowWithPadding(0, column_set_id, 0, kPadding); | 117 layout->StartRowWithPadding(0, column_set_id, 0, kPadding); |
| 118 layout->AddView(message_); | 118 layout->AddView(message_); |
| 119 | 119 |
| 120 if (tab_contents_) { | 120 if (tab_contents_) { |
| 121 string16 help_link(l10n_util::GetStringUTF16( | 121 std::wstring help_link(UTF16ToWide(l10n_util::GetStringUTF16( |
| 122 (kind_ == CRASHED) ? IDS_SAD_TAB_HELP_LINK : IDS_LEARN_MORE)); | 122 (kind_ == CRASHED) ? IDS_SAD_TAB_HELP_LINK : IDS_LEARN_MORE))); |
| 123 help_link_ = new views::Link(help_link); | 123 help_link_ = new views::Link(help_link); |
| 124 help_link_->SetFont(base_font.DeriveFont(kMessageFontSizeDelta)); | 124 help_link_->SetFont(base_font.DeriveFont(kMessageFontSizeDelta)); |
| 125 help_link_->SetNormalColor(kTextColor); | 125 help_link_->SetNormalColor(kTextColor); |
| 126 help_link_->set_listener(this); | 126 help_link_->set_listener(this); |
| 127 | 127 |
| 128 if (kind_ == CRASHED) { | 128 if (kind_ == CRASHED) { |
| 129 size_t offset = 0; | 129 size_t offset = 0; |
| 130 string16 help_text(l10n_util::GetStringFUTF16(IDS_SAD_TAB_HELP_MESSAGE, | 130 string16 help_text(l10n_util::GetStringFUTF16(IDS_SAD_TAB_HELP_MESSAGE, |
| 131 string16(), &offset)); | 131 string16(), &offset)); |
| 132 views::Label* help_prefix = | 132 views::Label* help_prefix = |
| 133 new views::Label(help_text.substr(0, offset)); | 133 new views::Label(UTF16ToWide(help_text.substr(0, offset))); |
| 134 help_prefix->SetFont(base_font.DeriveFont(kMessageFontSizeDelta)); | 134 help_prefix->SetFont(base_font.DeriveFont(kMessageFontSizeDelta)); |
| 135 help_prefix->SetColor(kTextColor); | 135 help_prefix->SetColor(kTextColor); |
| 136 views::Label* help_suffix = new views::Label(help_text.substr(offset)); | 136 views::Label* help_suffix = |
| 137 new views::Label(UTF16ToWide(help_text.substr(offset))); |
| 137 help_suffix->SetFont(base_font.DeriveFont(kMessageFontSizeDelta)); | 138 help_suffix->SetFont(base_font.DeriveFont(kMessageFontSizeDelta)); |
| 138 help_suffix->SetColor(kTextColor); | 139 help_suffix->SetColor(kTextColor); |
| 139 | 140 |
| 140 const int help_column_set_id = 1; | 141 const int help_column_set_id = 1; |
| 141 views::ColumnSet* help_columns = layout->AddColumnSet(help_column_set_id); | 142 views::ColumnSet* help_columns = layout->AddColumnSet(help_column_set_id); |
| 142 help_columns->AddPaddingColumn(1, kPadding); | 143 help_columns->AddPaddingColumn(1, kPadding); |
| 143 // Center three middle columns for the help's [prefix][link][suffix]. | 144 // Center three middle columns for the help's [prefix][link][suffix]. |
| 144 for (size_t column = 0; column < 3; column++) | 145 for (size_t column = 0; column < 3; column++) |
| 145 help_columns->AddColumn(views::GridLayout::CENTER, | 146 help_columns->AddColumn(views::GridLayout::CENTER, |
| 146 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); | 147 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); |
| 147 help_columns->AddPaddingColumn(1, kPadding); | 148 help_columns->AddPaddingColumn(1, kPadding); |
| 148 | 149 |
| 149 layout->StartRowWithPadding(0, help_column_set_id, 0, kPadding); | 150 layout->StartRowWithPadding(0, help_column_set_id, 0, kPadding); |
| 150 layout->AddView(help_prefix); | 151 layout->AddView(help_prefix); |
| 151 layout->AddView(help_link_); | 152 layout->AddView(help_link_); |
| 152 layout->AddView(help_suffix); | 153 layout->AddView(help_suffix); |
| 153 } else { | 154 } else { |
| 154 layout->StartRowWithPadding(0, column_set_id, 0, kPadding); | 155 layout->StartRowWithPadding(0, column_set_id, 0, kPadding); |
| 155 layout->AddView(help_link_); | 156 layout->AddView(help_link_); |
| 156 | 157 |
| 157 feedback_link_ = new views::Link( | 158 feedback_link_ = new views::Link(UTF16ToWide( |
| 158 l10n_util::GetStringUTF16(IDS_KILLED_TAB_FEEDBACK_LINK)); | 159 l10n_util::GetStringUTF16(IDS_KILLED_TAB_FEEDBACK_LINK))); |
| 159 feedback_link_->SetFont(base_font.DeriveFont(kMessageFontSizeDelta)); | 160 feedback_link_->SetFont(base_font.DeriveFont(kMessageFontSizeDelta)); |
| 160 feedback_link_->SetNormalColor(kTextColor); | 161 feedback_link_->SetNormalColor(kTextColor); |
| 161 feedback_link_->set_listener(this); | 162 feedback_link_->set_listener(this); |
| 162 layout->StartRowWithPadding(0, column_set_id, 0, kPadding); | 163 layout->StartRowWithPadding(0, column_set_id, 0, kPadding); |
| 163 layout->AddView(feedback_link_); | 164 layout->AddView(feedback_link_); |
| 164 } | 165 } |
| 165 } | 166 } |
| 166 layout->AddPaddingRow(1, kPadding); | 167 layout->AddPaddingRow(1, kPadding); |
| 167 } | 168 } |
| 168 | 169 |
| 169 void SadTabView::OnPaint(gfx::Canvas* canvas) { | 170 void SadTabView::OnPaint(gfx::Canvas* canvas) { |
| 170 if (!painted_) { | 171 if (!painted_) { |
| 171 // User actually saw the error, keep track for user experience stats. | 172 // User actually saw the error, keep track for user experience stats. |
| 172 UMA_HISTOGRAM_COUNTS("SadTab.Displayed", kind_); | 173 UMA_HISTOGRAM_COUNTS("SadTab.Displayed", kind_); |
| 173 painted_ = true; | 174 painted_ = true; |
| 174 } | 175 } |
| 175 View::OnPaint(canvas); | 176 View::OnPaint(canvas); |
| 176 } | 177 } |
| OLD | NEW |