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