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

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

Issue 2794763002: New Sad Tab strings. (Closed)
Patch Set: add bullets Created 3 years, 8 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
« no previous file with comments | « chrome/browser/ui/views/sad_tab_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 13 matching lines...) Expand all
24 #include "ui/views/controls/link.h" 24 #include "ui/views/controls/link.h"
25 #include "ui/views/layout/grid_layout.h" 25 #include "ui/views/layout/grid_layout.h"
26 #include "ui/views/layout/layout_constants.h" 26 #include "ui/views/layout/layout_constants.h"
27 #include "ui/views/widget/widget.h" 27 #include "ui/views/widget/widget.h"
28 28
29 namespace { 29 namespace {
30 30
31 constexpr int kMaxContentWidth = 600; 31 constexpr int kMaxContentWidth = 600;
32 constexpr int kMinColumnWidth = 120; 32 constexpr int kMinColumnWidth = 120;
33 constexpr int kTitleBottomSpacing = 13; 33 constexpr int kTitleBottomSpacing = 13;
34 constexpr int kBulletBottomSpacing = 3;
34 35
35 } // namespace 36 } // namespace
36 37
37 SadTabView::SadTabView(content::WebContents* web_contents, 38 SadTabView::SadTabView(content::WebContents* web_contents,
38 chrome::SadTabKind kind) 39 chrome::SadTabKind kind)
39 : SadTab(web_contents, kind) { 40 : SadTab(web_contents, kind) {
40 // Set the background color. 41 // Set the background color.
41 set_background( 42 set_background(
42 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( 43 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor(
43 ui::NativeTheme::kColorId_DialogBackground))); 44 ui::NativeTheme::kColorId_DialogBackground)));
(...skipping 23 matching lines...) Expand all
67 title_->SetFontList(rb.GetFontList(ui::ResourceBundle::LargeFont)); 68 title_->SetFontList(rb.GetFontList(ui::ResourceBundle::LargeFont));
68 title_->SetMultiLine(true); 69 title_->SetMultiLine(true);
69 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 70 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
70 layout->StartRowWithPadding(0, column_set_id, 0, 71 layout->StartRowWithPadding(0, column_set_id, 0,
71 views::kPanelVerticalSpacing); 72 views::kPanelVerticalSpacing);
72 layout->AddView(title_, 2, 1); 73 layout->AddView(title_, 2, 1);
73 74
74 const SkColor text_color = GetNativeTheme()->GetSystemColor( 75 const SkColor text_color = GetNativeTheme()->GetSystemColor(
75 ui::NativeTheme::kColorId_LabelDisabledColor); 76 ui::NativeTheme::kColorId_LabelDisabledColor);
76 77
77 message_ = CreateLabel(l10n_util::GetStringUTF16(GetMessage())); 78 views::Label* message = CreateLabel(l10n_util::GetStringUTF16(GetMessage()));
78 79
79 message_->SetMultiLine(true); 80 message->SetMultiLine(true);
80 message_->SetEnabledColor(text_color); 81 message->SetEnabledColor(text_color);
81 message_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 82 message->SetHorizontalAlignment(gfx::ALIGN_LEFT);
82 message_->SetLineHeight(views::kPanelSubVerticalSpacing); 83 message->SetLineHeight(views::kPanelSubVerticalSpacing);
83 84
84 layout->StartRowWithPadding(0, column_set_id, 0, kTitleBottomSpacing); 85 layout->StartRowWithPadding(0, column_set_id, 0, kTitleBottomSpacing);
85 layout->AddView(message_, 2, 1, views::GridLayout::LEADING, 86 layout->AddView(message, 2, 1, views::GridLayout::LEADING,
86 views::GridLayout::LEADING); 87 views::GridLayout::LEADING);
88 messages_.push_back(message);
89 size_t bullet = 0;
90 int bullet_string_id = GetBulletText(bullet);
91
92 while (bullet_string_id) {
93 // TODO(wfh) add bullet here.
94 base::string16 bullet_string = l10n_util::GetStringUTF16(bullet_string_id);
95 bullet_string = L" \u2022 " + bullet_string;
Will Harris 2017/04/03 19:49:19 I don't know how to do indents here.
kylix_rd 2017/04/04 20:59:07 Did you try setting the indent padding in layout->
Will Harris 2017/04/05 20:01:06 which parameter is the indent padding? I saw only
kylix_rd 2017/04/07 15:47:23 Ah, ok. I thought there was an option for indentin
96 message = CreateLabel(bullet_string);
Will Harris 2017/04/03 19:49:19 I'm assuming something owns and frees the memory t
kylix_rd 2017/04/04 20:59:07 The view is "owned" by the SadTabView instance by
Will Harris 2017/04/05 20:01:06 "its" refers to the layout? I think the call to S
kylix_rd 2017/04/07 15:47:23 The layout manager will add the view to the view o
97
98 message->SetMultiLine(true);
99 message->SetEnabledColor(text_color);
100 message->SetHorizontalAlignment(gfx::ALIGN_LEFT);
101 message->SetLineHeight(views::kPanelSubVerticalSpacing);
102
103 layout->StartRowWithPadding(0, column_set_id, 0, kBulletBottomSpacing);
104 layout->AddView(message, 2, 1, views::GridLayout::LEADING,
105 views::GridLayout::LEADING);
106 messages_.push_back(message);
107 bullet++;
108 bullet_string_id = GetBulletText(bullet);
109 }
87 110
88 action_button_ = views::MdTextButton::CreateSecondaryUiBlueButton( 111 action_button_ = views::MdTextButton::CreateSecondaryUiBlueButton(
89 this, l10n_util::GetStringUTF16(GetButtonTitle())); 112 this, l10n_util::GetStringUTF16(GetButtonTitle()));
90 help_link_ = 113 help_link_ =
91 CreateLink(l10n_util::GetStringUTF16(GetHelpLinkTitle()), text_color); 114 CreateLink(l10n_util::GetStringUTF16(GetHelpLinkTitle()), text_color);
92 layout->StartRowWithPadding(0, column_set_id, 0, 115 layout->StartRowWithPadding(0, column_set_id, 0,
93 views::kPanelVerticalSpacing); 116 views::kPanelVerticalSpacing);
94 layout->AddView(help_link_, 1, 1, views::GridLayout::LEADING, 117 layout->AddView(help_link_, 1, 1, views::GridLayout::LEADING,
95 views::GridLayout::CENTER); 118 views::GridLayout::CENTER);
96 layout->AddView(action_button_, 1, 1, views::GridLayout::TRAILING, 119 layout->AddView(action_button_, 1, 1, views::GridLayout::TRAILING,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 void SadTabView::ButtonPressed(views::Button* sender, 153 void SadTabView::ButtonPressed(views::Button* sender,
131 const ui::Event& event) { 154 const ui::Event& event) {
132 DCHECK_EQ(action_button_, sender); 155 DCHECK_EQ(action_button_, sender);
133 PerformAction(Action::BUTTON); 156 PerformAction(Action::BUTTON);
134 } 157 }
135 158
136 void SadTabView::Layout() { 159 void SadTabView::Layout() {
137 // Specify the maximum message width explicitly. 160 // Specify the maximum message width explicitly.
138 const int max_width = 161 const int max_width =
139 std::min(width() - views::kPanelSubVerticalSpacing * 2, kMaxContentWidth); 162 std::min(width() - views::kPanelSubVerticalSpacing * 2, kMaxContentWidth);
140 message_->SizeToFit(max_width); 163 for (auto* message : messages_) {
164 message->SizeToFit(max_width);
165 }
141 title_->SizeToFit(max_width); 166 title_->SizeToFit(max_width);
142 167
143 View::Layout(); 168 View::Layout();
144 } 169 }
145 170
146 void SadTabView::OnPaint(gfx::Canvas* canvas) { 171 void SadTabView::OnPaint(gfx::Canvas* canvas) {
147 if (!painted_) { 172 if (!painted_) {
148 RecordFirstPaint(); 173 RecordFirstPaint();
149 painted_ = true; 174 painted_ = true;
150 } 175 }
(...skipping 16 matching lines...) Expand all
167 } 192 }
168 193
169 namespace chrome { 194 namespace chrome {
170 195
171 SadTab* SadTab::Create(content::WebContents* web_contents, 196 SadTab* SadTab::Create(content::WebContents* web_contents,
172 SadTabKind kind) { 197 SadTabKind kind) {
173 return new SadTabView(web_contents, kind); 198 return new SadTabView(web_contents, kind);
174 } 199 }
175 200
176 } // namespace chrome 201 } // namespace chrome
OLDNEW
« no previous file with comments | « 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