| Index: chrome/browser/ui/views/sad_tab_view.cc
|
| diff --git a/chrome/browser/ui/views/sad_tab_view.cc b/chrome/browser/ui/views/sad_tab_view.cc
|
| index fa49b6082695e0493f7ab78f2787bc93d2fd2337..b71d049546b5bc01388dbea16138ad76cea7dc8c 100644
|
| --- a/chrome/browser/ui/views/sad_tab_view.cc
|
| +++ b/chrome/browser/ui/views/sad_tab_view.cc
|
| @@ -51,7 +51,7 @@ static const int kMessageFontSizeDelta = 1;
|
|
|
| SadTabView::SadTabView(TabContents* tab_contents, Kind kind)
|
| : tab_contents_(tab_contents),
|
| - learn_more_link_(NULL),
|
| + help_link_(NULL),
|
| kind_(kind),
|
| painted_(false) {
|
| DCHECK(tab_contents);
|
| @@ -76,12 +76,19 @@ SadTabView::SadTabView(TabContents* tab_contents, Kind kind)
|
| kind == CRASHED ? IDS_SAD_TAB_MESSAGE : IDS_KILLED_TAB_MESSAGE);
|
|
|
| if (tab_contents != NULL) {
|
| - learn_more_link_ =
|
| - new views::Link(UTF16ToWide(l10n_util::GetStringUTF16(IDS_LEARN_MORE)));
|
| - learn_more_link_->SetFont(*message_font_);
|
| - learn_more_link_->SetNormalColor(kLinkColor);
|
| - learn_more_link_->set_listener(this);
|
| - AddChildView(learn_more_link_);
|
| + if (kind == CRASHED) {
|
| + size_t offset = 0;
|
| + string16 help(l10n_util::GetStringFUTF16(IDS_SAD_TAB_HELP_MESSAGE,
|
| + string16(), &offset));
|
| + help_prefix_ = help.substr(0, offset);
|
| + help_suffix_ = help.substr(offset);
|
| + }
|
| + help_link_ = new views::Link(UTF16ToWide(l10n_util::GetStringUTF16(
|
| + kind == CRASHED ? IDS_SAD_TAB_HELP_LINK : IDS_LEARN_MORE)));
|
| + help_link_->SetFont(*message_font_);
|
| + help_link_->SetNormalColor(kLinkColor);
|
| + help_link_->set_listener(this);
|
| + AddChildView(help_link_);
|
| }
|
| }
|
|
|
| @@ -117,9 +124,21 @@ void SadTabView::OnPaint(gfx::Canvas* canvas) {
|
| message_bounds_.width(), message_bounds_.height(),
|
| kMessageFlags);
|
|
|
| - if (learn_more_link_ != NULL)
|
| - learn_more_link_->SetBounds(link_bounds_.x(), link_bounds_.y(),
|
| - link_bounds_.width(), link_bounds_.height());
|
| + if (help_link_ != NULL) {
|
| + if (kind_ == CRASHED) {
|
| + canvas->DrawStringInt(help_prefix_, *message_font_, kMessageColor,
|
| + help_prefix_bounds_.x(), help_prefix_bounds_.y(),
|
| + help_prefix_bounds_.width(), help_prefix_bounds_.height(),
|
| + gfx::Canvas::TEXT_ALIGN_CENTER);
|
| +
|
| + canvas->DrawStringInt(help_suffix_, *message_font_, kMessageColor,
|
| + help_suffix_bounds_.x(), help_suffix_bounds_.y(),
|
| + help_suffix_bounds_.width(), help_suffix_bounds_.height(),
|
| + gfx::Canvas::TEXT_ALIGN_CENTER);
|
| + }
|
| + help_link_->SetBounds(help_link_bounds_.x(), help_link_bounds_.y(),
|
| + help_link_bounds_.width(), help_link_bounds_.height());
|
| + }
|
| }
|
|
|
| void SadTabView::Layout() {
|
| @@ -143,17 +162,32 @@ void SadTabView::Layout() {
|
| int message_y = title_bounds_.bottom() + kTitleMessageSpacing;
|
| message_bounds_.SetRect(message_x, message_y, message_width, message_height);
|
|
|
| - if (learn_more_link_ != NULL) {
|
| - gfx::Size sz = learn_more_link_->GetPreferredSize();
|
| - gfx::Insets insets = learn_more_link_->GetInsets();
|
| - link_bounds_.SetRect((width() - sz.width()) / 2,
|
| - message_bounds_.bottom() + kTitleMessageSpacing -
|
| - insets.top(), sz.width(), sz.height());
|
| + if (help_link_ != NULL) {
|
| + gfx::Size link_size = help_link_->GetPreferredSize();
|
| + gfx::Insets link_insets = help_link_->GetInsets();
|
| + int y = message_bounds_.bottom() + kTitleMessageSpacing;
|
| + if (kind_ == CRASHED) {
|
| + // Layout [HELP PREFIX][HELP LINK][HELP SUFFIX] centered.
|
| + int help_height = message_font_->GetHeight();
|
| + int prefix_width = message_font_->GetStringWidth(help_prefix_);
|
| + int suffix_width = message_font_->GetStringWidth(help_suffix_);
|
| + int offset = width() - link_size.width() - prefix_width - suffix_width;
|
| + offset /= 2;
|
| + help_prefix_bounds_.SetRect(offset, y, prefix_width, help_height);
|
| + offset += prefix_width;
|
| + help_link_bounds_.SetRect(offset, y - link_insets.top(),
|
| + link_size.width(), link_size.height());
|
| + offset += link_size.width();
|
| + help_suffix_bounds_.SetRect(offset, y, suffix_width, help_height);
|
| + } else {
|
| + help_link_bounds_.SetRect((width() - link_size.width()) / 2,
|
| + y - link_insets.top(), link_size.width(), link_size.height());
|
| + }
|
| }
|
| }
|
|
|
| void SadTabView::LinkClicked(views::Link* source, int event_flags) {
|
| - if (tab_contents_ != NULL && source == learn_more_link_) {
|
| + if (tab_contents_ != NULL && source == help_link_) {
|
| GURL help_url =
|
| google_util::AppendGoogleLocaleParam(GURL(kind_ == CRASHED ?
|
| chrome::kCrashReasonURL :
|
|
|