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

Use set_fixed_width() for *_BUBBLE_PREFERRED_WIDTH

Removes CalculatePreferredSize() use for a chunk of remaining dialogs
that specify a fixed preferred width.

Bug: 1128500
Change-Id: Ib8c072f758a1ae7e3532c5472181be8229e1f53b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2493666
Commit-Queue: Peter Boström <pbos@chromium.org>
Reviewed-by: default avatarCharlene Yan <cyan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820405}
parent 5ab05eb5
...@@ -60,6 +60,10 @@ LocalCardMigrationBubbleViews::LocalCardMigrationBubbleViews( ...@@ -60,6 +60,10 @@ LocalCardMigrationBubbleViews::LocalCardMigrationBubbleViews(
SetAcceptCallback( SetAcceptCallback(
base::BindOnce(&LocalCardMigrationBubbleViews::OnDialogAccepted, base::BindOnce(&LocalCardMigrationBubbleViews::OnDialogAccepted,
base::Unretained(this))); base::Unretained(this)));
SetShowCloseButton(true);
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH));
} }
void LocalCardMigrationBubbleViews::Show(DisplayReason reason) { void LocalCardMigrationBubbleViews::Show(DisplayReason reason) {
...@@ -91,13 +95,6 @@ void LocalCardMigrationBubbleViews::OnDialogCancelled() { ...@@ -91,13 +95,6 @@ void LocalCardMigrationBubbleViews::OnDialogCancelled() {
controller_->OnCancelButtonClicked(); controller_->OnCancelButtonClicked();
} }
gfx::Size LocalCardMigrationBubbleViews::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
void LocalCardMigrationBubbleViews::AddedToWidget() { void LocalCardMigrationBubbleViews::AddedToWidget() {
auto title_container = std::make_unique<views::View>(); auto title_container = std::make_unique<views::View>();
title_container->SetLayoutManager(std::make_unique<views::BoxLayout>( title_container->SetLayoutManager(std::make_unique<views::BoxLayout>(
...@@ -139,10 +136,6 @@ void LocalCardMigrationBubbleViews::AddedToWidget() { ...@@ -139,10 +136,6 @@ void LocalCardMigrationBubbleViews::AddedToWidget() {
GetBubbleFrameView()->SetTitleView(std::move(title_container)); GetBubbleFrameView()->SetTitleView(std::move(title_container));
} }
bool LocalCardMigrationBubbleViews::ShouldShowCloseButton() const {
return true;
}
base::string16 LocalCardMigrationBubbleViews::GetWindowTitle() const { base::string16 LocalCardMigrationBubbleViews::GetWindowTitle() const {
return controller_ ? l10n_util::GetStringUTF16( return controller_ ? l10n_util::GetStringUTF16(
IDS_AUTOFILL_LOCAL_CARD_MIGRATION_BUBBLE_TITLE) IDS_AUTOFILL_LOCAL_CARD_MIGRATION_BUBBLE_TITLE)
......
...@@ -35,9 +35,7 @@ class LocalCardMigrationBubbleViews : public LocalCardMigrationBubble, ...@@ -35,9 +35,7 @@ class LocalCardMigrationBubbleViews : public LocalCardMigrationBubble,
void Hide() override; void Hide() override;
// LocationBarBubbleDelegateView: // LocationBarBubbleDelegateView:
gfx::Size CalculatePreferredSize() const override;
void AddedToWidget() override; void AddedToWidget() override;
bool ShouldShowCloseButton() const override;
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
void WindowClosing() override; void WindowClosing() override;
void OnWidgetClosing(views::Widget* widget) override; void OnWidgetClosing(views::Widget* widget) override;
......
...@@ -52,13 +52,17 @@ SaveCardBubbleViews::SaveCardBubbleViews(views::View* anchor_view, ...@@ -52,13 +52,17 @@ SaveCardBubbleViews::SaveCardBubbleViews(views::View* anchor_view,
SaveCardBubbleController* controller) SaveCardBubbleController* controller)
: LocationBarBubbleDelegateView(anchor_view, web_contents), : LocationBarBubbleDelegateView(anchor_view, web_contents),
controller_(controller) { controller_(controller) {
DCHECK(controller);
SetButtonLabel(ui::DIALOG_BUTTON_OK, controller->GetAcceptButtonText()); SetButtonLabel(ui::DIALOG_BUTTON_OK, controller->GetAcceptButtonText());
SetButtonLabel(ui::DIALOG_BUTTON_CANCEL, controller->GetDeclineButtonText()); SetButtonLabel(ui::DIALOG_BUTTON_CANCEL, controller->GetDeclineButtonText());
SetCancelCallback(base::BindOnce(&SaveCardBubbleViews::OnDialogCancelled, SetCancelCallback(base::BindOnce(&SaveCardBubbleViews::OnDialogCancelled,
base::Unretained(this))); base::Unretained(this)));
SetAcceptCallback(base::BindOnce(&SaveCardBubbleViews::OnDialogAccepted, SetAcceptCallback(base::BindOnce(&SaveCardBubbleViews::OnDialogAccepted,
base::Unretained(this))); base::Unretained(this)));
DCHECK(controller);
SetShowCloseButton(true);
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH));
chrome::RecordDialogCreation(chrome::DialogIdentifier::SAVE_CARD); chrome::RecordDialogCreation(chrome::DialogIdentifier::SAVE_CARD);
} }
...@@ -92,13 +96,6 @@ void SaveCardBubbleViews::OnDialogCancelled() { ...@@ -92,13 +96,6 @@ void SaveCardBubbleViews::OnDialogCancelled() {
controller_->OnCancelButton(); controller_->OnCancelButton();
} }
gfx::Size SaveCardBubbleViews::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
void SaveCardBubbleViews::AddedToWidget() { void SaveCardBubbleViews::AddedToWidget() {
// Use a custom title container if offering to upload a server card. // Use a custom title container if offering to upload a server card.
// Done when this view is added to the widget, so the bubble frame // Done when this view is added to the widget, so the bubble frame
...@@ -110,10 +107,6 @@ void SaveCardBubbleViews::AddedToWidget() { ...@@ -110,10 +107,6 @@ void SaveCardBubbleViews::AddedToWidget() {
std::make_unique<TitleWithIconAndSeparatorView>(GetWindowTitle())); std::make_unique<TitleWithIconAndSeparatorView>(GetWindowTitle()));
} }
bool SaveCardBubbleViews::ShouldShowCloseButton() const {
return true;
}
base::string16 SaveCardBubbleViews::GetWindowTitle() const { base::string16 SaveCardBubbleViews::GetWindowTitle() const {
return controller_ ? controller_->GetWindowTitle() : base::string16(); return controller_ ? controller_->GetWindowTitle() : base::string16();
} }
......
...@@ -39,12 +39,8 @@ class SaveCardBubbleViews : public SaveCardBubbleView, ...@@ -39,12 +39,8 @@ class SaveCardBubbleViews : public SaveCardBubbleView,
// SaveCardBubbleView: // SaveCardBubbleView:
void Hide() override; void Hide() override;
// views::View: // LocationBarBubbleDelegateView:
gfx::Size CalculatePreferredSize() const override;
void AddedToWidget() override; void AddedToWidget() override;
// views::WidgetDelegate:
bool ShouldShowCloseButton() const override;
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
void WindowClosing() override; void WindowClosing() override;
void OnWidgetClosing(views::Widget* widget) override; void OnWidgetClosing(views::Widget* widget) override;
...@@ -86,7 +82,7 @@ class SaveCardBubbleViews : public SaveCardBubbleView, ...@@ -86,7 +82,7 @@ class SaveCardBubbleViews : public SaveCardBubbleView,
// Attributes IDs to the dialog's DialogDelegate-supplied buttons. // Attributes IDs to the dialog's DialogDelegate-supplied buttons.
void AssignIdsToDialogButtons(); void AssignIdsToDialogButtons();
// views::BubbleDialogDelegateView: // LocationBarBubbleDelegateView:
void Init() override; void Init() override;
void OnDialogAccepted(); void OnDialogAccepted();
......
...@@ -20,12 +20,16 @@ SaveUPIOfferBubbleViews::SaveUPIOfferBubbleViews( ...@@ -20,12 +20,16 @@ SaveUPIOfferBubbleViews::SaveUPIOfferBubbleViews(
controller_(controller) { controller_(controller) {
DCHECK(controller_); DCHECK(controller_);
SetTitle(l10n_util::GetStringUTF16(IDS_AUTOFILL_SAVE_UPI_PROMPT_TITLE));
SetButtonLabel( SetButtonLabel(
ui::DIALOG_BUTTON_OK, ui::DIALOG_BUTTON_OK,
l10n_util::GetStringUTF16(IDS_AUTOFILL_SAVE_UPI_PROMPT_ACCEPT)); l10n_util::GetStringUTF16(IDS_AUTOFILL_SAVE_UPI_PROMPT_ACCEPT));
SetButtonLabel( SetButtonLabel(
ui::DIALOG_BUTTON_CANCEL, ui::DIALOG_BUTTON_CANCEL,
l10n_util::GetStringUTF16(IDS_AUTOFILL_SAVE_UPI_PROMPT_REJECT)); l10n_util::GetStringUTF16(IDS_AUTOFILL_SAVE_UPI_PROMPT_REJECT));
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH));
} }
SaveUPIOfferBubbleViews::~SaveUPIOfferBubbleViews() = default; SaveUPIOfferBubbleViews::~SaveUPIOfferBubbleViews() = default;
...@@ -34,22 +38,11 @@ void SaveUPIOfferBubbleViews::Show() { ...@@ -34,22 +38,11 @@ void SaveUPIOfferBubbleViews::Show() {
ShowForReason(LocationBarBubbleDelegateView::DisplayReason::AUTOMATIC); ShowForReason(LocationBarBubbleDelegateView::DisplayReason::AUTOMATIC);
} }
gfx::Size SaveUPIOfferBubbleViews::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
bool SaveUPIOfferBubbleViews::Accept() { bool SaveUPIOfferBubbleViews::Accept() {
controller_->OnAccept(); controller_->OnAccept();
return true; return true;
} }
base::string16 SaveUPIOfferBubbleViews::GetWindowTitle() const {
return l10n_util::GetStringUTF16(IDS_AUTOFILL_SAVE_UPI_PROMPT_TITLE);
}
void SaveUPIOfferBubbleViews::Hide() { void SaveUPIOfferBubbleViews::Hide() {
if (controller_) if (controller_)
controller_->OnBubbleClosed(); controller_->OnBubbleClosed();
......
...@@ -31,20 +31,14 @@ class SaveUPIOfferBubbleViews : public autofill::SaveUPIBubble, ...@@ -31,20 +31,14 @@ class SaveUPIOfferBubbleViews : public autofill::SaveUPIBubble,
// Displays the bubble. // Displays the bubble.
void Show(); void Show();
// LocationBarBubbleDelegateView:
gfx::Size CalculatePreferredSize() const override;
private: private:
// views::View: // views::View:
bool Accept() override; bool Accept() override;
// views::WidgetDelegate:
base::string16 GetWindowTitle() const override;
// autofill::SaveUPIBubble: // autofill::SaveUPIBubble:
void Hide() override; void Hide() override;
// views::BubbleDialogDelegateView: // LocationBarBubbleDelegateView:
void Init() override; void Init() override;
~SaveUPIOfferBubbleViews() override; ~SaveUPIOfferBubbleViews() override;
......
...@@ -74,13 +74,6 @@ base::string16 CrostiniAnsibleSoftwareConfigView::GetSubtextLabel() const { ...@@ -74,13 +74,6 @@ base::string16 CrostiniAnsibleSoftwareConfigView::GetSubtextLabel() const {
} }
} }
gfx::Size CrostiniAnsibleSoftwareConfigView::CalculatePreferredSize() const {
const int dialog_width = ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_STANDALONE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(dialog_width, GetHeightForWidth(dialog_width));
}
void CrostiniAnsibleSoftwareConfigView:: void CrostiniAnsibleSoftwareConfigView::
OnAnsibleSoftwareConfigurationStarted() {} OnAnsibleSoftwareConfigurationStarted() {}
...@@ -119,6 +112,9 @@ CrostiniAnsibleSoftwareConfigView::CrostiniAnsibleSoftwareConfigView( ...@@ -119,6 +112,9 @@ CrostiniAnsibleSoftwareConfigView::CrostiniAnsibleSoftwareConfigView(
crostini::AnsibleManagementService::GetForProfile(profile)) { crostini::AnsibleManagementService::GetForProfile(profile)) {
ansible_management_service_->AddObserver(this); ansible_management_service_->AddObserver(this);
set_fixed_width(ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_STANDALONE_BUBBLE_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,
......
...@@ -22,7 +22,6 @@ class CrostiniAnsibleSoftwareConfigView ...@@ -22,7 +22,6 @@ class CrostiniAnsibleSoftwareConfigView
public: public:
// views::DialogDelegateView: // views::DialogDelegateView:
bool Accept() override; bool Accept() override;
gfx::Size CalculatePreferredSize() const override;
// crostini::AnsibleManagementService::Observer: // crostini::AnsibleManagementService::Observer:
void OnAnsibleSoftwareConfigurationStarted() override; void OnAnsibleSoftwareConfigurationStarted() override;
......
...@@ -62,13 +62,6 @@ void CrostiniRecoveryView::Show(Profile* profile, ...@@ -62,13 +62,6 @@ void CrostiniRecoveryView::Show(Profile* profile,
g_crostini_recovery_view->GetWidget()->Show(); g_crostini_recovery_view->GetWidget()->Show();
} }
gfx::Size CrostiniRecoveryView::CalculatePreferredSize() const {
const int dialog_width = ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_STANDALONE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(dialog_width, GetHeightForWidth(dialog_width));
}
bool CrostiniRecoveryView::Accept() { bool CrostiniRecoveryView::Accept() {
SetButtonEnabled(ui::DIALOG_BUTTON_OK, false); SetButtonEnabled(ui::DIALOG_BUTTON_OK, false);
SetButtonEnabled(ui::DIALOG_BUTTON_CANCEL, false); SetButtonEnabled(ui::DIALOG_BUTTON_CANCEL, false);
...@@ -126,6 +119,8 @@ CrostiniRecoveryView::CrostiniRecoveryView( ...@@ -126,6 +119,8 @@ CrostiniRecoveryView::CrostiniRecoveryView(
l10n_util::GetStringUTF16(IDS_CROSTINI_RECOVERY_TERMINAL_BUTTON)); l10n_util::GetStringUTF16(IDS_CROSTINI_RECOVERY_TERMINAL_BUTTON));
SetShowCloseButton(false); SetShowCloseButton(false);
SetTitle(IDS_CROSTINI_RECOVERY_TITLE); SetTitle(IDS_CROSTINI_RECOVERY_TITLE);
set_fixed_width(ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_STANDALONE_BUBBLE_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>(
......
...@@ -27,7 +27,6 @@ class CrostiniRecoveryView : public views::BubbleDialogDelegateView { ...@@ -27,7 +27,6 @@ class CrostiniRecoveryView : public views::BubbleDialogDelegateView {
crostini::CrostiniSuccessCallback callback); crostini::CrostiniSuccessCallback callback);
// views::DialogDelegateView: // views::DialogDelegateView:
gfx::Size CalculatePreferredSize() const override;
bool Accept() override; bool Accept() override;
bool Cancel() override; bool Cancel() override;
......
...@@ -78,13 +78,6 @@ bool CrostiniUninstallerView::Cancel() { ...@@ -78,13 +78,6 @@ bool CrostiniUninstallerView::Cancel() {
return true; // Should close the dialog return true; // Should close the dialog
} }
gfx::Size CrostiniUninstallerView::CalculatePreferredSize() const {
const int dialog_width = ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_STANDALONE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(dialog_width, GetHeightForWidth(dialog_width));
}
// static // static
CrostiniUninstallerView* CrostiniUninstallerView::GetActiveViewForTesting() { CrostiniUninstallerView* CrostiniUninstallerView::GetActiveViewForTesting() {
return g_crostini_uninstaller_view; return g_crostini_uninstaller_view;
...@@ -97,7 +90,8 @@ CrostiniUninstallerView::CrostiniUninstallerView(Profile* profile) ...@@ -97,7 +90,8 @@ CrostiniUninstallerView::CrostiniUninstallerView(Profile* profile)
SetButtonLabel( SetButtonLabel(
ui::DIALOG_BUTTON_OK, ui::DIALOG_BUTTON_OK,
l10n_util::GetStringUTF16(IDS_CROSTINI_UNINSTALLER_UNINSTALL_BUTTON)); l10n_util::GetStringUTF16(IDS_CROSTINI_UNINSTALLER_UNINSTALL_BUTTON));
set_fixed_width(ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_STANDALONE_BUBBLE_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,7 +36,6 @@ class CrostiniUninstallerView : public views::BubbleDialogDelegateView { ...@@ -36,7 +36,6 @@ class CrostiniUninstallerView : public views::BubbleDialogDelegateView {
// views::DialogDelegateView: // views::DialogDelegateView:
bool Accept() override; bool Accept() override;
bool Cancel() override; bool Cancel() override;
gfx::Size CalculatePreferredSize() const override;
static CrostiniUninstallerView* GetActiveViewForTesting(); static CrostiniUninstallerView* GetActiveViewForTesting();
void set_destructor_callback_for_testing(base::OnceClosure callback) { void set_destructor_callback_for_testing(base::OnceClosure callback) {
......
...@@ -46,13 +46,6 @@ void CrostiniUpdateComponentView::Show(Profile* profile) { ...@@ -46,13 +46,6 @@ void CrostiniUpdateComponentView::Show(Profile* profile) {
g_crostini_upgrade_view->GetWidget()->Show(); g_crostini_upgrade_view->GetWidget()->Show();
} }
gfx::Size CrostiniUpdateComponentView::CalculatePreferredSize() const {
const int dialog_width = ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_STANDALONE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(dialog_width, GetHeightForWidth(dialog_width));
}
// static // static
CrostiniUpdateComponentView* CrostiniUpdateComponentView*
CrostiniUpdateComponentView::GetActiveViewForTesting() { CrostiniUpdateComponentView::GetActiveViewForTesting() {
...@@ -63,6 +56,8 @@ CrostiniUpdateComponentView::CrostiniUpdateComponentView() { ...@@ -63,6 +56,8 @@ CrostiniUpdateComponentView::CrostiniUpdateComponentView() {
SetButtons(ui::DIALOG_BUTTON_OK); SetButtons(ui::DIALOG_BUTTON_OK);
SetShowCloseButton(false); SetShowCloseButton(false);
SetTitle(IDS_CROSTINI_TERMINA_UPDATE_REQUIRED); SetTitle(IDS_CROSTINI_TERMINA_UPDATE_REQUIRED);
set_fixed_width(ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_STANDALONE_BUBBLE_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>(
......
...@@ -19,9 +19,6 @@ class CrostiniUpdateComponentView : public views::BubbleDialogDelegateView { ...@@ -19,9 +19,6 @@ class CrostiniUpdateComponentView : public views::BubbleDialogDelegateView {
public: public:
static void Show(Profile* profile); static void Show(Profile* profile);
// views::DialogDelegateView:
gfx::Size CalculatePreferredSize() const override;
static CrostiniUpdateComponentView* GetActiveViewForTesting(); static CrostiniUpdateComponentView* GetActiveViewForTesting();
private: private:
......
...@@ -90,13 +90,6 @@ void CrostiniUpdateFilesystemView::Show(Profile* profile) { ...@@ -90,13 +90,6 @@ void CrostiniUpdateFilesystemView::Show(Profile* profile) {
g_crostini_update_filesystem_view_dialog->GetWidget()->Show(); g_crostini_update_filesystem_view_dialog->GetWidget()->Show();
} }
gfx::Size CrostiniUpdateFilesystemView::CalculatePreferredSize() const {
const int dialog_width = ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_STANDALONE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(dialog_width, GetHeightForWidth(dialog_width));
}
// static // static
CrostiniUpdateFilesystemView* CrostiniUpdateFilesystemView*
CrostiniUpdateFilesystemView::GetActiveViewForTesting() { CrostiniUpdateFilesystemView::GetActiveViewForTesting() {
...@@ -110,6 +103,9 @@ CrostiniUpdateFilesystemView::CrostiniUpdateFilesystemView() { ...@@ -110,6 +103,9 @@ CrostiniUpdateFilesystemView::CrostiniUpdateFilesystemView() {
SetTitle(IDS_CROSTINI_UPGRADING_LABEL); SetTitle(IDS_CROSTINI_UPGRADING_LABEL);
SetButtons(ui::DIALOG_BUTTON_OK); SetButtons(ui::DIALOG_BUTTON_OK);
set_fixed_width(ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_STANDALONE_BUBBLE_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,
......
...@@ -19,9 +19,6 @@ class CrostiniUpdateFilesystemView : public views::BubbleDialogDelegateView { ...@@ -19,9 +19,6 @@ class CrostiniUpdateFilesystemView : public views::BubbleDialogDelegateView {
public: public:
static void Show(Profile* profile); static void Show(Profile* profile);
// views::DialogDelegateView:
gfx::Size CalculatePreferredSize() const override;
static CrostiniUpdateFilesystemView* GetActiveViewForTesting(); static CrostiniUpdateFilesystemView* GetActiveViewForTesting();
private: private:
......
...@@ -52,7 +52,6 @@ class DownloadDangerPromptViews : public DownloadDangerPrompt, ...@@ -52,7 +52,6 @@ class DownloadDangerPromptViews : public DownloadDangerPrompt,
void InvokeActionForTesting(Action action) override; void InvokeActionForTesting(Action action) override;
// views::DialogDelegateView: // views::DialogDelegateView:
gfx::Size CalculatePreferredSize() const override;
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
ui::ModalType GetModalType() const override; ui::ModalType GetModalType() const override;
...@@ -89,6 +88,9 @@ DownloadDangerPromptViews::DownloadDangerPromptViews( ...@@ -89,6 +88,9 @@ DownloadDangerPromptViews::DownloadDangerPromptViews(
? l10n_util::GetStringUTF16(IDS_CONFIRM_DOWNLOAD) ? l10n_util::GetStringUTF16(IDS_CONFIRM_DOWNLOAD)
: l10n_util::GetStringUTF16(IDS_CONFIRM_DOWNLOAD_AGAIN)); : l10n_util::GetStringUTF16(IDS_CONFIRM_DOWNLOAD_AGAIN));
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH));
auto make_done_callback = [&](DownloadDangerPrompt::Action action) { auto make_done_callback = [&](DownloadDangerPrompt::Action action) {
return base::BindOnce(&DownloadDangerPromptViews::RunDone, return base::BindOnce(&DownloadDangerPromptViews::RunDone,
base::Unretained(this), action); base::Unretained(this), action);
...@@ -182,13 +184,6 @@ void DownloadDangerPromptViews::OnDownloadUpdated( ...@@ -182,13 +184,6 @@ void DownloadDangerPromptViews::OnDownloadUpdated(
} }
} }
gfx::Size DownloadDangerPromptViews::CalculatePreferredSize() const {
int preferred_width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(preferred_width, GetHeightForWidth(preferred_width));
}
base::string16 DownloadDangerPromptViews::GetMessageBody() const { base::string16 DownloadDangerPromptViews::GetMessageBody() const {
if (show_context_) { if (show_context_) {
switch (download_->GetDangerType()) { switch (download_->GetDangerType()) {
......
...@@ -111,6 +111,13 @@ gfx::Size DialogClientView::CalculatePreferredSize() const { ...@@ -111,6 +111,13 @@ gfx::Size DialogClientView::CalculatePreferredSize() const {
} }
gfx::Size DialogClientView::GetMinimumSize() const { gfx::Size DialogClientView::GetMinimumSize() const {
// TODO(pbos): Try to find a way for ClientView::GetMinimumSize() to be
// fixed-width aware. For now this uses min-size = preferred size for
// fixed-width dialogs (even though min height might not be preferred height).
// Fixing this might require View::GetMinHeightForWidth().
if (GetDialogDelegate()->fixed_width())
return CalculatePreferredSize();
return GetBoundingSizeForVerticalStack( return GetBoundingSizeForVerticalStack(
ClientView::GetMinimumSize(), button_row_container_->GetMinimumSize()); ClientView::GetMinimumSize(), button_row_container_->GetMinimumSize());
} }
......
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