Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: chrome/browser/ui/views/sad_tab_view.cc

Issue 2794763002: New Sad Tab strings. (Closed)
Patch Set: right number of spaces as per UI review Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
23 #include "ui/views/controls/link.h" 23 #include "ui/views/controls/link.h"
24 #include "ui/views/layout/grid_layout.h" 24 #include "ui/views/layout/grid_layout.h"
25 #include "ui/views/layout/layout_constants.h" 25 #include "ui/views/layout/layout_constants.h"
26 #include "ui/views/widget/widget.h" 26 #include "ui/views/widget/widget.h"
27 27
28 namespace { 28 namespace {
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 constexpr int kBulletBottomSpacing = 3;
33 34
34 } // namespace 35 } // namespace
35 36
36 SadTabView::SadTabView(content::WebContents* web_contents, 37 SadTabView::SadTabView(content::WebContents* web_contents,
37 chrome::SadTabKind kind) 38 chrome::SadTabKind kind)
38 : SadTab(web_contents, kind) { 39 : SadTab(web_contents, kind) {
39 set_background(views::Background::CreateThemedSolidBackground( 40 set_background(views::Background::CreateThemedSolidBackground(
40 this, ui::NativeTheme::kColorId_DialogBackground)); 41 this, ui::NativeTheme::kColorId_DialogBackground));
41 42
42 views::GridLayout* layout = new views::GridLayout(this); 43 views::GridLayout* layout = new views::GridLayout(this);
(...skipping 18 matching lines...) Expand all
61 62
62 title_ = new views::Label(l10n_util::GetStringUTF16(GetTitle())); 63 title_ = new views::Label(l10n_util::GetStringUTF16(GetTitle()));
63 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 64 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
64 title_->SetFontList(rb.GetFontList(ui::ResourceBundle::LargeFont)); 65 title_->SetFontList(rb.GetFontList(ui::ResourceBundle::LargeFont));
65 title_->SetMultiLine(true); 66 title_->SetMultiLine(true);
66 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 67 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
67 layout->StartRowWithPadding(0, column_set_id, 0, 68 layout->StartRowWithPadding(0, column_set_id, 0,
68 views::kPanelVerticalSpacing); 69 views::kPanelVerticalSpacing);
69 layout->AddView(title_, 2, 1); 70 layout->AddView(title_, 2, 1);
70 71
71 message_ = new views::Label(l10n_util::GetStringUTF16(GetMessage())); 72 views::Label* message =
73 new views::Label(l10n_util::GetStringUTF16(GetMessage()));
72 74
73 message_->SetMultiLine(true); 75 message->SetMultiLine(true);
74 message_->SetEnabled(false); 76 message->SetEnabled(false);
75 message_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 77 message->SetHorizontalAlignment(gfx::ALIGN_LEFT);
76 message_->SetLineHeight(views::kPanelSubVerticalSpacing); 78 message->SetLineHeight(views::kPanelSubVerticalSpacing);
77 79
78 layout->StartRowWithPadding(0, column_set_id, 0, kTitleBottomSpacing); 80 layout->StartRowWithPadding(0, column_set_id, 0, kTitleBottomSpacing);
79 layout->AddView(message_, 2, 1, views::GridLayout::LEADING, 81 layout->AddView(message, 2, 1, views::GridLayout::LEADING,
80 views::GridLayout::LEADING); 82 views::GridLayout::LEADING);
83 messages_.push_back(message);
84 size_t bullet = 0;
85 int bullet_string_id = GetBulletText(bullet);
86
87 while (bullet_string_id) {
88 // TODO(wfh) add bullet here.
sky 2017/05/14 13:46:16 Optional: generally chrome code has a ':' after th
Will Harris 2017/05/17 18:25:19 I'm not even sure what the TODO means, I think thi
89 base::string16 bullet_string = l10n_util::GetStringUTF16(bullet_string_id);
90 bullet_string = L" \u2022 " + bullet_string;
91 message = new views::Label(bullet_string);
sky 2017/05/14 13:46:16 The way you have this now, if a line wraps the tex
Will Harris 2017/05/17 18:25:19 hmm I found however I resized the window I was not
sky 2017/05/17 19:11:41 I would rather see you do it correctly than kick t
92
93 message->SetMultiLine(true);
94 message->SetEnabled(false);
95 message->SetHorizontalAlignment(gfx::ALIGN_LEFT);
96 message->SetLineHeight(views::kPanelSubVerticalSpacing);
97
98 layout->StartRowWithPadding(0, column_set_id, 0, kBulletBottomSpacing);
99 layout->AddView(message, 2, 1, views::GridLayout::LEADING,
100 views::GridLayout::LEADING);
101 messages_.push_back(message);
102 bullet++;
103 bullet_string_id = GetBulletText(bullet);
104 }
81 105
82 action_button_ = views::MdTextButton::CreateSecondaryUiBlueButton( 106 action_button_ = views::MdTextButton::CreateSecondaryUiBlueButton(
83 this, l10n_util::GetStringUTF16(GetButtonTitle())); 107 this, l10n_util::GetStringUTF16(GetButtonTitle()));
84 help_link_ = new views::Link(l10n_util::GetStringUTF16(GetHelpLinkTitle())); 108 help_link_ = new views::Link(l10n_util::GetStringUTF16(GetHelpLinkTitle()));
85 help_link_->set_listener(this); 109 help_link_->set_listener(this);
86 layout->StartRowWithPadding(0, column_set_id, 0, 110 layout->StartRowWithPadding(0, column_set_id, 0,
87 views::kPanelVerticalSpacing); 111 views::kPanelVerticalSpacing);
88 layout->AddView(help_link_, 1, 1, views::GridLayout::LEADING, 112 layout->AddView(help_link_, 1, 1, views::GridLayout::LEADING,
89 views::GridLayout::CENTER); 113 views::GridLayout::CENTER);
90 layout->AddView(action_button_, 1, 1, views::GridLayout::TRAILING, 114 layout->AddView(action_button_, 1, 1, views::GridLayout::TRAILING,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 void SadTabView::ButtonPressed(views::Button* sender, 148 void SadTabView::ButtonPressed(views::Button* sender,
125 const ui::Event& event) { 149 const ui::Event& event) {
126 DCHECK_EQ(action_button_, sender); 150 DCHECK_EQ(action_button_, sender);
127 PerformAction(Action::BUTTON); 151 PerformAction(Action::BUTTON);
128 } 152 }
129 153
130 void SadTabView::Layout() { 154 void SadTabView::Layout() {
131 // Specify the maximum message width explicitly. 155 // Specify the maximum message width explicitly.
132 const int max_width = 156 const int max_width =
133 std::min(width() - views::kPanelSubVerticalSpacing * 2, kMaxContentWidth); 157 std::min(width() - views::kPanelSubVerticalSpacing * 2, kMaxContentWidth);
134 message_->SizeToFit(max_width); 158 for (auto* message : messages_) {
sky 2017/05/14 13:46:16 no {}. optional: auto* -> view::Label* for clarity
Will Harris 2017/05/17 18:25:19 Done.
159 message->SizeToFit(max_width);
160 }
135 title_->SizeToFit(max_width); 161 title_->SizeToFit(max_width);
136 162
137 View::Layout(); 163 View::Layout();
138 } 164 }
139 165
140 void SadTabView::OnPaint(gfx::Canvas* canvas) { 166 void SadTabView::OnPaint(gfx::Canvas* canvas) {
141 if (!painted_) { 167 if (!painted_) {
142 RecordFirstPaint(); 168 RecordFirstPaint();
143 painted_ = true; 169 painted_ = true;
144 } 170 }
145 View::OnPaint(canvas); 171 View::OnPaint(canvas);
146 } 172 }
147 173
148 namespace chrome { 174 namespace chrome {
149 175
150 SadTab* SadTab::Create(content::WebContents* web_contents, 176 SadTab* SadTab::Create(content::WebContents* web_contents,
151 SadTabKind kind) { 177 SadTabKind kind) {
152 return new SadTabView(web_contents, kind); 178 return new SadTabView(web_contents, kind);
153 } 179 }
154 180
155 } // namespace chrome 181 } // namespace chrome
OLDNEW
« chrome/browser/ui/views/sad_tab_view.h ('K') | « chrome/browser/ui/views/sad_tab_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698