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

Use set_fixed_width() for remaining dialogs

Replaces remaining CalculatePreferredSize() overrides that are used to
unconditionally set a specific fixed width.

Bug: 1128500
Change-Id: I93abc6b85be7fa956e65608819806aaac23d8d9d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2538131Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Reviewed-by: default avatarConnie Wan <connily@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827470}
parent 41ddf6d6
...@@ -35,6 +35,11 @@ IdleActionWarningDialogView::IdleActionWarningDialogView( ...@@ -35,6 +35,11 @@ IdleActionWarningDialogView::IdleActionWarningDialogView(
: idle_action_time_(idle_action_time) { : idle_action_time_(idle_action_time) {
DialogDelegate::SetButtons(ui::DIALOG_BUTTON_NONE); DialogDelegate::SetButtons(ui::DIALOG_BUTTON_NONE);
SetModalType(ui::MODAL_TYPE_SYSTEM);
SetShowCloseButton(false);
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
SetBorder(views::CreateEmptyBorder( SetBorder(views::CreateEmptyBorder(
ChromeLayoutProvider::Get()->GetDialogInsetsForContentType(views::TEXT, ChromeLayoutProvider::Get()->GetDialogInsetsForContentType(views::TEXT,
views::TEXT))); views::TEXT)));
...@@ -66,10 +71,6 @@ void IdleActionWarningDialogView::Update(base::TimeTicks idle_action_time) { ...@@ -66,10 +71,6 @@ void IdleActionWarningDialogView::Update(base::TimeTicks idle_action_time) {
UpdateTitle(); UpdateTitle();
} }
ui::ModalType IdleActionWarningDialogView::GetModalType() const {
return ui::MODAL_TYPE_SYSTEM;
}
base::string16 IdleActionWarningDialogView::GetWindowTitle() const { base::string16 IdleActionWarningDialogView::GetWindowTitle() const {
const base::TimeDelta time_until_idle_action = const base::TimeDelta time_until_idle_action =
std::max(idle_action_time_ - base::TimeTicks::Now(), base::TimeDelta()); std::max(idle_action_time_ - base::TimeTicks::Now(), base::TimeDelta());
...@@ -80,18 +81,6 @@ base::string16 IdleActionWarningDialogView::GetWindowTitle() const { ...@@ -80,18 +81,6 @@ base::string16 IdleActionWarningDialogView::GetWindowTitle() const {
time_until_idle_action)); time_until_idle_action));
} }
bool IdleActionWarningDialogView::ShouldShowCloseButton() const {
return false;
}
gfx::Size IdleActionWarningDialogView::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));
}
IdleActionWarningDialogView::~IdleActionWarningDialogView() = default; IdleActionWarningDialogView::~IdleActionWarningDialogView() = default;
void IdleActionWarningDialogView::UpdateTitle() { void IdleActionWarningDialogView::UpdateTitle() {
......
...@@ -24,12 +24,7 @@ class IdleActionWarningDialogView : public views::DialogDelegateView { ...@@ -24,12 +24,7 @@ class IdleActionWarningDialogView : public views::DialogDelegateView {
void Update(base::TimeTicks idle_action_time); void Update(base::TimeTicks idle_action_time);
// views::DialogDelegateView: // views::DialogDelegateView:
ui::ModalType GetModalType() const override;
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
bool ShouldShowCloseButton() const override;
// views::View:
gfx::Size CalculatePreferredSize() const override;
private: private:
~IdleActionWarningDialogView() override; ~IdleActionWarningDialogView() override;
......
...@@ -39,6 +39,15 @@ LocalCardMigrationErrorDialogView::LocalCardMigrationErrorDialogView( ...@@ -39,6 +39,15 @@ LocalCardMigrationErrorDialogView::LocalCardMigrationErrorDialogView(
SetCancelCallback( SetCancelCallback(
base::BindOnce(&LocalCardMigrationDialogController::OnDoneButtonClicked, base::BindOnce(&LocalCardMigrationDialogController::OnDoneButtonClicked,
base::Unretained(controller_))); base::Unretained(controller_)));
// The error dialog should be a modal dialog blocking the whole browser
// which is consistent with other dialogs. It should make sure that the
// user can see the error message.
SetModalType(ui::MODAL_TYPE_WINDOW);
SetShowCloseButton(false);
set_fixed_width(ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_LARGE_MODAL_DIALOG_PREFERRED_WIDTH));
set_close_on_deactivate(false); set_close_on_deactivate(false);
set_margins(gfx::Insets()); set_margins(gfx::Insets());
} }
...@@ -57,24 +66,6 @@ void LocalCardMigrationErrorDialogView::CloseDialog() { ...@@ -57,24 +66,6 @@ void LocalCardMigrationErrorDialogView::CloseDialog() {
GetWidget()->Close(); GetWidget()->Close();
} }
gfx::Size LocalCardMigrationErrorDialogView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_LARGE_MODAL_DIALOG_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
ui::ModalType LocalCardMigrationErrorDialogView::GetModalType() const {
// The error dialog should be a modal dialog blocking the whole browser
// which is consistent with other dialogs. It should make sure that the
// user can see the error message.
return ui::MODAL_TYPE_WINDOW;
}
bool LocalCardMigrationErrorDialogView::ShouldShowCloseButton() const {
return false;
}
void LocalCardMigrationErrorDialogView::WindowClosing() { void LocalCardMigrationErrorDialogView::WindowClosing() {
if (controller_) { if (controller_) {
controller_->OnDialogClosed(); controller_->OnDialogClosed();
......
...@@ -29,14 +29,11 @@ class LocalCardMigrationErrorDialogView ...@@ -29,14 +29,11 @@ class LocalCardMigrationErrorDialogView
content::WebContents* web_contents); content::WebContents* web_contents);
~LocalCardMigrationErrorDialogView() override; ~LocalCardMigrationErrorDialogView() override;
// LocalCardMigrationDialog // LocalCardMigrationDialog:
void ShowDialog() override; void ShowDialog() override;
void CloseDialog() override; void CloseDialog() override;
// views::BubbleDialogDelegateView // views::BubbleDialogDelegateView:
gfx::Size CalculatePreferredSize() const override;
ui::ModalType GetModalType() const override;
bool ShouldShowCloseButton() const override;
void Init() override; void Init() override;
void WindowClosing() override; void WindowClosing() override;
......
...@@ -27,6 +27,7 @@ namespace autofill { ...@@ -27,6 +27,7 @@ namespace autofill {
VirtualCardSelectionDialogViewImpl::VirtualCardSelectionDialogViewImpl( VirtualCardSelectionDialogViewImpl::VirtualCardSelectionDialogViewImpl(
VirtualCardSelectionDialogController* controller) VirtualCardSelectionDialogController* controller)
: controller_(controller) { : controller_(controller) {
SetShowTitle(true);
SetButtonLabel(ui::DIALOG_BUTTON_OK, controller_->GetOkButtonLabel()); SetButtonLabel(ui::DIALOG_BUTTON_OK, controller_->GetOkButtonLabel());
SetButtonLabel(ui::DIALOG_BUTTON_CANCEL, controller_->GetCancelButtonLabel()); SetButtonLabel(ui::DIALOG_BUTTON_CANCEL, controller_->GetCancelButtonLabel());
SetAcceptCallback( SetAcceptCallback(
...@@ -35,6 +36,11 @@ VirtualCardSelectionDialogViewImpl::VirtualCardSelectionDialogViewImpl( ...@@ -35,6 +36,11 @@ VirtualCardSelectionDialogViewImpl::VirtualCardSelectionDialogViewImpl(
SetCancelCallback(base::BindOnce( SetCancelCallback(base::BindOnce(
&VirtualCardSelectionDialogController::OnCancelButtonClicked, &VirtualCardSelectionDialogController::OnCancelButtonClicked,
base::Unretained(controller_))); base::Unretained(controller_)));
SetModalType(ui::MODAL_TYPE_CHILD);
SetShowCloseButton(false);
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
} }
VirtualCardSelectionDialogViewImpl::~VirtualCardSelectionDialogViewImpl() { VirtualCardSelectionDialogViewImpl::~VirtualCardSelectionDialogViewImpl() {
...@@ -65,12 +71,6 @@ void VirtualCardSelectionDialogViewImpl::Hide() { ...@@ -65,12 +71,6 @@ void VirtualCardSelectionDialogViewImpl::Hide() {
GetWidget()->Close(); GetWidget()->Close();
} }
gfx::Size VirtualCardSelectionDialogViewImpl::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH);
return gfx::Size(width, GetHeightForWidth(width));
}
void VirtualCardSelectionDialogViewImpl::AddedToWidget() { void VirtualCardSelectionDialogViewImpl::AddedToWidget() {
// TODO(crbug.com/1020740): The header image is not ready. Implement it later. // TODO(crbug.com/1020740): The header image is not ready. Implement it later.
} }
...@@ -81,10 +81,6 @@ bool VirtualCardSelectionDialogViewImpl::IsDialogButtonEnabled( ...@@ -81,10 +81,6 @@ bool VirtualCardSelectionDialogViewImpl::IsDialogButtonEnabled(
: true; : true;
} }
ui::ModalType VirtualCardSelectionDialogViewImpl::GetModalType() const {
return ui::MODAL_TYPE_CHILD;
}
views::View* VirtualCardSelectionDialogViewImpl::GetContentsView() { views::View* VirtualCardSelectionDialogViewImpl::GetContentsView() {
RemoveAllChildViews(/*delete_children=*/true); RemoveAllChildViews(/*delete_children=*/true);
...@@ -111,12 +107,4 @@ base::string16 VirtualCardSelectionDialogViewImpl::GetWindowTitle() const { ...@@ -111,12 +107,4 @@ base::string16 VirtualCardSelectionDialogViewImpl::GetWindowTitle() const {
return controller_->GetContentTitle(); return controller_->GetContentTitle();
} }
bool VirtualCardSelectionDialogViewImpl::ShouldShowWindowTitle() const {
return true;
}
bool VirtualCardSelectionDialogViewImpl::ShouldShowCloseButton() const {
return false;
}
} // namespace autofill } // namespace autofill
...@@ -26,14 +26,10 @@ class VirtualCardSelectionDialogViewImpl ...@@ -26,14 +26,10 @@ class VirtualCardSelectionDialogViewImpl
void Hide() override; void Hide() override;
// views::DialogDelegateView: // views::DialogDelegateView:
gfx::Size CalculatePreferredSize() const override;
void AddedToWidget() override; void AddedToWidget() override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override; bool IsDialogButtonEnabled(ui::DialogButton button) const override;
ui::ModalType GetModalType() const override;
View* GetContentsView() override; View* GetContentsView() override;
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
bool ShouldShowWindowTitle() const override;
bool ShouldShowCloseButton() const override;
private: private:
VirtualCardSelectionDialogController* controller_ = nullptr; VirtualCardSelectionDialogController* controller_ = nullptr;
......
...@@ -23,6 +23,7 @@ WebauthnDialogViewImpl::WebauthnDialogViewImpl( ...@@ -23,6 +23,7 @@ WebauthnDialogViewImpl::WebauthnDialogViewImpl(
WebauthnDialogController* controller, WebauthnDialogController* controller,
WebauthnDialogState dialog_state) WebauthnDialogState dialog_state)
: controller_(controller) { : controller_(controller) {
SetShowTitle(false);
SetLayoutManager(std::make_unique<views::FillLayout>()); SetLayoutManager(std::make_unique<views::FillLayout>());
std::unique_ptr<WebauthnDialogModel> model = std::unique_ptr<WebauthnDialogModel> model =
std::make_unique<WebauthnDialogModel>(dialog_state); std::make_unique<WebauthnDialogModel>(dialog_state);
...@@ -32,6 +33,11 @@ WebauthnDialogViewImpl::WebauthnDialogViewImpl( ...@@ -32,6 +33,11 @@ WebauthnDialogViewImpl::WebauthnDialogViewImpl(
AddChildView(CreateSheetViewForAutofillWebAuthn(std::move(model))); AddChildView(CreateSheetViewForAutofillWebAuthn(std::move(model)));
sheet_view_->ReInitChildViews(); sheet_view_->ReInitChildViews();
SetModalType(ui::MODAL_TYPE_CHILD);
SetShowCloseButton(false);
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
SetButtonLabel(ui::DIALOG_BUTTON_OK, model_->GetAcceptButtonLabel()); SetButtonLabel(ui::DIALOG_BUTTON_OK, model_->GetAcceptButtonLabel());
SetButtonLabel(ui::DIALOG_BUTTON_CANCEL, model_->GetCancelButtonLabel()); SetButtonLabel(ui::DIALOG_BUTTON_CANCEL, model_->GetCancelButtonLabel());
SetButtons(model_->IsAcceptButtonVisible() SetButtons(model_->IsAcceptButtonVisible()
...@@ -78,12 +84,6 @@ void WebauthnDialogViewImpl::OnDialogStateChanged() { ...@@ -78,12 +84,6 @@ void WebauthnDialogViewImpl::OnDialogStateChanged() {
} }
} }
gfx::Size WebauthnDialogViewImpl::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH);
return gfx::Size(width, GetHeightForWidth(width));
}
bool WebauthnDialogViewImpl::Accept() { bool WebauthnDialogViewImpl::Accept() {
DCHECK_EQ(model_->dialog_state(), WebauthnDialogState::kOffer); DCHECK_EQ(model_->dialog_state(), WebauthnDialogState::kOffer);
controller_->OnOkButtonClicked(); controller_->OnOkButtonClicked();
...@@ -106,22 +106,10 @@ bool WebauthnDialogViewImpl::IsDialogButtonEnabled( ...@@ -106,22 +106,10 @@ bool WebauthnDialogViewImpl::IsDialogButtonEnabled(
: true; : true;
} }
ui::ModalType WebauthnDialogViewImpl::GetModalType() const {
return ui::MODAL_TYPE_CHILD;
}
base::string16 WebauthnDialogViewImpl::GetWindowTitle() const { base::string16 WebauthnDialogViewImpl::GetWindowTitle() const {
return model_->GetStepTitle(); return model_->GetStepTitle();
} }
bool WebauthnDialogViewImpl::ShouldShowWindowTitle() const {
return false;
}
bool WebauthnDialogViewImpl::ShouldShowCloseButton() const {
return false;
}
void WebauthnDialogViewImpl::Hide() { void WebauthnDialogViewImpl::Hide() {
// Reset controller reference if the controller has been destroyed before the // Reset controller reference if the controller has been destroyed before the
// view being destroyed. This happens if browser window is closed when the // view being destroyed. This happens if browser window is closed when the
......
...@@ -32,14 +32,10 @@ class WebauthnDialogViewImpl : public WebauthnDialogView, ...@@ -32,14 +32,10 @@ class WebauthnDialogViewImpl : public WebauthnDialogView,
void OnDialogStateChanged() override; void OnDialogStateChanged() override;
// views::DialogDelegateView: // views::DialogDelegateView:
gfx::Size CalculatePreferredSize() const override;
bool Accept() override; bool Accept() override;
bool Cancel() override; bool Cancel() override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override; bool IsDialogButtonEnabled(ui::DialogButton button) const override;
ui::ModalType GetModalType() const override;
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
bool ShouldShowWindowTitle() const override;
bool ShouldShowCloseButton() const override;
private: private:
// Closes the dialog. // Closes the dialog.
......
...@@ -58,6 +58,7 @@ ChromeCleanerDialog::ChromeCleanerDialog( ...@@ -58,6 +58,7 @@ ChromeCleanerDialog::ChromeCleanerDialog(
DCHECK(dialog_controller_); DCHECK(dialog_controller_);
DCHECK(cleaner_controller_); DCHECK(cleaner_controller_);
SetTitle(IDS_CHROME_CLEANUP_PROMPT_TITLE);
SetButtonLabel( SetButtonLabel(
ui::DIALOG_BUTTON_OK, ui::DIALOG_BUTTON_OK,
l10n_util::GetStringUTF16(IDS_CHROME_CLEANUP_PROMPT_REMOVE_BUTTON_LABEL)); l10n_util::GetStringUTF16(IDS_CHROME_CLEANUP_PROMPT_REMOVE_BUTTON_LABEL));
...@@ -77,6 +78,11 @@ ChromeCleanerDialog::ChromeCleanerDialog( ...@@ -77,6 +78,11 @@ ChromeCleanerDialog::ChromeCleanerDialog(
base::Unretained(this), base::Unretained(this),
DialogInteractionResult::kClose)); DialogInteractionResult::kClose));
SetModalType(ui::MODAL_TYPE_WINDOW);
SetShowCloseButton(false);
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
ChromeLayoutProvider* layout_provider = ChromeLayoutProvider::Get(); ChromeLayoutProvider* layout_provider = ChromeLayoutProvider::Get();
set_margins( set_margins(
layout_provider->GetDialogInsetsForContentType(views::TEXT, views::TEXT)); layout_provider->GetDialogInsetsForContentType(views::TEXT, views::TEXT));
...@@ -133,17 +139,6 @@ void ChromeCleanerDialog::Show(Browser* browser) { ...@@ -133,17 +139,6 @@ void ChromeCleanerDialog::Show(Browser* browser) {
cleaner_controller_->AddObserver(this); cleaner_controller_->AddObserver(this);
} }
// WidgetDelegate overrides.
ui::ModalType ChromeCleanerDialog::GetModalType() const {
return ui::MODAL_TYPE_WINDOW;
}
base::string16 ChromeCleanerDialog::GetWindowTitle() const {
DCHECK(dialog_controller_);
return l10n_util::GetStringUTF16(IDS_CHROME_CLEANUP_PROMPT_TITLE);
}
views::View* ChromeCleanerDialog::GetInitiallyFocusedView() { views::View* ChromeCleanerDialog::GetInitiallyFocusedView() {
// Set focus away from the Remove/OK button to prevent accidental prompt // Set focus away from the Remove/OK button to prevent accidental prompt
// acceptance if the user is typing as the dialog appears. // acceptance if the user is typing as the dialog appears.
...@@ -151,19 +146,6 @@ views::View* ChromeCleanerDialog::GetInitiallyFocusedView() { ...@@ -151,19 +146,6 @@ views::View* ChromeCleanerDialog::GetInitiallyFocusedView() {
return details_button_; return details_button_;
} }
bool ChromeCleanerDialog::ShouldShowCloseButton() const {
return false;
}
// View overrides.
gfx::Size ChromeCleanerDialog::CalculatePreferredSize() const {
const int dialog_width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(dialog_width, GetHeightForWidth(dialog_width));
}
// safe_browsing::ChromeCleanerController::Observer overrides // safe_browsing::ChromeCleanerController::Observer overrides
void ChromeCleanerDialog::OnIdle( void ChromeCleanerDialog::OnIdle(
......
...@@ -46,14 +46,8 @@ class ChromeCleanerDialog ...@@ -46,14 +46,8 @@ class ChromeCleanerDialog
void Show(Browser* browser); void Show(Browser* browser);
// views::WidgetDelegate overrides. // views::DialogDelegateView:
ui::ModalType GetModalType() const override;
base::string16 GetWindowTitle() const override;
views::View* GetInitiallyFocusedView() override; views::View* GetInitiallyFocusedView() override;
bool ShouldShowCloseButton() const override;
// views::View overrides.
gfx::Size CalculatePreferredSize() const override;
// safe_browsing::ChromeCleanerController::Observer overrides. // safe_browsing::ChromeCleanerController::Observer overrides.
void OnIdle( void OnIdle(
......
...@@ -49,17 +49,6 @@ views::Widget* CrostiniForceCloseView::Show( ...@@ -49,17 +49,6 @@ views::Widget* CrostiniForceCloseView::Show(
return dialog_widget; return dialog_widget;
} }
ui::ModalType CrostiniForceCloseView::GetModalType() const {
return ui::ModalType::MODAL_TYPE_WINDOW;
}
gfx::Size CrostiniForceCloseView::CalculatePreferredSize() const {
const int dialog_width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(dialog_width, GetHeightForWidth(dialog_width));
}
CrostiniForceCloseView::CrostiniForceCloseView( CrostiniForceCloseView::CrostiniForceCloseView(
const base::string16& app_name, const base::string16& app_name,
base::OnceClosure force_close_callback) { base::OnceClosure force_close_callback) {
...@@ -74,6 +63,10 @@ CrostiniForceCloseView::CrostiniForceCloseView( ...@@ -74,6 +63,10 @@ CrostiniForceCloseView::CrostiniForceCloseView(
l10n_util::GetStringUTF16(IDS_CROSTINI_FORCE_CLOSE_ACCEPT_BUTTON)); l10n_util::GetStringUTF16(IDS_CROSTINI_FORCE_CLOSE_ACCEPT_BUTTON));
SetAcceptCallback(std::move(force_close_callback)); SetAcceptCallback(std::move(force_close_callback));
SetModalType(ui::ModalType::MODAL_TYPE_WINDOW);
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
views::LayoutProvider* provider = views::LayoutProvider::Get(); views::LayoutProvider* provider = views::LayoutProvider::Get();
SetLayoutManager(std::make_unique<views::BoxLayout>( SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical, views::BoxLayout::Orientation::kVertical,
......
...@@ -36,10 +36,6 @@ class CrostiniForceCloseView : public views::BubbleDialogDelegateView { ...@@ -36,10 +36,6 @@ class CrostiniForceCloseView : public views::BubbleDialogDelegateView {
gfx::NativeView closable_view, gfx::NativeView closable_view,
base::OnceClosure force_close_callback); base::OnceClosure force_close_callback);
// BubbleDialogDelegateView overrides.
ui::ModalType GetModalType() const override;
gfx::Size CalculatePreferredSize() const override;
private: private:
CrostiniForceCloseView(const base::string16& app_name, CrostiniForceCloseView(const base::string16& app_name,
base::OnceClosure force_close_callback); base::OnceClosure force_close_callback);
......
...@@ -32,13 +32,6 @@ void CrostiniPackageInstallFailureView::Show(const std::string& error_message) { ...@@ -32,13 +32,6 @@ void CrostiniPackageInstallFailureView::Show(const std::string& error_message) {
->Show(); ->Show();
} }
gfx::Size CrostiniPackageInstallFailureView::CalculatePreferredSize() const {
const int dialog_width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(dialog_width, GetHeightForWidth(dialog_width));
}
CrostiniPackageInstallFailureView::CrostiniPackageInstallFailureView( CrostiniPackageInstallFailureView::CrostiniPackageInstallFailureView(
const std::string& error_message) { const std::string& error_message) {
SetShowCloseButton(false); SetShowCloseButton(false);
...@@ -51,6 +44,8 @@ CrostiniPackageInstallFailureView::CrostiniPackageInstallFailureView( ...@@ -51,6 +44,8 @@ CrostiniPackageInstallFailureView::CrostiniPackageInstallFailureView(
provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL))); provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL)));
set_margins(provider->GetDialogInsetsForContentType( set_margins(provider->GetDialogInsetsForContentType(
views::DialogContentType::TEXT, views::DialogContentType::TEXT)); views::DialogContentType::TEXT, views::DialogContentType::TEXT));
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
views::StyledLabel* message_label = views::StyledLabel* message_label =
AddChildView(std::make_unique<views::StyledLabel>()); AddChildView(std::make_unique<views::StyledLabel>());
......
...@@ -13,9 +13,6 @@ class CrostiniPackageInstallFailureView ...@@ -13,9 +13,6 @@ class CrostiniPackageInstallFailureView
public: public:
static void Show(const std::string& error_message); static void Show(const std::string& error_message);
// BubbleDialogDelegateView overrides.
gfx::Size CalculatePreferredSize() const override;
private: private:
explicit CrostiniPackageInstallFailureView(const std::string& error_message); explicit CrostiniPackageInstallFailureView(const std::string& error_message);
......
...@@ -46,6 +46,8 @@ DownloadInProgressDialogView::DownloadInProgressDialogView( ...@@ -46,6 +46,8 @@ DownloadInProgressDialogView::DownloadInProgressDialogView(
SetLayoutManager(std::make_unique<views::FillLayout>()); SetLayoutManager(std::make_unique<views::FillLayout>());
set_margins(ChromeLayoutProvider::Get()->GetDialogInsetsForContentType( set_margins(ChromeLayoutProvider::Get()->GetDialogInsetsForContentType(
views::TEXT, views::TEXT)); views::TEXT, views::TEXT));
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
auto run_callback = [](DownloadInProgressDialogView* dialog, bool accept) { auto run_callback = [](DownloadInProgressDialogView* dialog, bool accept) {
// Note that accepting this dialog means "cancel the download", while cancel // Note that accepting this dialog means "cancel the download", while cancel
...@@ -86,12 +88,5 @@ DownloadInProgressDialogView::DownloadInProgressDialogView( ...@@ -86,12 +88,5 @@ DownloadInProgressDialogView::DownloadInProgressDialogView(
DownloadInProgressDialogView::~DownloadInProgressDialogView() = default; DownloadInProgressDialogView::~DownloadInProgressDialogView() = default;
gfx::Size DownloadInProgressDialogView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
BEGIN_METADATA(DownloadInProgressDialogView, views::DialogDelegateView) BEGIN_METADATA(DownloadInProgressDialogView, views::DialogDelegateView)
END_METADATA END_METADATA
...@@ -32,9 +32,6 @@ class DownloadInProgressDialogView : public views::DialogDelegateView { ...@@ -32,9 +32,6 @@ class DownloadInProgressDialogView : public views::DialogDelegateView {
const base::Callback<void(bool)>& callback); const base::Callback<void(bool)>& callback);
~DownloadInProgressDialogView() override; ~DownloadInProgressDialogView() override;
// views::DialogDelegateView:
gfx::Size CalculatePreferredSize() const override;
const base::Callback<void(bool)> callback_; const base::Callback<void(bool)> callback_;
DISALLOW_COPY_AND_ASSIGN(DownloadInProgressDialogView); DISALLOW_COPY_AND_ASSIGN(DownloadInProgressDialogView);
......
...@@ -70,6 +70,13 @@ ExtensionInstallBlockedDialogView::ExtensionInstallBlockedDialogView( ...@@ -70,6 +70,13 @@ ExtensionInstallBlockedDialogView::ExtensionInstallBlockedDialogView(
SetTitle( SetTitle(
l10n_util::GetStringFUTF16(IDS_EXTENSION_BLOCKED_BY_POLICY_PROMPT_TITLE, l10n_util::GetStringFUTF16(IDS_EXTENSION_BLOCKED_BY_POLICY_PROMPT_TITLE,
base::UTF8ToUTF16(extension_name))); base::UTF8ToUTF16(extension_name)));
// Make sure user know the installation is blocked before taking further
// action.
SetModalType(ui::MODAL_TYPE_CHILD);
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
set_draggable(true); set_draggable(true);
set_close_on_deactivate(false); set_close_on_deactivate(false);
SetLayoutManager(std::make_unique<views::FillLayout>()); SetLayoutManager(std::make_unique<views::FillLayout>());
...@@ -82,19 +89,6 @@ ExtensionInstallBlockedDialogView::~ExtensionInstallBlockedDialogView() { ...@@ -82,19 +89,6 @@ ExtensionInstallBlockedDialogView::~ExtensionInstallBlockedDialogView() {
std::move(done_callback_).Run(); std::move(done_callback_).Run();
} }
gfx::Size ExtensionInstallBlockedDialogView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
ui::ModalType ExtensionInstallBlockedDialogView::GetModalType() const {
// Make sure user know the installation is blocked before taking further
// action.
return ui::MODAL_TYPE_CHILD;
}
void ExtensionInstallBlockedDialogView::AddCustomMessageContents( void ExtensionInstallBlockedDialogView::AddCustomMessageContents(
const base::string16& custom_error_message) { const base::string16& custom_error_message) {
DCHECK(!custom_error_message.empty()); DCHECK(!custom_error_message.empty());
......
...@@ -35,10 +35,6 @@ class ExtensionInstallBlockedDialogView ...@@ -35,10 +35,6 @@ class ExtensionInstallBlockedDialogView
~ExtensionInstallBlockedDialogView() override; ~ExtensionInstallBlockedDialogView() override;
private: private:
// views::BubbleDialogDelegateView
gfx::Size CalculatePreferredSize() const override;
ui::ModalType GetModalType() const override;
// Creates the contents area that contains custom error message that is set by // Creates the contents area that contains custom error message that is set by
// administrator. // administrator.
void AddCustomMessageContents(const base::string16& custom_error_message); void AddCustomMessageContents(const base::string16& custom_error_message);
......
...@@ -221,6 +221,10 @@ ExtensionInstallDialogView::ExtensionInstallDialogView( ...@@ -221,6 +221,10 @@ ExtensionInstallDialogView::ExtensionInstallDialogView(
default_button = ui::DIALOG_BUTTON_OK; default_button = ui::DIALOG_BUTTON_OK;
#endif #endif
SetModalType(ui::MODAL_TYPE_WINDOW);
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
SetDefaultButton(default_button); SetDefaultButton(default_button);
SetButtons(buttons); SetButtons(buttons);
SetAcceptCallback(base::BindOnce( SetAcceptCallback(base::BindOnce(
...@@ -265,13 +269,6 @@ void ExtensionInstallDialogView::ResizeWidget() { ...@@ -265,13 +269,6 @@ void ExtensionInstallDialogView::ResizeWidget() {
GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize()); GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize());
} }
gfx::Size ExtensionInstallDialogView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
void ExtensionInstallDialogView::VisibilityChanged(views::View* starting_from, void ExtensionInstallDialogView::VisibilityChanged(views::View* starting_from,
bool is_visible) { bool is_visible) {
if (is_visible) { if (is_visible) {
...@@ -398,6 +395,10 @@ bool ExtensionInstallDialogView::IsDialogButtonEnabled( ...@@ -398,6 +395,10 @@ bool ExtensionInstallDialogView::IsDialogButtonEnabled(
return true; return true;
} }
base::string16 ExtensionInstallDialogView::GetAccessibleWindowTitle() const {
return title_;
}
void ExtensionInstallDialogView::CloseDialog() { void ExtensionInstallDialogView::CloseDialog() {
GetWidget()->Close(); GetWidget()->Close();
} }
...@@ -421,14 +422,6 @@ void ExtensionInstallDialogView::OnShutdown( ...@@ -421,14 +422,6 @@ void ExtensionInstallDialogView::OnShutdown(
CloseDialog(); CloseDialog();
} }
base::string16 ExtensionInstallDialogView::GetAccessibleWindowTitle() const {
return title_;
}
ui::ModalType ExtensionInstallDialogView::GetModalType() const {
return ui::MODAL_TYPE_WINDOW;
}
void ExtensionInstallDialogView::LinkClicked() { void ExtensionInstallDialogView::LinkClicked() {
GURL store_url(extension_urls::GetWebstoreItemDetailURLPrefix() + GURL store_url(extension_urls::GetWebstoreItemDetailURLPrefix() +
prompt_->extension()->id()); prompt_->extension()->id());
......
...@@ -53,11 +53,11 @@ class ExtensionInstallDialogView ...@@ -53,11 +53,11 @@ class ExtensionInstallDialogView
// Changes the widget size to accommodate the contents' preferred size. // Changes the widget size to accommodate the contents' preferred size.
void ResizeWidget(); void ResizeWidget();
// views::BubbleDialogDelegate: // views::BubbleDialogDelegateView:
gfx::Size CalculatePreferredSize() const override;
void VisibilityChanged(views::View* starting_from, bool is_visible) override; void VisibilityChanged(views::View* starting_from, bool is_visible) override;
void AddedToWidget() override; void AddedToWidget() override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override; bool IsDialogButtonEnabled(ui::DialogButton button) const override;
base::string16 GetAccessibleWindowTitle() const override;
private: private:
void CloseDialog(); void CloseDialog();
...@@ -68,10 +68,6 @@ class ExtensionInstallDialogView ...@@ -68,10 +68,6 @@ class ExtensionInstallDialogView
extensions::UninstallReason reason) override; extensions::UninstallReason reason) override;
void OnShutdown(extensions::ExtensionRegistry* registry) override; void OnShutdown(extensions::ExtensionRegistry* registry) override;
// views::WidgetDelegate:
base::string16 GetAccessibleWindowTitle() const override;
ui::ModalType GetModalType() const override;
void LinkClicked(); void LinkClicked();
void OnDialogCanceled(); void OnDialogCanceled();
void OnDialogAccepted(); void OnDialogAccepted();
......
...@@ -43,11 +43,10 @@ SettingsOverriddenDialogView::SettingsOverriddenDialogView( ...@@ -43,11 +43,10 @@ SettingsOverriddenDialogView::SettingsOverriddenDialogView(
SetCancelCallback(make_result_callback(DialogResult::kKeepNewSettings)); SetCancelCallback(make_result_callback(DialogResult::kKeepNewSettings));
SetCloseCallback(make_result_callback(DialogResult::kDialogDismissed)); SetCloseCallback(make_result_callback(DialogResult::kDialogDismissed));
// Modals shouldn't show a close button according to the latest style SetModalType(ui::MODAL_TYPE_WINDOW);
// guidelines. Note the dialog can still be dismissed by user action via the
// escape key (in addition to closing automatically if the parent widget
// is destroyed).
SetShowCloseButton(false); SetShowCloseButton(false);
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
SettingsOverriddenDialogController::ShowParams show_params = SettingsOverriddenDialogController::ShowParams show_params =
controller_->GetShowParams(); controller_->GetShowParams();
...@@ -90,17 +89,6 @@ void SettingsOverriddenDialogView::Show(gfx::NativeWindow parent) { ...@@ -90,17 +89,6 @@ void SettingsOverriddenDialogView::Show(gfx::NativeWindow parent) {
controller_->OnDialogShown(); controller_->OnDialogShown();
} }
ui::ModalType SettingsOverriddenDialogView::GetModalType() const {
return ui::MODAL_TYPE_WINDOW;
}
gfx::Size SettingsOverriddenDialogView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
void SettingsOverriddenDialogView::NotifyControllerOfResult( void SettingsOverriddenDialogView::NotifyControllerOfResult(
SettingsOverriddenDialogController::DialogResult result) { SettingsOverriddenDialogController::DialogResult result) {
DCHECK(!result_) DCHECK(!result_)
......
...@@ -27,10 +27,6 @@ class SettingsOverriddenDialogView : public views::DialogDelegateView { ...@@ -27,10 +27,6 @@ class SettingsOverriddenDialogView : public views::DialogDelegateView {
void Show(gfx::NativeWindow parent); void Show(gfx::NativeWindow parent);
private: private:
// views::DialogDelegateView:
ui::ModalType GetModalType() const override;
gfx::Size CalculatePreferredSize() const override;
// Notifies the |controller_| of the |result|. // Notifies the |controller_| of the |result|.
void NotifyControllerOfResult( void NotifyControllerOfResult(
SettingsOverriddenDialogController::DialogResult result); SettingsOverriddenDialogController::DialogResult result);
......
...@@ -47,6 +47,8 @@ void ImportLockDialogView::Show(gfx::NativeWindow parent, ...@@ -47,6 +47,8 @@ void ImportLockDialogView::Show(gfx::NativeWindow parent,
ImportLockDialogView::ImportLockDialogView( ImportLockDialogView::ImportLockDialogView(
base::OnceCallback<void(bool)> callback) base::OnceCallback<void(bool)> callback)
: callback_(std::move(callback)) { : callback_(std::move(callback)) {
SetTitle(IDS_IMPORTER_LOCK_TITLE);
SetButtonLabel(ui::DIALOG_BUTTON_OK, SetButtonLabel(ui::DIALOG_BUTTON_OK,
l10n_util::GetStringUTF16(IDS_IMPORTER_LOCK_OK)); l10n_util::GetStringUTF16(IDS_IMPORTER_LOCK_OK));
...@@ -61,6 +63,10 @@ ImportLockDialogView::ImportLockDialogView( ...@@ -61,6 +63,10 @@ ImportLockDialogView::ImportLockDialogView(
SetCancelCallback( SetCancelCallback(
base::BindOnce(done_callback, base::Unretained(this), false)); base::BindOnce(done_callback, base::Unretained(this), false));
SetShowCloseButton(false);
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
SetLayoutManager(std::make_unique<views::FillLayout>()); SetLayoutManager(std::make_unique<views::FillLayout>());
views::Label* description_label = views::Label* description_label =
new views::Label(l10n_util::GetStringUTF16(IDS_IMPORTER_LOCK_TEXT)); new views::Label(l10n_util::GetStringUTF16(IDS_IMPORTER_LOCK_TEXT));
...@@ -73,19 +79,4 @@ ImportLockDialogView::ImportLockDialogView( ...@@ -73,19 +79,4 @@ ImportLockDialogView::ImportLockDialogView(
chrome::RecordDialogCreation(chrome::DialogIdentifier::IMPORT_LOCK); chrome::RecordDialogCreation(chrome::DialogIdentifier::IMPORT_LOCK);
} }
ImportLockDialogView::~ImportLockDialogView() { ImportLockDialogView::~ImportLockDialogView() = default;
}
gfx::Size ImportLockDialogView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH);
return gfx::Size(width, GetHeightForWidth(width));
}
base::string16 ImportLockDialogView::GetWindowTitle() const {
return l10n_util::GetStringUTF16(IDS_IMPORTER_LOCK_TITLE);
}
bool ImportLockDialogView::ShouldShowCloseButton() const {
return false;
}
...@@ -21,15 +21,6 @@ class ImportLockDialogView : public views::DialogDelegateView { ...@@ -21,15 +21,6 @@ class ImportLockDialogView : public views::DialogDelegateView {
explicit ImportLockDialogView(base::OnceCallback<void(bool)> callback); explicit ImportLockDialogView(base::OnceCallback<void(bool)> callback);
~ImportLockDialogView() override; ~ImportLockDialogView() override;
// views::View:
gfx::Size CalculatePreferredSize() const override;
// views::DialogDelegate:
base::string16 GetWindowTitle() const override;
// views::WidgetDelegate:
bool ShouldShowCloseButton() const override;
private: private:
// Called with the result of the dialog. // Called with the result of the dialog.
base::OnceCallback<void(bool)> callback_; base::OnceCallback<void(bool)> callback_;
......
...@@ -107,6 +107,8 @@ CookieControlsBubbleView::CookieControlsBubbleView( ...@@ -107,6 +107,8 @@ CookieControlsBubbleView::CookieControlsBubbleView(
content_settings::CookieControlsController* controller) content_settings::CookieControlsController* controller)
: LocationBarBubbleDelegateView(anchor_view, web_contents), : LocationBarBubbleDelegateView(anchor_view, web_contents),
controller_(controller) { controller_(controller) {
SetShowTitle(true);
SetShowCloseButton(true);
controller_observer_.Add(controller); controller_observer_.Add(controller);
SetButtons(ui::DIALOG_BUTTON_NONE); SetButtons(ui::DIALOG_BUTTON_NONE);
} }
...@@ -255,14 +257,6 @@ base::string16 CookieControlsBubbleView::GetWindowTitle() const { ...@@ -255,14 +257,6 @@ base::string16 CookieControlsBubbleView::GetWindowTitle() const {
} }
} }
bool CookieControlsBubbleView::ShouldShowWindowTitle() const {
return true;
}
bool CookieControlsBubbleView::ShouldShowCloseButton() const {
return true;
}
void CookieControlsBubbleView::WindowClosing() { void CookieControlsBubbleView::WindowClosing() {
// |cookie_bubble_| can be a new bubble by this point (as Close(); doesn't // |cookie_bubble_| can be a new bubble by this point (as Close(); doesn't
// call this right away). Only set to nullptr when it's this bubble. // call this right away). Only set to nullptr when it's this bubble.
......
...@@ -65,8 +65,6 @@ class CookieControlsBubbleView : public LocationBarBubbleDelegateView, ...@@ -65,8 +65,6 @@ class CookieControlsBubbleView : public LocationBarBubbleDelegateView,
void CloseBubble() override; void CloseBubble() override;
void Init() override; void Init() override;
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
bool ShouldShowWindowTitle() const override;
bool ShouldShowCloseButton() const override;
void WindowClosing() override; void WindowClosing() override;
gfx::Size CalculatePreferredSize() const override; gfx::Size CalculatePreferredSize() const override;
void AddedToWidget() override; void AddedToWidget() override;
......
...@@ -27,6 +27,11 @@ AutoSigninFirstRunDialogView::AutoSigninFirstRunDialogView( ...@@ -27,6 +27,11 @@ AutoSigninFirstRunDialogView::AutoSigninFirstRunDialogView(
SetButtonLabel(ui::DIALOG_BUTTON_CANCEL, SetButtonLabel(ui::DIALOG_BUTTON_CANCEL,
l10n_util::GetStringUTF16(IDS_TURN_OFF)); l10n_util::GetStringUTF16(IDS_TURN_OFF));
SetModalType(ui::MODAL_TYPE_CHILD);
SetShowCloseButton(false);
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
using ControllerCallbackFn = void (CredentialManagerDialogController::*)(); using ControllerCallbackFn = void (CredentialManagerDialogController::*)();
auto call_controller = [](AutoSigninFirstRunDialogView* dialog, auto call_controller = [](AutoSigninFirstRunDialogView* dialog,
ControllerCallbackFn func) { ControllerCallbackFn func) {
...@@ -59,25 +64,10 @@ void AutoSigninFirstRunDialogView::ControllerGone() { ...@@ -59,25 +64,10 @@ void AutoSigninFirstRunDialogView::ControllerGone() {
controller_ = nullptr; controller_ = nullptr;
} }
ui::ModalType AutoSigninFirstRunDialogView::GetModalType() const {
return ui::MODAL_TYPE_CHILD;
}
base::string16 AutoSigninFirstRunDialogView::GetWindowTitle() const { base::string16 AutoSigninFirstRunDialogView::GetWindowTitle() const {
return controller_->GetAutoSigninPromoTitle(); return controller_->GetAutoSigninPromoTitle();
} }
bool AutoSigninFirstRunDialogView::ShouldShowCloseButton() const {
return false;
}
gfx::Size AutoSigninFirstRunDialogView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
void AutoSigninFirstRunDialogView::WindowClosing() { void AutoSigninFirstRunDialogView::WindowClosing() {
if (controller_) if (controller_)
controller_->OnCloseDialog(); controller_->OnCloseDialog();
......
...@@ -22,10 +22,7 @@ class AutoSigninFirstRunDialogView : public views::DialogDelegateView, ...@@ -22,10 +22,7 @@ class AutoSigninFirstRunDialogView : public views::DialogDelegateView,
private: private:
// views::DialogDelegateView: // views::DialogDelegateView:
ui::ModalType GetModalType() const override;
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
bool ShouldShowCloseButton() const override;
gfx::Size CalculatePreferredSize() const override;
void WindowClosing() override; void WindowClosing() override;
// Sets up the child views. // Sets up the child views.
......
...@@ -65,7 +65,12 @@ CredentialLeakDialogView::CredentialLeakDialogView( ...@@ -65,7 +65,12 @@ CredentialLeakDialogView::CredentialLeakDialogView(
SetButtonLabel(ui::DIALOG_BUTTON_OK, controller_->GetAcceptButtonLabel()); SetButtonLabel(ui::DIALOG_BUTTON_OK, controller_->GetAcceptButtonLabel());
SetButtonLabel(ui::DIALOG_BUTTON_CANCEL, controller_->GetCancelButtonLabel()); SetButtonLabel(ui::DIALOG_BUTTON_CANCEL, controller_->GetCancelButtonLabel());
using ControllerClosureFn = void (CredentialLeakDialogController::*)(void); SetModalType(ui::MODAL_TYPE_CHILD);
SetShowCloseButton(false);
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
using ControllerClosureFn = void (CredentialLeakDialogController::*)();
auto close_callback = [](CredentialLeakDialogController** controller, auto close_callback = [](CredentialLeakDialogController** controller,
ControllerClosureFn fn) { ControllerClosureFn fn) {
// Null out the controller pointer stored in the parent object, to avoid any // Null out the controller pointer stored in the parent object, to avoid any
...@@ -106,21 +111,6 @@ void CredentialLeakDialogView::ControllerGone() { ...@@ -106,21 +111,6 @@ void CredentialLeakDialogView::ControllerGone() {
GetWidget()->Close(); GetWidget()->Close();
} }
ui::ModalType CredentialLeakDialogView::GetModalType() const {
return ui::MODAL_TYPE_CHILD;
}
gfx::Size CredentialLeakDialogView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
bool CredentialLeakDialogView::ShouldShowCloseButton() const {
return false;
}
void CredentialLeakDialogView::OnThemeChanged() { void CredentialLeakDialogView::OnThemeChanged() {
views::DialogDelegateView::OnThemeChanged(); views::DialogDelegateView::OnThemeChanged();
GetBubbleFrameView()->SetHeaderView( GetBubbleFrameView()->SetHeaderView(
......
...@@ -28,9 +28,6 @@ class CredentialLeakDialogView : public views::DialogDelegateView, ...@@ -28,9 +28,6 @@ class CredentialLeakDialogView : public views::DialogDelegateView,
private: private:
// views::DialogDelegateView: // views::DialogDelegateView:
ui::ModalType GetModalType() const override;
gfx::Size CalculatePreferredSize() const override;
bool ShouldShowCloseButton() const override;
void OnThemeChanged() override; void OnThemeChanged() override;
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
......
...@@ -58,18 +58,10 @@ void RelaunchRequiredDialogView::SetDeadline(base::Time deadline) { ...@@ -58,18 +58,10 @@ void RelaunchRequiredDialogView::SetDeadline(base::Time deadline) {
relaunch_required_timer_.SetDeadline(deadline); relaunch_required_timer_.SetDeadline(deadline);
} }
ui::ModalType RelaunchRequiredDialogView::GetModalType() const {
return ui::MODAL_TYPE_WINDOW;
}
base::string16 RelaunchRequiredDialogView::GetWindowTitle() const { base::string16 RelaunchRequiredDialogView::GetWindowTitle() const {
return relaunch_required_timer_.GetWindowTitle(); return relaunch_required_timer_.GetWindowTitle();
} }
bool RelaunchRequiredDialogView::ShouldShowCloseButton() const {
return false;
}
gfx::ImageSkia RelaunchRequiredDialogView::GetWindowIcon() { gfx::ImageSkia RelaunchRequiredDialogView::GetWindowIcon() {
return gfx::CreateVectorIcon( return gfx::CreateVectorIcon(
gfx::IconDescription(vector_icons::kBusinessIcon, gfx::IconDescription(vector_icons::kBusinessIcon,
...@@ -78,13 +70,6 @@ gfx::ImageSkia RelaunchRequiredDialogView::GetWindowIcon() { ...@@ -78,13 +70,6 @@ gfx::ImageSkia RelaunchRequiredDialogView::GetWindowIcon() {
gfx::kChromeIconGrey)); gfx::kChromeIconGrey));
} }
gfx::Size RelaunchRequiredDialogView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
// |relaunch_required_timer_| automatically starts for the next time the title // |relaunch_required_timer_| automatically starts for the next time the title
// needs to be updated (e.g., from "2 days" to "3 days"). // needs to be updated (e.g., from "2 days" to "3 days").
RelaunchRequiredDialogView::RelaunchRequiredDialogView( RelaunchRequiredDialogView::RelaunchRequiredDialogView(
...@@ -110,6 +95,12 @@ RelaunchRequiredDialogView::RelaunchRequiredDialogView( ...@@ -110,6 +95,12 @@ RelaunchRequiredDialogView::RelaunchRequiredDialogView(
SetCancelCallback(base::BindOnce( SetCancelCallback(base::BindOnce(
base::RecordAction, base::UserMetricsAction("RelaunchRequired_Close"))); base::RecordAction, base::UserMetricsAction("RelaunchRequired_Close")));
SetLayoutManager(std::make_unique<views::FillLayout>()); SetLayoutManager(std::make_unique<views::FillLayout>());
SetModalType(ui::MODAL_TYPE_WINDOW);
SetShowCloseButton(false);
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
chrome::RecordDialogCreation(chrome::DialogIdentifier::RELAUNCH_REQUIRED); chrome::RecordDialogCreation(chrome::DialogIdentifier::RELAUNCH_REQUIRED);
const ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); const ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
set_margins( set_margins(
......
...@@ -38,15 +38,9 @@ class RelaunchRequiredDialogView : views::DialogDelegateView { ...@@ -38,15 +38,9 @@ class RelaunchRequiredDialogView : views::DialogDelegateView {
void SetDeadline(base::Time deadline); void SetDeadline(base::Time deadline);
// views::DialogDelegateView: // views::DialogDelegateView:
ui::ModalType GetModalType() const override;
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
bool ShouldShowCloseButton() const override;
gfx::ImageSkia GetWindowIcon() override; gfx::ImageSkia GetWindowIcon() override;
protected:
// views::DialogDelegateView:
gfx::Size CalculatePreferredSize() const override;
private: private:
RelaunchRequiredDialogView(base::Time deadline, RelaunchRequiredDialogView(base::Time deadline,
base::RepeatingClosure on_accept); base::RepeatingClosure on_accept);
......
...@@ -73,7 +73,11 @@ WebAppUninstallDialogDelegateView::WebAppUninstallDialogDelegateView( ...@@ -73,7 +73,11 @@ WebAppUninstallDialogDelegateView::WebAppUninstallDialogDelegateView(
std::make_unique<WebAppInfoImageSource>(kIconSizeInDip, icon_bitmaps), std::make_unique<WebAppInfoImageSource>(kIconSizeInDip, icon_bitmaps),
image_size); image_size);
SetModalType(ui::MODAL_TYPE_WINDOW);
SetShowCloseButton(false); SetShowCloseButton(false);
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
SetShowIcon(true); SetShowIcon(true);
SetTitle(l10n_util::GetStringFUTF16( SetTitle(l10n_util::GetStringFUTF16(
IDS_EXTENSION_PROMPT_UNINSTALL_TITLE, IDS_EXTENSION_PROMPT_UNINSTALL_TITLE,
...@@ -143,17 +147,6 @@ void WebAppUninstallDialogDelegateView::OnDialogCanceled() { ...@@ -143,17 +147,6 @@ void WebAppUninstallDialogDelegateView::OnDialogCanceled() {
std::exchange(dialog_, nullptr)->CallCallback(/*uninstalled=*/false); std::exchange(dialog_, nullptr)->CallCallback(/*uninstalled=*/false);
} }
gfx::Size WebAppUninstallDialogDelegateView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
ui::ModalType WebAppUninstallDialogDelegateView::GetModalType() const {
return ui::MODAL_TYPE_WINDOW;
}
gfx::ImageSkia WebAppUninstallDialogDelegateView::GetWindowIcon() { gfx::ImageSkia WebAppUninstallDialogDelegateView::GetWindowIcon() {
return image_; return image_;
} }
......
...@@ -51,10 +51,6 @@ class WebAppUninstallDialogDelegateView : public views::DialogDelegateView { ...@@ -51,10 +51,6 @@ class WebAppUninstallDialogDelegateView : public views::DialogDelegateView {
private: private:
// views::DialogDelegateView: // views::DialogDelegateView:
gfx::Size CalculatePreferredSize() const override;
// views::WidgetDelegate:
ui::ModalType GetModalType() const override;
gfx::ImageSkia GetWindowIcon() override; gfx::ImageSkia GetWindowIcon() override;
// Uninstalls the web app. Returns true on success. // Uninstalls the web app. Returns true on success.
......
...@@ -149,12 +149,6 @@ bool AuthenticatorRequestDialogView::ShouldOtherTransportsButtonBeVisible() ...@@ -149,12 +149,6 @@ bool AuthenticatorRequestDialogView::ShouldOtherTransportsButtonBeVisible()
sheet_->model()->GetOtherTransportsMenuModel()->GetItemCount(); sheet_->model()->GetOtherTransportsMenuModel()->GetItemCount();
} }
gfx::Size AuthenticatorRequestDialogView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH);
return gfx::Size(width, GetHeightForWidth(width));
}
bool AuthenticatorRequestDialogView::Accept() { bool AuthenticatorRequestDialogView::Accept() {
sheet()->model()->OnAccept(); sheet()->model()->OnAccept();
return false; return false;
...@@ -206,22 +200,10 @@ views::View* AuthenticatorRequestDialogView::GetInitiallyFocusedView() { ...@@ -206,22 +200,10 @@ views::View* AuthenticatorRequestDialogView::GetInitiallyFocusedView() {
return nullptr; return nullptr;
} }
ui::ModalType AuthenticatorRequestDialogView::GetModalType() const {
return ui::MODAL_TYPE_CHILD;
}
base::string16 AuthenticatorRequestDialogView::GetWindowTitle() const { base::string16 AuthenticatorRequestDialogView::GetWindowTitle() const {
return sheet()->model()->GetStepTitle(); return sheet()->model()->GetStepTitle();
} }
bool AuthenticatorRequestDialogView::ShouldShowWindowTitle() const {
return false;
}
bool AuthenticatorRequestDialogView::ShouldShowCloseButton() const {
return false;
}
void AuthenticatorRequestDialogView::OnModelDestroyed() { void AuthenticatorRequestDialogView::OnModelDestroyed() {
NOTREACHED(); NOTREACHED();
} }
...@@ -282,6 +264,7 @@ AuthenticatorRequestDialogView::AuthenticatorRequestDialogView( ...@@ -282,6 +264,7 @@ AuthenticatorRequestDialogView::AuthenticatorRequestDialogView(
l10n_util::GetStringUTF16(IDS_WEBAUTHN_TRANSPORT_POPUP_LABEL)))), l10n_util::GetStringUTF16(IDS_WEBAUTHN_TRANSPORT_POPUP_LABEL)))),
web_contents_hidden_(web_contents->GetVisibility() == web_contents_hidden_(web_contents->GetVisibility() ==
content::Visibility::HIDDEN) { content::Visibility::HIDDEN) {
SetShowTitle(false);
DCHECK(!model_->should_dialog_be_closed()); DCHECK(!model_->should_dialog_be_closed());
model_->AddObserver(this); model_->AddObserver(this);
...@@ -289,6 +272,11 @@ AuthenticatorRequestDialogView::AuthenticatorRequestDialogView( ...@@ -289,6 +272,11 @@ AuthenticatorRequestDialogView::AuthenticatorRequestDialogView(
base::BindOnce(&AuthenticatorRequestDialogView::OnDialogClosing, base::BindOnce(&AuthenticatorRequestDialogView::OnDialogClosing,
base::Unretained(this))); base::Unretained(this)));
SetModalType(ui::MODAL_TYPE_CHILD);
SetShowCloseButton(false);
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
// Currently, all sheets have a label on top and controls at the bottom. // Currently, all sheets have a label on top and controls at the bottom.
// Consider moving this to AuthenticatorRequestSheetView if this changes. // Consider moving this to AuthenticatorRequestSheetView if this changes.
SetLayoutManager(std::make_unique<views::FillLayout>()); SetLayoutManager(std::make_unique<views::FillLayout>());
......
...@@ -63,15 +63,11 @@ class AuthenticatorRequestDialogView ...@@ -63,15 +63,11 @@ class AuthenticatorRequestDialogView
} }
// views::DialogDelegateView: // views::DialogDelegateView:
gfx::Size CalculatePreferredSize() const override;
bool Accept() override; bool Accept() override;
bool Cancel() override; bool Cancel() override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override; bool IsDialogButtonEnabled(ui::DialogButton button) const override;
View* GetInitiallyFocusedView() override; View* GetInitiallyFocusedView() override;
ui::ModalType GetModalType() const override;
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
bool ShouldShowWindowTitle() const override;
bool ShouldShowCloseButton() const override;
// AuthenticatorRequestDialogModel::Observer: // AuthenticatorRequestDialogModel::Observer:
void OnModelDestroyed() override; void OnModelDestroyed() 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