| 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/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 constexpr int kMaxContentWidth = 600; | 30 constexpr int kMaxContentWidth = 600; |
| 31 constexpr int kMinColumnWidth = 120; | 31 constexpr int kMinColumnWidth = 120; |
| 32 constexpr int kTitleBottomSpacing = 13; | 32 constexpr int kTitleBottomSpacing = 13; |
| 33 | 33 |
| 34 } // namespace | 34 } // namespace |
| 35 | 35 |
| 36 SadTabView::SadTabView(content::WebContents* web_contents, | 36 SadTabView::SadTabView(content::WebContents* web_contents, |
| 37 chrome::SadTabKind kind) | 37 chrome::SadTabKind kind) |
| 38 : SadTab(web_contents, kind) { | 38 : SadTab(web_contents, kind) { |
| 39 set_background(views::Background::CreateThemedSolidBackground( | 39 // Set the background color. |
| 40 this, ui::NativeTheme::kColorId_DialogBackground)); | 40 set_background( |
| 41 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( |
| 42 ui::NativeTheme::kColorId_DialogBackground))); |
| 41 | 43 |
| 42 views::GridLayout* layout = new views::GridLayout(this); | 44 views::GridLayout* layout = new views::GridLayout(this); |
| 43 SetLayoutManager(layout); | 45 SetLayoutManager(layout); |
| 44 | 46 |
| 45 const int column_set_id = 0; | 47 const int column_set_id = 0; |
| 46 views::ColumnSet* columns = layout->AddColumnSet(column_set_id); | 48 views::ColumnSet* columns = layout->AddColumnSet(column_set_id); |
| 47 columns->AddPaddingColumn(1, views::kPanelSubVerticalSpacing); | 49 columns->AddPaddingColumn(1, views::kPanelSubVerticalSpacing); |
| 48 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::LEADING, 0, | 50 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::LEADING, 0, |
| 49 views::GridLayout::USE_PREF, 0, kMinColumnWidth); | 51 views::GridLayout::USE_PREF, 0, kMinColumnWidth); |
| 50 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::LEADING, 0, | 52 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::LEADING, 0, |
| 51 views::GridLayout::USE_PREF, 0, kMinColumnWidth); | 53 views::GridLayout::USE_PREF, 0, kMinColumnWidth); |
| 52 columns->AddPaddingColumn(1, views::kPanelSubVerticalSpacing); | 54 columns->AddPaddingColumn(1, views::kPanelSubVerticalSpacing); |
| 53 | 55 |
| 54 views::ImageView* image = new views::ImageView(); | 56 views::ImageView* image = new views::ImageView(); |
| 55 | 57 |
| 56 image->SetImage( | 58 image->SetImage( |
| 57 gfx::CreateVectorIcon(kCrashedTabIcon, 48, gfx::kChromeIconGrey)); | 59 gfx::CreateVectorIcon(kCrashedTabIcon, 48, gfx::kChromeIconGrey)); |
| 58 layout->AddPaddingRow(1, views::kPanelVerticalSpacing); | 60 layout->AddPaddingRow(1, views::kPanelVerticalSpacing); |
| 59 layout->StartRow(0, column_set_id); | 61 layout->StartRow(0, column_set_id); |
| 60 layout->AddView(image, 2, 1); | 62 layout->AddView(image, 2, 1); |
| 61 | 63 |
| 62 title_ = new views::Label(l10n_util::GetStringUTF16(GetTitle())); | 64 title_ = CreateLabel(l10n_util::GetStringUTF16(GetTitle())); |
| 63 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 65 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 64 title_->SetFontList(rb.GetFontList(ui::ResourceBundle::LargeFont)); | 66 title_->SetFontList(rb.GetFontList(ui::ResourceBundle::LargeFont)); |
| 65 title_->SetMultiLine(true); | 67 title_->SetMultiLine(true); |
| 66 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 68 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 67 layout->StartRowWithPadding(0, column_set_id, 0, | 69 layout->StartRowWithPadding(0, column_set_id, 0, |
| 68 views::kPanelVerticalSpacing); | 70 views::kPanelVerticalSpacing); |
| 69 layout->AddView(title_, 2, 1); | 71 layout->AddView(title_, 2, 1); |
| 70 | 72 |
| 71 message_ = new views::Label(l10n_util::GetStringUTF16(GetMessage())); | 73 const SkColor text_color = GetNativeTheme()->GetSystemColor( |
| 74 ui::NativeTheme::kColorId_LabelDisabledColor); |
| 75 |
| 76 message_ = CreateLabel(l10n_util::GetStringUTF16(GetMessage())); |
| 72 | 77 |
| 73 message_->SetMultiLine(true); | 78 message_->SetMultiLine(true); |
| 74 message_->SetEnabled(false); | 79 message_->SetEnabledColor(text_color); |
| 75 message_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 80 message_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 76 message_->SetLineHeight(views::kPanelSubVerticalSpacing); | 81 message_->SetLineHeight(views::kPanelSubVerticalSpacing); |
| 77 | 82 |
| 78 layout->StartRowWithPadding(0, column_set_id, 0, kTitleBottomSpacing); | 83 layout->StartRowWithPadding(0, column_set_id, 0, kTitleBottomSpacing); |
| 79 layout->AddView(message_, 2, 1, views::GridLayout::LEADING, | 84 layout->AddView(message_, 2, 1, views::GridLayout::LEADING, |
| 80 views::GridLayout::LEADING); | 85 views::GridLayout::LEADING); |
| 81 | 86 |
| 82 action_button_ = views::MdTextButton::CreateSecondaryUiBlueButton( | 87 action_button_ = views::MdTextButton::CreateSecondaryUiBlueButton( |
| 83 this, l10n_util::GetStringUTF16(GetButtonTitle())); | 88 this, l10n_util::GetStringUTF16(GetButtonTitle())); |
| 84 help_link_ = new views::Link(l10n_util::GetStringUTF16(GetHelpLinkTitle())); | 89 help_link_ = |
| 85 help_link_->set_listener(this); | 90 CreateLink(l10n_util::GetStringUTF16(GetHelpLinkTitle()), text_color); |
| 86 layout->StartRowWithPadding(0, column_set_id, 0, | 91 layout->StartRowWithPadding(0, column_set_id, 0, |
| 87 views::kPanelVerticalSpacing); | 92 views::kPanelVerticalSpacing); |
| 88 layout->AddView(help_link_, 1, 1, views::GridLayout::LEADING, | 93 layout->AddView(help_link_, 1, 1, views::GridLayout::LEADING, |
| 89 views::GridLayout::CENTER); | 94 views::GridLayout::CENTER); |
| 90 layout->AddView(action_button_, 1, 1, views::GridLayout::TRAILING, | 95 layout->AddView(action_button_, 1, 1, views::GridLayout::TRAILING, |
| 91 views::GridLayout::LEADING); | 96 views::GridLayout::LEADING); |
| 92 | 97 |
| 93 layout->AddPaddingRow(2, views::kPanelSubVerticalSpacing); | 98 layout->AddPaddingRow(2, views::kPanelSubVerticalSpacing); |
| 94 | 99 |
| 95 views::Widget::InitParams sad_tab_params( | 100 views::Widget::InitParams sad_tab_params( |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 } | 143 } |
| 139 | 144 |
| 140 void SadTabView::OnPaint(gfx::Canvas* canvas) { | 145 void SadTabView::OnPaint(gfx::Canvas* canvas) { |
| 141 if (!painted_) { | 146 if (!painted_) { |
| 142 RecordFirstPaint(); | 147 RecordFirstPaint(); |
| 143 painted_ = true; | 148 painted_ = true; |
| 144 } | 149 } |
| 145 View::OnPaint(canvas); | 150 View::OnPaint(canvas); |
| 146 } | 151 } |
| 147 | 152 |
| 153 views::Label* SadTabView::CreateLabel(const base::string16& text) { |
| 154 views::Label* label = new views::Label(text); |
| 155 label->SetBackgroundColor(background()->get_color()); |
| 156 return label; |
| 157 } |
| 158 |
| 159 views::Link* SadTabView::CreateLink(const base::string16& text, |
| 160 const SkColor& color) { |
| 161 views::Link* link = new views::Link(text); |
| 162 link->SetBackgroundColor(background()->get_color()); |
| 163 link->SetEnabledColor(color); |
| 164 link->set_listener(this); |
| 165 return link; |
| 166 } |
| 167 |
| 148 namespace chrome { | 168 namespace chrome { |
| 149 | 169 |
| 150 SadTab* SadTab::Create(content::WebContents* web_contents, | 170 SadTab* SadTab::Create(content::WebContents* web_contents, |
| 151 SadTabKind kind) { | 171 SadTabKind kind) { |
| 152 return new SadTabView(web_contents, kind); | 172 return new SadTabView(web_contents, kind); |
| 153 } | 173 } |
| 154 | 174 |
| 155 } // namespace chrome | 175 } // namespace chrome |
| OLD | NEW |