Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/browser_process.h" | |
| 12 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_finder.h" | 14 #include "chrome/browser/ui/browser_finder.h" |
| 14 #include "chrome/browser/ui/chrome_pages.h" | 15 #include "chrome/browser/ui/chrome_pages.h" |
| 15 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 16 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
| 17 #include "components/feedback/feedback_util.h" | 18 #include "components/feedback/feedback_util.h" |
| 18 #include "content/public/browser/navigation_controller.h" | 19 #include "content/public/browser/navigation_controller.h" |
| 19 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 20 #include "grit/components_strings.h" | 21 #include "grit/components_strings.h" |
| 21 #include "grit/theme_resources.h" | 22 #include "grit/theme_resources.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 23 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
| 24 #include "ui/views/background.h" | 25 #include "ui/views/background.h" |
| 26 #include "ui/views/controls/button/blue_button.h" | |
| 25 #include "ui/views/controls/button/label_button.h" | 27 #include "ui/views/controls/button/label_button.h" |
| 26 #include "ui/views/controls/button/label_button_border.h" | 28 #include "ui/views/controls/button/label_button_border.h" |
| 27 #include "ui/views/controls/image_view.h" | 29 #include "ui/views/controls/image_view.h" |
| 28 #include "ui/views/controls/label.h" | 30 #include "ui/views/controls/label.h" |
| 29 #include "ui/views/controls/link.h" | 31 #include "ui/views/controls/link.h" |
| 32 #include "ui/views/controls/styled_label.h" | |
| 30 #include "ui/views/layout/grid_layout.h" | 33 #include "ui/views/layout/grid_layout.h" |
| 31 #include "ui/views/widget/widget.h" | 34 #include "ui/views/widget/widget.h" |
| 32 | 35 |
| 33 using content::OpenURLParams; | 36 using content::OpenURLParams; |
| 34 using content::WebContents; | 37 using content::WebContents; |
| 35 | 38 |
| 36 namespace { | 39 namespace { |
| 37 | 40 |
| 38 const int kPadding = 20; | 41 const int kPadding = 16; |
| 42 const int kTopPadding = 100; | |
|
msw
2015/05/11 18:27:09
Why are we doing such excessive padding instead of
edwardjung
2015/05/14 18:31:27
The design was updated to be vertically anchored t
| |
| 43 const int kLineHeight = 24; | |
| 44 const int kMaxContentWidth = 600; | |
| 45 const int kMinColumnWidth = 100; | |
| 46 const int kLabelHeight = 50; | |
| 39 const float kMessageSize = 0.65f; | 47 const float kMessageSize = 0.65f; |
| 40 const SkColor kTextColor = SK_ColorWHITE; | 48 const SkColor kTextColor = SkColorSetRGB(100, 100, 100); |
|
msw
2015/05/11 18:27:09
This isn't cool. Can we use (or make these) native
edwardjung
2015/05/14 18:31:26
Per the chat with ainslie and bettes to not use th
msw
2015/05/14 23:50:19
Post screenshots as I suggest, ainslie and bettes
edwardjung
2015/05/18 12:02:35
You assumed correct, I wasn't passing the enum to
| |
| 41 const SkColor kCrashColor = SkColorSetRGB(35, 48, 64); | 49 const SkColor kTitleColor = SkColorSetRGB(51, 51, 51); |
| 42 const SkColor kKillColor = SkColorSetRGB(57, 48, 88); | 50 const SkColor kCrashColor = SkColorSetRGB(247, 247, 247); |
| 51 const SkColor kKillColor = SkColorSetRGB(247, 247, 247); | |
| 52 // const SkColor kButtonColor = SkColorSetRGB(76, 142, 250); | |
|
msw
2015/05/11 18:27:10
Please review your own code thoroughly before aski
edwardjung
2015/05/14 18:31:27
Apologies again.
| |
| 43 | 53 |
| 44 const char kCategoryTagCrash[] = "Crash"; | 54 const char kCategoryTagCrash[] = "Crash"; |
| 45 | 55 |
| 46 } // namespace | 56 } // namespace |
| 47 | 57 |
| 58 namespace views { | |
| 59 | |
| 60 // Extends Label to allow defining a maximum width. | |
| 61 class LabelWithMaxWidth : public Label { | |
|
msw
2015/05/11 18:27:09
Can you instead call Label::SizeToFit for the mult
edwardjung
2015/05/14 18:31:27
Thanks for the suggestion. I've updated SadTabView
| |
| 62 public: | |
| 63 explicit LabelWithMaxWidth(const base::string16& text) : Label(text) { | |
| 64 } | |
| 65 | |
| 66 ~LabelWithMaxWidth() override; | |
| 67 | |
| 68 gfx::Size GetPreferredSize() const override { | |
| 69 gfx::Size out = Label::GetPreferredSize(); | |
| 70 int width = std::min(out.width(), kMaxContentWidth); | |
|
msw
2015/05/11 18:27:09
Might any single-line labels go through this code
edwardjung
2015/05/14 18:31:26
I removed this class per suggestion above.
| |
| 71 out.SetSize(width, Label::GetHeightForWidth(width)); | |
| 72 return out; | |
| 73 } | |
| 74 }; | |
| 75 | |
| 76 LabelWithMaxWidth::~LabelWithMaxWidth() {} | |
|
msw
2015/05/11 18:27:09
nit: inline
edwardjung
2015/05/14 18:31:27
No longer applicable
| |
| 77 | |
| 78 } // namespace views | |
| 79 | |
| 48 SadTabView::SadTabView(WebContents* web_contents, chrome::SadTabKind kind) | 80 SadTabView::SadTabView(WebContents* web_contents, chrome::SadTabKind kind) |
| 49 : web_contents_(web_contents), | 81 : web_contents_(web_contents), |
| 50 kind_(kind), | 82 kind_(kind), |
| 51 painted_(false), | 83 painted_(false), |
| 52 message_(NULL), | 84 message_(NULL), |
| 53 help_link_(NULL), | 85 help_link_(NULL), |
| 54 feedback_link_(NULL), | 86 feedback_link_(NULL), |
| 55 reload_button_(NULL) { | 87 reload_button_(NULL) { |
| 56 DCHECK(web_contents); | 88 DCHECK(web_contents); |
| 57 | 89 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 77 static int killed = 0; | 109 static int killed = 0; |
| 78 killed++; | 110 killed++; |
| 79 UMA_HISTOGRAM_CUSTOM_COUNTS( | 111 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 80 "Tabs.SadTab.KillCreated", killed, 1, 1000, 50); | 112 "Tabs.SadTab.KillCreated", killed, 1, 1000, 50); |
| 81 break; | 113 break; |
| 82 } | 114 } |
| 83 default: | 115 default: |
| 84 NOTREACHED(); | 116 NOTREACHED(); |
| 85 } | 117 } |
| 86 | 118 |
| 119 // Linux and Windows font size discrepency | |
|
msw
2015/05/11 18:27:09
indentation...
edwardjung
2015/05/14 18:31:27
Done.
| |
| 120 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
| 121 #if defined(OS_WIN) | |
|
msw
2015/05/11 18:27:09
This is not acceptable. Pick a ui::ResourceBundle:
edwardjung
2015/05/14 18:31:26
In our minds, we are trying to achieve consistency
| |
| 122 const int kTitleFontAdjustment = 4; | |
| 123 gfx::FontList body_font_list_ = | |
| 124 rb.GetFontList(ui::ResourceBundle::MediumFont); | |
| 125 gfx::FontList link_font_list_ = medium_font_list_.DeriveWithSizeDelta(-1); | |
| 126 #else | |
| 127 const int kTitleFontAdjustment = 0; | |
| 128 gfx::FontList body_font_list_ = | |
| 129 rb.GetFontList(ui::ResourceBundle::SmallFont); | |
| 130 #endif | |
| 131 | |
| 87 // Set the background color. | 132 // Set the background color. |
| 88 set_background(views::Background::CreateSolidBackground( | 133 set_background(views::Background::CreateSolidBackground( |
| 89 (kind_ == chrome::SAD_TAB_KIND_CRASHED) ? kCrashColor : kKillColor)); | 134 (kind_ == chrome::SAD_TAB_KIND_CRASHED) ? kCrashColor : kKillColor)); |
| 90 | 135 |
| 91 views::GridLayout* layout = new views::GridLayout(this); | 136 views::GridLayout* layout = new views::GridLayout(this); |
| 92 SetLayoutManager(layout); | 137 SetLayoutManager(layout); |
| 93 | 138 |
| 94 const int column_set_id = 0; | 139 const int column_set_id = 0; |
| 95 views::ColumnSet* columns = layout->AddColumnSet(column_set_id); | 140 views::ColumnSet* columns = layout->AddColumnSet(column_set_id); |
| 96 columns->AddPaddingColumn(1, kPadding); | 141 columns->AddPaddingColumn(0.5, kPadding); |
|
msw
2015/05/11 18:27:09
You can leave both of these at 1 for evenly balanc
edwardjung
2015/05/14 18:31:27
Done.
| |
| 97 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, | 142 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::LEADING, |
| 98 0, views::GridLayout::USE_PREF, 0, 0); | 143 0, views::GridLayout::USE_PREF, 0, kMinColumnWidth); |
| 99 columns->AddPaddingColumn(1, kPadding); | 144 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::LEADING, |
| 145 0, views::GridLayout::USE_PREF, 0, kMinColumnWidth); | |
| 146 columns->AddPaddingColumn(0.5, kPadding); | |
| 100 | 147 |
| 101 views::ImageView* image = new views::ImageView(); | 148 views::ImageView* image = new views::ImageView(); |
| 102 image->SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 149 image->SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 103 (kind_ == chrome::SAD_TAB_KIND_CRASHED) ? IDR_SAD_TAB : IDR_KILLED_TAB)); | 150 IDR_SAD_TAB)); |
|
msw
2015/05/11 18:27:09
Are we no longer using IDR_KILLED_TAB? Remove the
edwardjung
2015/05/14 18:31:26
That's correct, they will use the same image. I'll
| |
| 104 layout->StartRowWithPadding(0, column_set_id, 1, kPadding); | 151 layout->StartRowWithPadding(0, column_set_id, 0, kTopPadding); |
| 105 layout->AddView(image); | 152 layout->AddView(image, 2, 1); |
| 106 | 153 |
| 107 views::Label* title = CreateLabel(l10n_util::GetStringUTF16( | 154 views::Label* title = CreateLabel(l10n_util::GetStringUTF16( |
| 108 (kind_ == chrome::SAD_TAB_KIND_CRASHED) ? | 155 (kind_ == chrome::SAD_TAB_KIND_CRASHED) ? |
| 109 IDS_SAD_TAB_TITLE : IDS_KILLED_TAB_TITLE)); | 156 IDS_SAD_TAB_TITLE : IDS_KILLED_TAB_TITLE)); |
| 110 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 157 // Font size is too large on Linux. |
|
msw
2015/05/11 18:27:09
No, if that's really the case we need a fix to the
edwardjung
2015/05/14 18:31:27
Removed the font adjustment
| |
| 111 title->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont)); | 158 title->SetFontList(rb.GetFontList( |
| 112 layout->StartRowWithPadding(0, column_set_id, 0, kPadding); | 159 ui::ResourceBundle::LargeFont).DeriveWithSizeDelta(kTitleFontAdjustment)); |
| 113 layout->AddView(title); | 160 title->SetEnabledColor(kTitleColor); |
| 161 layout->StartRowWithPadding(0, column_set_id, 0, kPadding * 2); | |
| 162 layout->AddView(title, 2, 1); | |
| 114 | 163 |
| 115 message_ = CreateLabel(l10n_util::GetStringUTF16( | 164 message_ = CreateLabel(l10n_util::GetStringUTF16( |
| 116 (kind_ == chrome::SAD_TAB_KIND_CRASHED) ? | 165 (kind_ == chrome::SAD_TAB_KIND_CRASHED) ? |
| 117 IDS_SAD_TAB_MESSAGE : IDS_KILLED_TAB_MESSAGE)); | 166 IDS_SAD_TAB_MESSAGE : IDS_KILLED_TAB_MESSAGE)); |
| 167 message_->SetFontList(body_font_list_); | |
| 118 message_->SetMultiLine(true); | 168 message_->SetMultiLine(true); |
| 169 message_->SetEnabledColor(kTextColor); | |
| 170 message_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
| 171 message_->SetLineHeight(kLineHeight); | |
| 172 | |
| 119 layout->StartRowWithPadding(0, column_set_id, 0, kPadding); | 173 layout->StartRowWithPadding(0, column_set_id, 0, kPadding); |
| 120 layout->AddView(message_); | 174 layout->AddView(message_, 2, 1, views::GridLayout::LEADING, |
| 175 views::GridLayout::LEADING); | |
| 121 | 176 |
| 122 if (web_contents_) { | 177 if (web_contents_) { |
| 123 layout->StartRowWithPadding(0, column_set_id, 0, kPadding); | 178 help_link_ = CreateLink(l10n_util::GetStringUTF16( |
| 124 reload_button_ = new views::LabelButton( | 179 (kind_ == chrome::SAD_TAB_KIND_CRASHED) ? |
| 180 IDS_SAD_TAB_HELP_LINK : IDS_LEARN_MORE)); | |
|
msw
2015/05/11 18:27:09
Do both mocks actually have a help link?
edwardjung
2015/05/14 18:31:27
You're correct, only chrome://kill has the help li
| |
| 181 help_link_->SetFontList(body_font_list_); | |
| 182 | |
| 183 reload_button_ = new views::BlueButton( | |
| 125 this, | 184 this, |
| 126 l10n_util::GetStringUTF16(IDS_SAD_TAB_RELOAD_LABEL)); | 185 l10n_util::GetStringUTF16(IDS_SAD_TAB_RELOAD_LABEL)); |
| 127 reload_button_->SetStyle(views::Button::STYLE_BUTTON); | 186 reload_button_->SetFontList(body_font_list_); |
| 128 // Always render the reload button with chrome style borders; never rely on | 187 reload_button_->SetMinSize(gfx::Size(90, 36)); |
| 129 // native styles. | |
| 130 reload_button_->SetBorder(scoped_ptr<views::Border>( | |
| 131 new views::LabelButtonBorder(reload_button_->style()))); | |
| 132 layout->AddView(reload_button_); | |
| 133 | |
| 134 help_link_ = CreateLink(l10n_util::GetStringUTF16( | |
| 135 (kind_ == chrome::SAD_TAB_KIND_CRASHED) ? | |
| 136 IDS_SAD_TAB_HELP_LINK : IDS_LEARN_MORE)); | |
| 137 | 188 |
| 138 if (kind_ == chrome::SAD_TAB_KIND_CRASHED) { | 189 if (kind_ == chrome::SAD_TAB_KIND_CRASHED) { |
| 139 size_t offset = 0; | 190 size_t offset = 0; |
| 140 base::string16 help_text( | 191 base::string16 help_text( |
| 141 l10n_util::GetStringFUTF16(IDS_SAD_TAB_HELP_MESSAGE, | 192 l10n_util::GetStringFUTF16(IDS_SAD_TAB_HELP_MESSAGE, |
| 142 base::string16(), &offset)); | 193 base::string16(), &offset)); |
| 143 views::Label* help_prefix = CreateLabel(help_text.substr(0, offset)); | |
| 144 views::Label* help_suffix = CreateLabel(help_text.substr(offset)); | |
| 145 | 194 |
| 146 const int help_column_set_id = 1; | 195 base::string16 link_text = |
| 147 views::ColumnSet* help_columns = layout->AddColumnSet(help_column_set_id); | 196 l10n_util::GetStringUTF16(IDS_SAD_TAB_HELP_LINK); |
|
msw
2015/05/11 18:27:08
Why is this different than |help_link_|'s text? Is
edwardjung
2015/05/14 18:31:26
This is the suggestion link which only appears on
| |
| 148 help_columns->AddPaddingColumn(1, kPadding); | |
| 149 // Center three middle columns for the help's [prefix][link][suffix]. | |
| 150 for (size_t column = 0; column < 3; column++) | |
| 151 help_columns->AddColumn(views::GridLayout::CENTER, | |
| 152 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); | |
| 153 help_columns->AddPaddingColumn(1, kPadding); | |
| 154 | 197 |
| 155 layout->StartRowWithPadding(0, help_column_set_id, 0, kPadding); | 198 base::string16 help_prefix = help_text.substr(0, offset); |
| 156 layout->AddView(help_prefix); | 199 base::string16 help_suffix = help_text.substr(offset); |
| 157 layout->AddView(help_link_); | 200 base::string16 help_message_string = help_prefix; |
| 158 layout->AddView(help_suffix); | 201 help_message_string.append(link_text).append(help_suffix); |
| 202 | |
| 203 views::StyledLabel* help_message_ = | |
| 204 new views::StyledLabel(help_message_string, this); | |
| 205 | |
| 206 views::StyledLabel::RangeStyleInfo link_style = | |
| 207 views::StyledLabel::RangeStyleInfo::CreateForLink(); | |
| 208 link_style.font_style = gfx::Font::UNDERLINE; | |
| 209 link_style.color = kTextColor; | |
| 210 | |
| 211 views::StyledLabel::RangeStyleInfo normal_style = | |
| 212 views::StyledLabel::RangeStyleInfo::CreateForLink(); | |
| 213 normal_style.font_style = gfx::Font::NORMAL; | |
| 214 normal_style.color = kTextColor; | |
| 215 normal_style.is_link = false; | |
| 216 | |
| 217 help_message_->SetBaseFontList(body_font_list_); | |
| 218 help_message_->SetDefaultStyle(normal_style); | |
| 219 help_message_->SetLineHeight(kLineHeight); | |
| 220 | |
| 221 help_message_->AddStyleRange(gfx::Range(help_prefix.length(), | |
| 222 help_message_string.length() - 1), | |
| 223 link_style); | |
| 224 | |
| 225 layout->StartRowWithPadding(0, column_set_id, 0, kPadding); | |
| 226 layout->AddView(help_message_, 2, 1, views::GridLayout::LEADING, | |
| 227 views::GridLayout::TRAILING, kMaxContentWidth, kLabelHeight); | |
|
msw
2015/05/11 18:27:10
Will longer translated text be able to wrap and us
edwardjung
2015/05/14 18:31:27
You're right, the height isn't enough here for lon
| |
| 228 layout->StartRowWithPadding(0, column_set_id, 0, kPadding); | |
| 229 layout->SkipColumns(1); | |
| 159 } else { | 230 } else { |
| 231 base::string16 feedback_text = | |
| 232 l10n_util::GetStringUTF16(IDS_KILLED_TAB_FEEDBACK_LINK); | |
| 233 views::StyledLabel* feedback_link_ = | |
|
msw
2015/05/11 18:27:08
Why is this not simply a views::Link? There is no
edwardjung
2015/05/14 18:31:27
I'll do as suggested.
msw
2015/05/14 23:50:19
Did you try this?
| |
| 234 new views::StyledLabel(feedback_text, this); | |
| 235 | |
| 236 views::StyledLabel::RangeStyleInfo link_style = | |
| 237 views::StyledLabel::RangeStyleInfo::CreateForLink(); | |
| 238 link_style.font_style = gfx::Font::UNDERLINE; | |
| 239 link_style.color = kTextColor; | |
| 240 | |
| 241 feedback_link_->SetBaseFontList(body_font_list_); | |
| 242 feedback_link_->SetDefaultStyle(link_style); | |
| 243 feedback_link_->SetLineHeight(kLineHeight); | |
| 244 | |
| 245 layout->StartRowWithPadding(0, column_set_id, 0, kPadding); | |
| 246 layout->AddView(feedback_link_, 2, 1, views::GridLayout::LEADING, | |
| 247 views::GridLayout::LEADING, kMaxContentWidth, kLabelHeight); | |
| 248 | |
| 160 layout->StartRowWithPadding(0, column_set_id, 0, kPadding); | 249 layout->StartRowWithPadding(0, column_set_id, 0, kPadding); |
| 161 layout->AddView(help_link_); | 250 layout->AddView(help_link_); |
| 162 | |
| 163 feedback_link_ = CreateLink( | |
| 164 l10n_util::GetStringUTF16(IDS_KILLED_TAB_FEEDBACK_LINK)); | |
| 165 layout->StartRowWithPadding(0, column_set_id, 0, kPadding); | |
| 166 layout->AddView(feedback_link_); | |
| 167 } | 251 } |
| 252 layout->AddView(reload_button_, 1, 1, views::GridLayout::TRAILING, | |
| 253 views::GridLayout::LEADING); | |
| 168 } | 254 } |
| 169 layout->AddPaddingRow(1, kPadding); | 255 layout->AddPaddingRow(1, kPadding); |
| 170 } | 256 } |
| 171 | 257 |
| 172 SadTabView::~SadTabView() {} | 258 SadTabView::~SadTabView() {} |
| 173 | 259 |
| 174 void SadTabView::LinkClicked(views::Link* source, int event_flags) { | 260 void SadTabView::LinkClicked(views::Link* source, int event_flags) { |
| 175 DCHECK(web_contents_); | 261 DCHECK(web_contents_); |
| 176 if (source == help_link_) { | 262 if (source == help_link_) { |
| 177 GURL help_url((kind_ == chrome::SAD_TAB_KIND_CRASHED) ? | 263 GURL help_url((kind_ == chrome::SAD_TAB_KIND_CRASHED) ? |
| 178 chrome::kCrashReasonURL : chrome::kKillReasonURL); | 264 chrome::kCrashReasonURL : chrome::kKillReasonURL); |
| 179 OpenURLParams params( | 265 OpenURLParams params( |
| 180 help_url, content::Referrer(), CURRENT_TAB, | 266 help_url, content::Referrer(), CURRENT_TAB, |
| 181 ui::PAGE_TRANSITION_LINK, false); | 267 ui::PAGE_TRANSITION_LINK, false); |
| 182 web_contents_->OpenURL(params); | 268 web_contents_->OpenURL(params); |
| 183 } else if (source == feedback_link_) { | 269 } else if (source == feedback_link_) { |
| 184 chrome::ShowFeedbackPage( | 270 chrome::ShowFeedbackPage( |
| 185 chrome::FindBrowserWithWebContents(web_contents_), | 271 chrome::FindBrowserWithWebContents(web_contents_), |
| 186 l10n_util::GetStringUTF8(IDS_KILLED_TAB_FEEDBACK_MESSAGE), | 272 l10n_util::GetStringUTF8(IDS_KILLED_TAB_FEEDBACK_MESSAGE), |
| 187 std::string(kCategoryTagCrash)); | 273 std::string(kCategoryTagCrash)); |
| 188 } | 274 } |
| 189 } | 275 } |
| 190 | 276 |
| 277 void SadTabView::StyledLabelLinkClicked(const gfx::Range& range, | |
|
msw
2015/05/11 18:27:09
Ugh StyledLabel... This callback doesn't even spec
| |
| 278 int event_flags) { | |
| 279 | |
|
msw
2015/05/11 18:27:09
Remove blank line.
edwardjung
2015/05/14 18:31:26
Done.
| |
| 280 // Will this work for i18n other languages in RTL for example? | |
|
msw
2015/05/11 18:27:09
I doubt it... this does not seem acceptable to me.
edwardjung
2015/05/14 18:31:26
Removed this check as there is now only a single i
| |
| 281 if (range.start() > 0) { | |
| 282 GURL help_url((kind_ == chrome::SAD_TAB_KIND_CRASHED) ? | |
|
msw
2015/05/11 18:27:09
Don't copy this code... refactor it to be used her
edwardjung
2015/05/14 18:31:26
Done.
msw
2015/05/14 23:50:19
Not done, afaict.
edwardjung
2015/05/18 12:02:35
Misunderstood.
| |
| 283 chrome::kCrashReasonURL : chrome::kKillReasonURL); | |
| 284 OpenURLParams params( | |
| 285 help_url, content::Referrer(), CURRENT_TAB, | |
| 286 ui::PAGE_TRANSITION_LINK, false); | |
| 287 web_contents_->OpenURL(params); | |
| 288 } else if (range.start() == 0) { | |
| 289 chrome::ShowFeedbackPage( | |
| 290 chrome::FindBrowserWithWebContents(web_contents_), | |
| 291 l10n_util::GetStringUTF8(IDS_KILLED_TAB_FEEDBACK_MESSAGE), | |
| 292 std::string(kCategoryTagCrash)); | |
| 293 } | |
| 294 } | |
| 295 | |
| 191 void SadTabView::ButtonPressed(views::Button* sender, | 296 void SadTabView::ButtonPressed(views::Button* sender, |
| 192 const ui::Event& event) { | 297 const ui::Event& event) { |
| 193 DCHECK(web_contents_); | 298 DCHECK(web_contents_); |
| 194 DCHECK_EQ(reload_button_, sender); | 299 DCHECK_EQ(reload_button_, sender); |
| 195 web_contents_->GetController().Reload(true); | 300 web_contents_->GetController().Reload(true); |
| 196 } | 301 } |
| 197 | 302 |
| 198 void SadTabView::Layout() { | 303 void SadTabView::Layout() { |
| 199 // Specify the maximum message width explicitly. | 304 // Specify the maximum message width explicitly. |
| 200 message_->SizeToFit(static_cast<int>(width() * kMessageSize)); | 305 message_->SizeToFit(static_cast<int>(width() * kMessageSize)); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 gfx::Rect bounds = web_contents_->GetContainerBounds(); | 357 gfx::Rect bounds = web_contents_->GetContainerBounds(); |
| 253 sad_tab->SetBounds(gfx::Rect(bounds.size())); | 358 sad_tab->SetBounds(gfx::Rect(bounds.size())); |
| 254 } | 359 } |
| 255 | 360 |
| 256 void SadTabView::Close() { | 361 void SadTabView::Close() { |
| 257 if (GetWidget()) | 362 if (GetWidget()) |
| 258 GetWidget()->Close(); | 363 GetWidget()->Close(); |
| 259 } | 364 } |
| 260 | 365 |
| 261 views::Label* SadTabView::CreateLabel(const base::string16& text) { | 366 views::Label* SadTabView::CreateLabel(const base::string16& text) { |
| 262 views::Label* label = new views::Label(text); | 367 views::Label* label = new views::LabelWithMaxWidth(text); |
| 263 label->SetBackgroundColor(background()->get_color()); | 368 label->SetBackgroundColor(background()->get_color()); |
| 264 label->SetEnabledColor(kTextColor); | 369 label->SetEnabledColor(kTextColor); |
| 265 return label; | 370 return label; |
| 266 } | 371 } |
| 267 | 372 |
| 268 views::Link* SadTabView::CreateLink(const base::string16& text) { | 373 views::Link* SadTabView::CreateLink(const base::string16& text) { |
| 269 views::Link* link = new views::Link(text); | 374 views::Link* link = new views::Link(text); |
| 270 link->SetBackgroundColor(background()->get_color()); | 375 link->SetBackgroundColor(background()->get_color()); |
| 271 link->SetEnabledColor(kTextColor); | 376 link->SetEnabledColor(kTextColor); |
| 272 link->set_listener(this); | 377 link->set_listener(this); |
| 273 return link; | 378 return link; |
| 274 } | 379 } |
| 275 | 380 |
| 276 namespace chrome { | 381 namespace chrome { |
| 277 | 382 |
| 278 SadTab* SadTab::Create(content::WebContents* web_contents, | 383 SadTab* SadTab::Create(content::WebContents* web_contents, |
| 279 SadTabKind kind) { | 384 SadTabKind kind) { |
| 280 return new SadTabView(web_contents, kind); | 385 return new SadTabView(web_contents, kind); |
| 281 } | 386 } |
| 282 | 387 |
| 283 } // namespace chrome | 388 } // namespace chrome |
| OLD | NEW |