Commit 243c4f41 authored by glevin's avatar glevin Committed by Commit Bot

Harmonize RequestPinView dialog - Part II

As per crbug.com/788024 Comment 10 and other observations:
- Make error text darker (#D93025)
- Dialog width = 448 (for reals this time)
- Remove X (Close) button from upper right

Bug: 788024
Test: Get yourself into some kinda pin-needin' situation and confirm the
Harmonious nature of the pin-requestin' dialog.

Change-Id: I7da3bffa3ff91434f651dd316a245cdf8d3f91a1
Reviewed-on: https://chromium-review.googlesource.com/1118609Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Commit-Queue: Greg Levin <glevin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574961}
parent c2661625
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/gfx/color_palette.h"
#include "ui/views/controls/label.h" #include "ui/views/controls/label.h"
#include "ui/views/controls/textfield/textfield.h" #include "ui/views/controls/textfield/textfield.h"
#include "ui/views/layout/grid_layout.h" #include "ui/views/layout/grid_layout.h"
...@@ -26,9 +27,6 @@ namespace chromeos { ...@@ -26,9 +27,6 @@ namespace chromeos {
namespace { namespace {
// Default width of the dialog.
constexpr int kDefaultWidth = 448;
// Default width of the text field. // Default width of the text field.
constexpr int kDefaultTextWidth = 200; constexpr int kDefaultTextWidth = 200;
...@@ -95,14 +93,6 @@ bool RequestPinView::Accept() { ...@@ -95,14 +93,6 @@ bool RequestPinView::Accept() {
return false; return false;
} }
base::string16 RequestPinView::GetWindowTitle() const {
return window_title_;
}
views::View* RequestPinView::GetInitiallyFocusedView() {
return textfield_;
}
bool RequestPinView::IsDialogButtonEnabled(ui::DialogButton button) const { bool RequestPinView::IsDialogButtonEnabled(ui::DialogButton button) const {
switch (button) { switch (button) {
case ui::DialogButton::DIALOG_BUTTON_CANCEL: case ui::DialogButton::DIALOG_BUTTON_CANCEL:
...@@ -126,10 +116,22 @@ bool RequestPinView::IsDialogButtonEnabled(ui::DialogButton button) const { ...@@ -126,10 +116,22 @@ bool RequestPinView::IsDialogButtonEnabled(ui::DialogButton button) const {
return true; return true;
} }
views::View* RequestPinView::GetInitiallyFocusedView() {
return textfield_;
}
base::string16 RequestPinView::GetWindowTitle() const {
return window_title_;
}
bool RequestPinView::ShouldShowCloseButton() const {
return false;
}
gfx::Size RequestPinView::CalculatePreferredSize() const { gfx::Size RequestPinView::CalculatePreferredSize() const {
return gfx::Size( int default_width = views::LayoutProvider::Get()->GetDistanceMetric(
kDefaultWidth, DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH);
GetLayoutManager()->GetPreferredHeightForWidth(this, kDefaultWidth)); return gfx::Size(default_width, GetHeightForWidth(default_width));
} }
bool RequestPinView::IsLocked() { bool RequestPinView::IsLocked() {
...@@ -177,8 +179,9 @@ void RequestPinView::UpdateHeaderText() { ...@@ -177,8 +179,9 @@ void RequestPinView::UpdateHeaderText() {
} }
void RequestPinView::Init() { void RequestPinView::Init() {
set_margins(ChromeLayoutProvider::Get()->GetDialogInsetsForContentType( const views::LayoutProvider* provider = views::LayoutProvider::Get();
views::TEXT, views::TEXT)); SetBorder(views::CreateEmptyBorder(
provider->GetDialogInsetsForContentType(views::TEXT, views::TEXT)));
views::GridLayout* layout = views::GridLayout* layout =
SetLayoutManager(std::make_unique<views::GridLayout>(this)); SetLayoutManager(std::make_unique<views::GridLayout>(this));
...@@ -198,8 +201,7 @@ void RequestPinView::Init() { ...@@ -198,8 +201,7 @@ void RequestPinView::Init() {
layout->AddView(header_label_); layout->AddView(header_label_);
const int related_vertical_spacing = const int related_vertical_spacing =
ChromeLayoutProvider::Get()->GetDistanceMetric( provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL);
views::DISTANCE_RELATED_CONTROL_VERTICAL);
layout->AddPaddingRow(0, related_vertical_spacing); layout->AddPaddingRow(0, related_vertical_spacing);
column_view_set_id++; column_view_set_id++;
...@@ -282,7 +284,7 @@ void RequestPinView::SetErrorMessage(RequestPinErrorType error_type, ...@@ -282,7 +284,7 @@ void RequestPinView::SetErrorMessage(RequestPinErrorType error_type,
error_label_->SetVisible(true); error_label_->SetVisible(true);
error_label_->SetText(error_message); error_label_->SetText(error_message);
error_label_->SetTooltipText(error_message); error_label_->SetTooltipText(error_message);
error_label_->SetEnabledColor(SK_ColorRED); error_label_->SetEnabledColor(gfx::kGoogleRed600);
error_label_->SizeToPreferredSize(); error_label_->SizeToPreferredSize();
textfield_->SetInvalid(true); textfield_->SetInvalid(true);
} }
......
...@@ -75,12 +75,13 @@ class RequestPinView : public views::DialogDelegateView, ...@@ -75,12 +75,13 @@ class RequestPinView : public views::DialogDelegateView,
void ContentsChanged(views::Textfield* sender, void ContentsChanged(views::Textfield* sender,
const base::string16& new_contents) override; const base::string16& new_contents) override;
// views::DialogDelegateView // views::DialogDelegate
bool Cancel() override; bool Cancel() override;
bool Accept() override; bool Accept() override;
base::string16 GetWindowTitle() const override;
views::View* GetInitiallyFocusedView() override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override; bool IsDialogButtonEnabled(ui::DialogButton button) const override;
views::View* GetInitiallyFocusedView() override;
base::string16 GetWindowTitle() const override;
bool ShouldShowCloseButton() const override;
// views::View // views::View
gfx::Size CalculatePreferredSize() const override; gfx::Size CalculatePreferredSize() const override;
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "third_party/boringssl/src/include/openssl/evp.h" #include "third_party/boringssl/src/include/openssl/evp.h"
#include "third_party/boringssl/src/include/openssl/mem.h" #include "third_party/boringssl/src/include/openssl/mem.h"
#include "third_party/boringssl/src/include/openssl/rsa.h" #include "third_party/boringssl/src/include/openssl/rsa.h"
#include "ui/gfx/color_palette.h"
#include "ui/views/controls/label.h" #include "ui/views/controls/label.h"
#include "ui/views/controls/textfield/textfield.h" #include "ui/views/controls/textfield/textfield.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
...@@ -140,7 +141,8 @@ void EnterWrongPin(chromeos::CertificateProviderService* service) { ...@@ -140,7 +141,8 @@ void EnterWrongPin(chromeos::CertificateProviderService* service) {
// Check that we have an error message displayed. // Check that we have an error message displayed.
chromeos::RequestPinView* view = chromeos::RequestPinView* view =
service->pin_dialog_manager()->active_view_for_testing(); service->pin_dialog_manager()->active_view_for_testing();
EXPECT_EQ(SK_ColorRED, view->error_label_for_testing()->enabled_color()); EXPECT_EQ(gfx::kGoogleRed600,
view->error_label_for_testing()->enabled_color());
} }
class CertificateProviderApiTest : public extensions::ExtensionApiTest { class CertificateProviderApiTest : public extensions::ExtensionApiTest {
......
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