Commit 1ee769ef authored by yiyaoliu's avatar yiyaoliu Committed by Commit bot

Align the checkbox with the first line of the text.

BUG=293702

Review URL: https://codereview.chromium.org/469653002

Cr-Commit-Position: refs/heads/master@{#292391}
parent cbe4516d
...@@ -152,7 +152,7 @@ void SessionCrashedBubbleView::Show(Browser* browser) { ...@@ -152,7 +152,7 @@ void SessionCrashedBubbleView::Show(Browser* browser) {
void SessionCrashedBubbleView::ShowForReal( void SessionCrashedBubbleView::ShowForReal(
scoped_ptr<BrowserRemovalObserver> browser_observer, scoped_ptr<BrowserRemovalObserver> browser_observer,
bool uma_opted_in_already) { bool uma_opted_in_already) {
// Determine whether or not the uma opt-in option should be offered. It is // Determine whether or not the UMA opt-in option should be offered. It is
// offered only when it is a Google chrome build, user hasn't opted in yet, // offered only when it is a Google chrome build, user hasn't opted in yet,
// and the preference is modifiable by the user. // and the preference is modifiable by the user.
bool offer_uma_optin = false; bool offer_uma_optin = false;
...@@ -281,25 +281,38 @@ void SessionCrashedBubbleView::Init() { ...@@ -281,25 +281,38 @@ void SessionCrashedBubbleView::Init() {
layout->AddView(restore_button_); layout->AddView(restore_button_);
layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
int bottom_margin = 1;
// Metrics reporting option. // Metrics reporting option.
if (offer_uma_optin_) { if (offer_uma_optin_) {
CreateUmaOptinView(layout); const int kUMAOptionColumnSetId = 2;
cs = layout->AddColumnSet(kUMAOptionColumnSetId);
cs->AddColumn(
GridLayout::FILL, GridLayout::FILL, 1, GridLayout::USE_PREF, 0, 0);
layout->StartRow(1, kUMAOptionColumnSetId);
layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
layout->StartRow(1, kUMAOptionColumnSetId);
layout->AddView(CreateUMAOptinView());
// Since the UMA optin row has a different background than the default
// background color of bubbles, the bottom margin has to be 0 to make sure
// the background extends to the bottom edge of the bubble.
bottom_margin = 0;
RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_OPTIN_BAR_SHOWN); RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_OPTIN_BAR_SHOWN);
} }
set_margins(gfx::Insets()); set_margins(gfx::Insets(1, 0, bottom_margin, 0));
Layout(); Layout();
} }
void SessionCrashedBubbleView::CreateUmaOptinView(GridLayout* layout) { views::View* SessionCrashedBubbleView::CreateUMAOptinView() {
// Checkbox for metric reporting setting. // Checkbox for metric reporting setting.
// Since the text to the right of the checkbox can't be a simple string (needs // Since the text to the right of the checkbox can't be a simple string (needs
// a hyperlink in it), this checkbox contains an empty string as its label, // a hyperlink in it), this checkbox contains an empty string as its label,
// and the real text will be added as a separate view. // and the real text will be added as a separate view.
uma_option_ = new views::Checkbox(base::string16()); uma_option_ = new views::Checkbox(base::string16());
uma_option_->SetChecked(false); uma_option_->SetChecked(false);
uma_option_->set_background(
views::Background::CreateSolidBackground(kBackgroundColor));
// The text to the right of the checkbox. // The text to the right of the checkbox.
size_t offset; size_t offset;
...@@ -310,8 +323,6 @@ void SessionCrashedBubbleView::CreateUmaOptinView(GridLayout* layout) { ...@@ -310,8 +323,6 @@ void SessionCrashedBubbleView::CreateUmaOptinView(GridLayout* layout) {
link_text, link_text,
&offset); &offset);
views::StyledLabel* uma_label = new views::StyledLabel(uma_text, this); views::StyledLabel* uma_label = new views::StyledLabel(uma_text, this);
uma_label->set_background(
views::Background::CreateSolidBackground(kBackgroundColor));
views::StyledLabel::RangeStyleInfo link_style = views::StyledLabel::RangeStyleInfo link_style =
views::StyledLabel::RangeStyleInfo::CreateForLink(); views::StyledLabel::RangeStyleInfo::CreateForLink();
link_style.font_style = gfx::Font::NORMAL; link_style.font_style = gfx::Font::NORMAL;
...@@ -326,35 +337,30 @@ void SessionCrashedBubbleView::CreateUmaOptinView(GridLayout* layout) { ...@@ -326,35 +337,30 @@ void SessionCrashedBubbleView::CreateUmaOptinView(GridLayout* layout) {
if (!after_link_range.is_empty()) if (!after_link_range.is_empty())
uma_label->AddStyleRange(after_link_range, uma_style); uma_label->AddStyleRange(after_link_range, uma_style);
// We use a border instead of padding so that the background color reaches // Create a view to hold the checkbox and the text.
// the edges of the bubble. views::View* uma_view = new views::View();
const gfx::Insets title_insets = GetBubbleFrameView()->GetTitleInsets(); GridLayout* uma_layout = new GridLayout(uma_view);
uma_option_->SetBorder(views::Border::CreateSolidSidedBorder( uma_view->SetLayoutManager(uma_layout);
0, title_insets.left(), 0, 0, kBackgroundColor));
uma_label->SetBorder(views::Border::CreateSolidSidedBorder( uma_view->set_background(
views::kRelatedControlVerticalSpacing, kCheckboxTextDistance, views::Background::CreateSolidBackground(kBackgroundColor));
views::kRelatedControlVerticalSpacing, title_insets.left(), int inset_left = GetBubbleFrameView()->GetTitleInsets().left();
kBackgroundColor)); uma_layout->SetInsets(views::kRelatedControlVerticalSpacing, inset_left,
views::kRelatedControlVerticalSpacing, inset_left);
// Separator.
const int kSeparatorColumnSetId = 2;
views::ColumnSet* cs = layout->AddColumnSet(kSeparatorColumnSetId);
cs->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
GridLayout::USE_PREF, 0, 0);
// Reporting row. const int kReportColumnSetId = 0;
const int kReportColumnSetId = 3; views::ColumnSet* cs = uma_layout->AddColumnSet(kReportColumnSetId);
cs = layout->AddColumnSet(kReportColumnSetId); cs->AddColumn(GridLayout::CENTER, GridLayout::LEADING, 0,
cs->AddColumn(GridLayout::CENTER, GridLayout::FILL, 0,
GridLayout::USE_PREF, 0, 0); GridLayout::USE_PREF, 0, 0);
cs->AddPaddingColumn(0, kCheckboxTextDistance);
cs->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, cs->AddColumn(GridLayout::FILL, GridLayout::FILL, 0,
GridLayout::FIXED, kWidthOfDescriptionText, 0); GridLayout::FIXED, kWidthOfDescriptionText, 0);
layout->StartRow(0, kSeparatorColumnSetId); uma_layout->StartRow(0, kReportColumnSetId);
layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); uma_layout->AddView(uma_option_);
layout->StartRow(0, kReportColumnSetId); uma_layout->AddView(uma_label);
layout->AddView(uma_option_);
layout->AddView(uma_label); return uma_view;
} }
void SessionCrashedBubbleView::ButtonPressed(views::Button* sender, void SessionCrashedBubbleView::ButtonPressed(views::Button* sender,
......
...@@ -98,8 +98,8 @@ class SessionCrashedBubbleView ...@@ -98,8 +98,8 @@ class SessionCrashedBubbleView
content::WebContents* contents, content::WebContents* contents,
int index) OVERRIDE; int index) OVERRIDE;
// Create the view for user to opt in to Uma. // Create the view for the user to opt in to UMA.
void CreateUmaOptinView(views::GridLayout* layout); views::View* CreateUMAOptinView();
// Restore previous session after user selects so. // Restore previous session after user selects so.
void RestorePreviousSession(views::Button* sender); void RestorePreviousSession(views::Button* sender);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment