Commit d8fcc86c authored by Yicheng Li's avatar Yicheng Li Committed by Commit Bot

ash: Adjust cancel button style for in-session auth dialog

The cancel button was added back due to privacy team's concern. UI
reviewers requested swapping the positions of the help button and
the cancel button, and adding button style to the cancel button.
Screenshot of this implementation has received a LGTM on UI review
thread.

Bug: b:156258540, b:144861739
Change-Id: I60d0bd83e305e2c737fad01cce67ee2c7b563cb2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2531014
Commit-Queue: Yicheng Li <yichengli@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826957}
parent bf5255d2
...@@ -540,27 +540,26 @@ void AuthDialogContentsView::AddActionButtonsView() { ...@@ -540,27 +540,26 @@ void AuthDialogContentsView::AddActionButtonsView() {
buttons_layout->set_main_axis_alignment( buttons_layout->set_main_axis_alignment(
views::BoxLayout::MainAxisAlignment::kStart); views::BoxLayout::MainAxisAlignment::kStart);
cancel_button_ = help_button_ =
action_view_container_->AddChildView(std::make_unique<views::LabelButton>( action_view_container_->AddChildView(std::make_unique<views::LabelButton>(
base::BindRepeating(&AuthDialogContentsView::OnCancelButtonPressed, base::BindRepeating(&AuthDialogContentsView::OnNeedHelpButtonPressed,
base::Unretained(this)), base::Unretained(this)),
l10n_util::GetStringUTF16(IDS_ASH_IN_SESSION_AUTH_CANCEL), l10n_util::GetStringUTF16(IDS_ASH_IN_SESSION_AUTH_HELP),
views::style::CONTEXT_BUTTON)); views::style::CONTEXT_BUTTON));
cancel_button_->SetEnabledTextColors(kTextColorPrimary); help_button_->SetEnabledTextColors(kTextColorPrimary);
auto* spacing = action_view_container_->AddChildView( auto* spacing = action_view_container_->AddChildView(
std::make_unique<NonAccessibleView>()); std::make_unique<NonAccessibleView>());
buttons_layout->SetFlexForView(spacing, 1); buttons_layout->SetFlexForView(spacing, 1);
help_button_ = cancel_button_ = action_view_container_->AddChildView(
action_view_container_->AddChildView(std::make_unique<views::LabelButton>( std::make_unique<views::MdTextButton>(
base::BindRepeating(&AuthDialogContentsView::OnNeedHelpButtonPressed, base::BindRepeating(&AuthDialogContentsView::OnCancelButtonPressed,
base::Unretained(this)), base::Unretained(this)),
l10n_util::GetStringUTF16(IDS_ASH_IN_SESSION_AUTH_HELP), l10n_util::GetStringUTF16(IDS_ASH_IN_SESSION_AUTH_CANCEL)));
views::style::CONTEXT_BUTTON));
help_button_->SetEnabledTextColors(kTextColorPrimary);
action_view_container_->SetPreferredSize( action_view_container_->SetPreferredSize(
gfx::Size(kContainerPreferredWidth, help_button_->height())); gfx::Size(kContainerPreferredWidth, cancel_button_->height()));
} }
void AuthDialogContentsView::OnCancelButtonPressed(const ui::Event& event) { void AuthDialogContentsView::OnCancelButtonPressed(const ui::Event& event) {
...@@ -629,4 +628,16 @@ void AuthDialogContentsView::GetAccessibleNodeData(ui::AXNodeData* node_data) { ...@@ -629,4 +628,16 @@ void AuthDialogContentsView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
base::UTF8ToUTF16(origin_name_))); base::UTF8ToUTF16(origin_name_)));
} }
void AuthDialogContentsView::RequestFocus() {
if (auth_methods_ == kAuthFingerprint) {
// There's no PIN input field, so let the focus be on the cancel button
// (instead of the help button) because it is more often used.
cancel_button_->RequestFocus();
return;
}
// For other cases, the base method correctly sets focus to the input field.
views::View::RequestFocus();
}
} // namespace ash } // namespace ash
...@@ -15,6 +15,7 @@ namespace views { ...@@ -15,6 +15,7 @@ namespace views {
class BoxLayout; class BoxLayout;
class Label; class Label;
class LabelButton; class LabelButton;
class MdTextButton;
} // namespace views } // namespace views
namespace ash { namespace ash {
...@@ -52,6 +53,7 @@ class AuthDialogContentsView : public views::View { ...@@ -52,6 +53,7 @@ class AuthDialogContentsView : public views::View {
// views::Views: // views::Views:
void GetAccessibleNodeData(ui::AXNodeData* node_data) override; void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
void RequestFocus() override;
uint32_t auth_methods() const { return auth_methods_; } uint32_t auth_methods() const { return auth_methods_; }
...@@ -152,7 +154,7 @@ class AuthDialogContentsView : public views::View { ...@@ -152,7 +154,7 @@ class AuthDialogContentsView : public views::View {
FingerprintView* fingerprint_view_ = nullptr; FingerprintView* fingerprint_view_ = nullptr;
// A button to cancel authentication and close the dialog. // A button to cancel authentication and close the dialog.
views::LabelButton* cancel_button_ = nullptr; views::MdTextButton* cancel_button_ = nullptr;
// A button to show a help center article. // A button to show a help center article.
views::LabelButton* help_button_ = nullptr; views::LabelButton* help_button_ = nullptr;
......
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