Commit 38ab97cd authored by glevin's avatar glevin Committed by Commit Bot

Harmonize RequestPinView dialog

As per crbug.com/788024 Comment 1 (see mocks):
- Fix error box style
- Dialog width = 448
- Input box width = 200, left aligned
- Additionally: add SPACE between "Invalid PIN" & "Attempts left"

Harmonious nature of the pin-requestin' dialog.

Bug: 788024
Test: Get yourself into some kinda pin-needin' situation and confirm the
Change-Id: Ie573c8a79fdb2001a3c2b66adc4b80a4b09dd723
Reviewed-on: https://chromium-review.googlesource.com/1013412
Commit-Queue: Greg Levin <glevin@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#554472}
parent fc07a87c
...@@ -24,6 +24,16 @@ ...@@ -24,6 +24,16 @@
namespace chromeos { namespace chromeos {
namespace {
// Default width of the dialog.
constexpr int kDefaultWidth = 448;
// Default width of the text field.
constexpr int kDefaultTextWidth = 200;
} // namespace
RequestPinView::RequestPinView(const std::string& extension_name, RequestPinView::RequestPinView(const std::string& extension_name,
RequestPinView::RequestPinCodeType code_type, RequestPinView::RequestPinCodeType code_type,
int attempts_left, int attempts_left,
...@@ -116,6 +126,12 @@ bool RequestPinView::IsDialogButtonEnabled(ui::DialogButton button) const { ...@@ -116,6 +126,12 @@ bool RequestPinView::IsDialogButtonEnabled(ui::DialogButton button) const {
return true; return true;
} }
gfx::Size RequestPinView::CalculatePreferredSize() const {
return gfx::Size(
kDefaultWidth,
GetLayoutManager()->GetPreferredHeightForWidth(this, kDefaultWidth));
}
bool RequestPinView::IsLocked() { bool RequestPinView::IsLocked() {
return callback_.is_null(); return callback_.is_null();
} }
...@@ -197,7 +213,8 @@ void RequestPinView::Init() { ...@@ -197,7 +213,8 @@ void RequestPinView::Init() {
textfield_->set_controller(this); textfield_->set_controller(this);
textfield_->SetEnabled(true); textfield_->SetEnabled(true);
textfield_->SetAssociatedLabel(header_label_); textfield_->SetAssociatedLabel(header_label_);
layout->AddView(textfield_); layout->AddView(textfield_, 1, 1, views::GridLayout::LEADING,
views::GridLayout::FILL, kDefaultTextWidth, 0);
layout->AddPaddingRow(0, related_vertical_spacing); layout->AddPaddingRow(0, related_vertical_spacing);
...@@ -248,12 +265,15 @@ void RequestPinView::SetErrorMessage(RequestPinErrorType error_type, ...@@ -248,12 +265,15 @@ void RequestPinView::SetErrorMessage(RequestPinErrorType error_type,
case RequestPinErrorType::NONE: case RequestPinErrorType::NONE:
if (attempts_left < 0) { if (attempts_left < 0) {
error_label_->SetVisible(false); error_label_->SetVisible(false);
textfield_->SetInvalid(false);
return; return;
} }
break; break;
} }
if (attempts_left >= 0) { if (attempts_left >= 0) {
if (!error_message.empty())
error_message.append(base::ASCIIToUTF16(" "));
error_message.append(l10n_util::GetStringFUTF16( error_message.append(l10n_util::GetStringFUTF16(
IDS_REQUEST_PIN_DIALOG_ATTEMPTS_LEFT, IDS_REQUEST_PIN_DIALOG_ATTEMPTS_LEFT,
base::ASCIIToUTF16(std::to_string(attempts_left)))); base::ASCIIToUTF16(std::to_string(attempts_left))));
...@@ -264,6 +284,7 @@ void RequestPinView::SetErrorMessage(RequestPinErrorType error_type, ...@@ -264,6 +284,7 @@ void RequestPinView::SetErrorMessage(RequestPinErrorType error_type,
error_label_->SetTooltipText(error_message); error_label_->SetTooltipText(error_message);
error_label_->SetEnabledColor(SK_ColorRED); error_label_->SetEnabledColor(SK_ColorRED);
error_label_->SizeToPreferredSize(); error_label_->SizeToPreferredSize();
textfield_->SetInvalid(true);
} }
} // namespace chromeos } // namespace chromeos
...@@ -82,6 +82,9 @@ class RequestPinView : public views::DialogDelegateView, ...@@ -82,6 +82,9 @@ class RequestPinView : public views::DialogDelegateView,
views::View* GetInitiallyFocusedView() override; views::View* GetInitiallyFocusedView() override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override; bool IsDialogButtonEnabled(ui::DialogButton button) const override;
// views::View
gfx::Size CalculatePreferredSize() const override;
// Returns whether the view is locked while waiting the extension to process // Returns whether the view is locked while waiting the extension to process
// the user input data. // the user input data.
bool IsLocked(); bool IsLocked();
......
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