Commit 24c87c68 authored by Peter Boström's avatar Peter Boström Committed by Commit Bot

Use set_fixed_width() in c/b/chromeos dialogs

Replaces CalculatePreferredSize() overrides. Change also replaces a few
DialogDelegate overrides with corresponding setters.

Bug: 1128500
Change-Id: If6a1048d0c3b560fa8bbfffed146ea982a75c502
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2485619Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818677}
parent c0f304bc
...@@ -116,6 +116,10 @@ PlatformVerificationDialog::PlatformVerificationDialog( ...@@ -116,6 +116,10 @@ PlatformVerificationDialog::PlatformVerificationDialog(
DialogDelegate::SetCloseCallback(base::BindOnce( DialogDelegate::SetCloseCallback(base::BindOnce(
run_callback, base::Unretained(this), CONSENT_RESPONSE_NONE)); run_callback, base::Unretained(this), CONSENT_RESPONSE_NONE));
SetModalType(ui::MODAL_TYPE_CHILD);
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
// Explanation string. // Explanation string.
auto label = std::make_unique<views::Label>(l10n_util::GetStringFUTF16( auto label = std::make_unique<views::Label>(l10n_util::GetStringFUTF16(
IDS_PLATFORM_VERIFICATION_DIALOG_HEADLINE, domain_)); IDS_PLATFORM_VERIFICATION_DIALOG_HEADLINE, domain_));
...@@ -125,18 +129,6 @@ PlatformVerificationDialog::PlatformVerificationDialog( ...@@ -125,18 +129,6 @@ PlatformVerificationDialog::PlatformVerificationDialog(
chrome::RecordDialogCreation(chrome::DialogIdentifier::PLATFORM_VERIFICATION); chrome::RecordDialogCreation(chrome::DialogIdentifier::PLATFORM_VERIFICATION);
} }
ui::ModalType PlatformVerificationDialog::GetModalType() const {
return ui::MODAL_TYPE_CHILD;
}
gfx::Size PlatformVerificationDialog::CalculatePreferredSize() const {
const int default_width = views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH);
return gfx::Size(
default_width,
GetLayoutManager()->GetPreferredHeightForWidth(this, default_width));
}
void PlatformVerificationDialog::ButtonPressed(views::Button* sender, void PlatformVerificationDialog::ButtonPressed(views::Button* sender,
const ui::Event& event) { const ui::Event& event) {
if (sender != learn_more_button_) if (sender != learn_more_button_)
......
...@@ -50,10 +50,6 @@ class PlatformVerificationDialog : public views::DialogDelegateView, ...@@ -50,10 +50,6 @@ class PlatformVerificationDialog : public views::DialogDelegateView,
const base::string16& domain, const base::string16& domain,
ConsentCallback callback); ConsentCallback callback);
// views::DialogDelegateView:
ui::ModalType GetModalType() const override;
gfx::Size CalculatePreferredSize() const override;
// views::ButtonListener: // views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override; void ButtonPressed(views::Button* sender, const ui::Event& event) override;
......
...@@ -66,6 +66,14 @@ EchoDialogView::EchoDialogView(EchoDialogListener* listener, ...@@ -66,6 +66,14 @@ EchoDialogView::EchoDialogView(EchoDialogListener* listener,
&EchoDialogListener::OnAccept, base::Unretained(listener_))); &EchoDialogListener::OnAccept, base::Unretained(listener_)));
DialogDelegate::SetCancelCallback(base::BindOnce( DialogDelegate::SetCancelCallback(base::BindOnce(
&EchoDialogListener::OnCancel, base::Unretained(listener_))); &EchoDialogListener::OnCancel, base::Unretained(listener_)));
DialogDelegate::SetShowTitle(false);
DialogDelegate::SetShowCloseButton(false);
DialogDelegate::SetModalType(ui::MODAL_TYPE_WINDOW);
DialogDelegate::set_fixed_width(
views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
} }
EchoDialogView::~EchoDialogView() = default; EchoDialogView::~EchoDialogView() = default;
...@@ -108,26 +116,6 @@ void EchoDialogView::InitForDisabledEcho() { ...@@ -108,26 +116,6 @@ void EchoDialogView::InitForDisabledEcho() {
SetBorderAndLabel(std::move(label), font_list); SetBorderAndLabel(std::move(label), font_list);
} }
ui::ModalType EchoDialogView::GetModalType() const {
return ui::MODAL_TYPE_WINDOW;
}
bool EchoDialogView::ShouldShowWindowTitle() const {
return false;
}
bool EchoDialogView::ShouldShowCloseButton() const {
return false;
}
gfx::Size EchoDialogView::CalculatePreferredSize() const {
const int default_width = views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH);
return gfx::Size(
default_width,
GetLayoutManager()->GetPreferredHeightForWidth(this, default_width));
}
void EchoDialogView::ButtonPressed(views::Button* sender, void EchoDialogView::ButtonPressed(views::Button* sender,
const ui::Event& event) { const ui::Event& event) {
DCHECK(sender == learn_more_button_); DCHECK(sender == learn_more_button_);
......
...@@ -60,12 +60,6 @@ class EchoDialogView : public views::DialogDelegateView, ...@@ -60,12 +60,6 @@ class EchoDialogView : public views::DialogDelegateView,
// The dialog will have only Cancel button. // The dialog will have only Cancel button.
void InitForDisabledEcho(); void InitForDisabledEcho();
// views::DialogDelegateView:
ui::ModalType GetModalType() const override;
bool ShouldShowWindowTitle() const override;
bool ShouldShowCloseButton() const override;
gfx::Size CalculatePreferredSize() const override;
// views::ButtonListener: // views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override; void ButtonPressed(views::Button* sender, const ui::Event& event) override;
......
...@@ -49,6 +49,10 @@ RequestPinView::RequestPinView( ...@@ -49,6 +49,10 @@ RequestPinView::RequestPinView(
SetDialogParameters(code_type, security_token_pin::ErrorLabel::kNone, SetDialogParameters(code_type, security_token_pin::ErrorLabel::kNone,
attempts_left, accept_input); attempts_left, accept_input);
chrome::RecordDialogCreation(chrome::DialogIdentifier::REQUEST_PIN); chrome::RecordDialogCreation(chrome::DialogIdentifier::REQUEST_PIN);
SetShowCloseButton(false);
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
} }
RequestPinView::~RequestPinView() { RequestPinView::~RequestPinView() {
...@@ -111,16 +115,6 @@ base::string16 RequestPinView::GetWindowTitle() const { ...@@ -111,16 +115,6 @@ base::string16 RequestPinView::GetWindowTitle() const {
return window_title_; return window_title_;
} }
bool RequestPinView::ShouldShowCloseButton() const {
return false;
}
gfx::Size RequestPinView::CalculatePreferredSize() const {
int default_width = views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH);
return gfx::Size(default_width, GetHeightForWidth(default_width));
}
void RequestPinView::SetDialogParameters( void RequestPinView::SetDialogParameters(
security_token_pin::CodeType code_type, security_token_pin::CodeType code_type,
security_token_pin::ErrorLabel error_label, security_token_pin::ErrorLabel error_label,
......
...@@ -54,19 +54,15 @@ class RequestPinView final : public views::DialogDelegateView, ...@@ -54,19 +54,15 @@ class RequestPinView final : public views::DialogDelegateView,
RequestPinView& operator=(const RequestPinView&) = delete; RequestPinView& operator=(const RequestPinView&) = delete;
~RequestPinView() override; ~RequestPinView() override;
// views::TextfieldController // views::TextfieldController:
void ContentsChanged(views::Textfield* sender, void ContentsChanged(views::Textfield* sender,
const base::string16& new_contents) override; const base::string16& new_contents) override;
// views::DialogDelegate // views::DialogDelegateView:
bool Accept() override; bool Accept() override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override; bool IsDialogButtonEnabled(ui::DialogButton button) const override;
views::View* GetInitiallyFocusedView() override; views::View* GetInitiallyFocusedView() override;
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
bool ShouldShowCloseButton() const override;
// views::View
gfx::Size CalculatePreferredSize() const override;
// |code_type| - specifies whether the user is asked to enter PIN or PUK. // |code_type| - specifies whether the user is asked to enter PIN or PUK.
// |error_label| - the error template to be displayed in red in the dialog. If // |error_label| - the error template to be displayed in red in the dialog. If
......
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