Commit c4f85547 authored by Nicholas Verne's avatar Nicholas Verne Committed by Commit Bot

CrostiniInstallerView:: Change magic numbers to meaningful names.

Addresses comments from tapted after
https://chromium-review.googlesource.com/c/chromium/src/+/1114408 was submitted.

Bug: 848118
Change-Id: I66059b005de6ede632f81ec8fa6c9c103a892051
Reviewed-on: https://chromium-review.googlesource.com/1121937
Commit-Queue: Nicholas Verne <nverne@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572065}
parent 01219500
...@@ -125,6 +125,10 @@ bool CrostiniInstallerView::ShouldShowCloseButton() const { ...@@ -125,6 +125,10 @@ bool CrostiniInstallerView::ShouldShowCloseButton() const {
return false; return false;
} }
bool CrostiniInstallerView::ShouldShowWindowTitle() const {
return false;
}
bool CrostiniInstallerView::Accept() { bool CrostiniInstallerView::Accept() {
// This dialog can be accepted from State::ERROR. In that case, we're doing a // This dialog can be accepted from State::ERROR. In that case, we're doing a
// Retry. // Retry.
...@@ -239,11 +243,16 @@ CrostiniInstallerView* CrostiniInstallerView::GetActiveViewForTesting() { ...@@ -239,11 +243,16 @@ CrostiniInstallerView* CrostiniInstallerView::GetActiveViewForTesting() {
CrostiniInstallerView::CrostiniInstallerView(Profile* profile) CrostiniInstallerView::CrostiniInstallerView(Profile* profile)
: profile_(profile), weak_ptr_factory_(this) { : profile_(profile), weak_ptr_factory_(this) {
// Layout constants from the spec.
constexpr gfx::Insets kDialogInsets(60, 64, 32, 64);
constexpr int kDialogSpacingVertical = 32;
constexpr gfx::Size kLogoImageSize(32, 32);
SetLayoutManager(std::make_unique<views::BoxLayout>( SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::kVertical, gfx::Insets(60, 64, 32, 64), 32)); views::BoxLayout::kVertical, kDialogInsets, kDialogSpacingVertical));
logo_image_ = new views::ImageView(); logo_image_ = new views::ImageView();
logo_image_->SetImageSize(gfx::Size(32, 32)); logo_image_->SetImageSize(kLogoImageSize);
logo_image_->SetImage( logo_image_->SetImage(
ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
IDR_LOGO_CROSTINI_DEFAULT)); IDR_LOGO_CROSTINI_DEFAULT));
...@@ -257,7 +266,6 @@ CrostiniInstallerView::CrostiniInstallerView(Profile* profile) ...@@ -257,7 +266,6 @@ CrostiniInstallerView::CrostiniInstallerView(Profile* profile)
ash::AshTextContext::CONTEXT_HEADLINE_OVERSIZED); ash::AshTextContext::CONTEXT_HEADLINE_OVERSIZED);
big_message_label_->SetMultiLine(true); big_message_label_->SetMultiLine(true);
big_message_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); big_message_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
big_message_label_->SizeToFit(kOOBEWindowWidth);
AddChildView(big_message_label_); AddChildView(big_message_label_);
// TODO(timloh): Descenders in the message appear to be clipped, re-visit once // TODO(timloh): Descenders in the message appear to be clipped, re-visit once
...@@ -270,7 +278,6 @@ CrostiniInstallerView::CrostiniInstallerView(Profile* profile) ...@@ -270,7 +278,6 @@ CrostiniInstallerView::CrostiniInstallerView(Profile* profile)
message_label_ = new views::Label(message); message_label_ = new views::Label(message);
message_label_->SetMultiLine(true); message_label_->SetMultiLine(true);
message_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); message_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
message_label_->SizeToFit(kOOBEWindowWidth);
AddChildView(message_label_); AddChildView(message_label_);
// Make a slot for the progress bar, but it's not initially visible. // Make a slot for the progress bar, but it's not initially visible.
...@@ -308,6 +315,12 @@ void CrostiniInstallerView::HandleError(const base::string16& error_message, ...@@ -308,6 +315,12 @@ void CrostiniInstallerView::HandleError(const base::string16& error_message,
message_label_->SetText(error_message); message_label_->SetText(error_message);
SetBigMessageLabel(); SetBigMessageLabel();
progress_bar_->SetVisible(false); progress_bar_->SetVisible(false);
// Remove the buttons so they get recreated with correct color and
// highlighting. Without this it is possible for both buttons to be styled as
// default buttons.
delete GetDialogClientView()->ok_button();
delete GetDialogClientView()->cancel_button();
DialogModelChanged(); DialogModelChanged();
GetWidget()->GetRootView()->Layout(); GetWidget()->GetRootView()->Layout();
} }
......
...@@ -50,6 +50,7 @@ class CrostiniInstallerView ...@@ -50,6 +50,7 @@ class CrostiniInstallerView
int GetDialogButtons() const override; int GetDialogButtons() const override;
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
bool ShouldShowCloseButton() const override; bool ShouldShowCloseButton() const override;
bool ShouldShowWindowTitle() const override;
bool Accept() override; bool Accept() override;
bool Cancel() override; bool Cancel() override;
gfx::Size CalculatePreferredSize() const override; gfx::Size CalculatePreferredSize() const override;
......
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