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

Use SetFixedWidth for BubbleDialog* subclasses

Removes a few CalculatePreferredSize overrides that try to end up with
the same fixed width.

Bug: 1128500
Change-Id: If0fbc457aac34fe0dc64e548bf75573553573393
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2469839Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#817105}
parent a7d0843c
...@@ -15,20 +15,15 @@ ...@@ -15,20 +15,15 @@
AppDialogView::AppDialogView(const gfx::ImageSkia& image) AppDialogView::AppDialogView(const gfx::ImageSkia& image)
: BubbleDialogDelegateView(nullptr, views::BubbleBorder::NONE) { : BubbleDialogDelegateView(nullptr, views::BubbleBorder::NONE) {
SetIcon(image); SetIcon(image);
SetModalType(ui::MODAL_TYPE_WINDOW);
SetShowCloseButton(false);
SetShowIcon(true); SetShowIcon(true);
SetShowCloseButton(false);
SetModalType(ui::MODAL_TYPE_WINDOW);
SetFixedWidth(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
} }
AppDialogView::~AppDialogView() = default; AppDialogView::~AppDialogView() = default;
gfx::Size AppDialogView::CalculatePreferredSize() const {
const int default_width = views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(default_width, GetHeightForWidth(default_width));
}
void AppDialogView::InitializeView(const base::string16& heading_text) { void AppDialogView::InitializeView(const base::string16& heading_text) {
SetButtons(ui::DIALOG_BUTTON_OK); SetButtons(ui::DIALOG_BUTTON_OK);
ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
......
...@@ -19,9 +19,6 @@ class AppDialogView : public views::BubbleDialogDelegateView { ...@@ -19,9 +19,6 @@ class AppDialogView : public views::BubbleDialogDelegateView {
explicit AppDialogView(const gfx::ImageSkia& image); explicit AppDialogView(const gfx::ImageSkia& image);
~AppDialogView() override; ~AppDialogView() override;
// views::BubbleDialogDelegateView:
gfx::Size CalculatePreferredSize() const override;
protected: protected:
void InitializeView(const base::string16& heading_text); void InitializeView(const base::string16& heading_text);
}; };
......
...@@ -71,6 +71,10 @@ CardUnmaskPromptViews::CardUnmaskPromptViews( ...@@ -71,6 +71,10 @@ CardUnmaskPromptViews::CardUnmaskPromptViews(
: controller_(controller), web_contents_(web_contents) { : controller_(controller), web_contents_(web_contents) {
chrome::RecordDialogCreation(chrome::DialogIdentifier::CARD_UNMASK); chrome::RecordDialogCreation(chrome::DialogIdentifier::CARD_UNMASK);
UpdateButtons(); UpdateButtons();
SetModalType(ui::MODAL_TYPE_CHILD);
SetFixedWidth(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
} }
CardUnmaskPromptViews::~CardUnmaskPromptViews() { CardUnmaskPromptViews::~CardUnmaskPromptViews() {
...@@ -207,16 +211,6 @@ views::View* CardUnmaskPromptViews::GetContentsView() { ...@@ -207,16 +211,6 @@ views::View* CardUnmaskPromptViews::GetContentsView() {
return this; return this;
} }
gfx::Size CardUnmaskPromptViews::CalculatePreferredSize() const {
// If the margins width is not discounted here, the bubble border will be
// taken into consideration in the frame width size. Because of that, the
// dialog width will be snapped to a larger size when Harmony is enabled.
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
void CardUnmaskPromptViews::AddedToWidget() { void CardUnmaskPromptViews::AddedToWidget() {
GetBubbleFrameView()->SetTitleView( GetBubbleFrameView()->SetTitleView(
std::make_unique<TitleWithIconAndSeparatorView>(GetWindowTitle())); std::make_unique<TitleWithIconAndSeparatorView>(GetWindowTitle()));
...@@ -231,10 +225,6 @@ void CardUnmaskPromptViews::OnThemeChanged() { ...@@ -231,10 +225,6 @@ void CardUnmaskPromptViews::OnThemeChanged() {
overlay_label_->SetBackgroundColor(bg_color); overlay_label_->SetBackgroundColor(bg_color);
} }
ui::ModalType CardUnmaskPromptViews::GetModalType() const {
return ui::MODAL_TYPE_CHILD;
}
base::string16 CardUnmaskPromptViews::GetWindowTitle() const { base::string16 CardUnmaskPromptViews::GetWindowTitle() const {
return controller_->GetWindowTitle(); return controller_->GetWindowTitle();
} }
......
...@@ -45,14 +45,10 @@ class CardUnmaskPromptViews : public CardUnmaskPromptView, ...@@ -45,14 +45,10 @@ class CardUnmaskPromptViews : public CardUnmaskPromptView,
void GotVerificationResult(const base::string16& error_message, void GotVerificationResult(const base::string16& error_message,
bool allow_retry) override; bool allow_retry) override;
// views::DialogDelegateView // views::BubbleDialogDelegateView:
View* GetContentsView() override; View* GetContentsView() override;
// views::View
gfx::Size CalculatePreferredSize() const override;
void AddedToWidget() override; void AddedToWidget() override;
void OnThemeChanged() override; void OnThemeChanged() override;
ui::ModalType GetModalType() const override;
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
void DeleteDelegate() override; void DeleteDelegate() override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override; bool IsDialogButtonEnabled(ui::DialogButton button) const override;
......
...@@ -358,6 +358,8 @@ LocalCardMigrationDialogView::LocalCardMigrationDialogView( ...@@ -358,6 +358,8 @@ LocalCardMigrationDialogView::LocalCardMigrationDialogView(
&LocalCardMigrationDialogView::OnDialogAccepted, base::Unretained(this))); &LocalCardMigrationDialogView::OnDialogAccepted, base::Unretained(this)));
set_close_on_deactivate(false); set_close_on_deactivate(false);
set_margins(gfx::Insets()); set_margins(gfx::Insets());
SetFixedWidth(ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_LARGE_MODAL_DIALOG_PREFERRED_WIDTH));
} }
LocalCardMigrationDialogView::~LocalCardMigrationDialogView() {} LocalCardMigrationDialogView::~LocalCardMigrationDialogView() {}
...@@ -374,13 +376,6 @@ void LocalCardMigrationDialogView::CloseDialog() { ...@@ -374,13 +376,6 @@ void LocalCardMigrationDialogView::CloseDialog() {
GetWidget()->Close(); GetWidget()->Close();
} }
gfx::Size LocalCardMigrationDialogView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_LARGE_MODAL_DIALOG_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
ui::ModalType LocalCardMigrationDialogView::GetModalType() const { ui::ModalType LocalCardMigrationDialogView::GetModalType() const {
// This should be a modal dialog blocking the browser since we don't want // This should be a modal dialog blocking the browser since we don't want
// users to lose progress in the migration workflow until they are done. // users to lose progress in the migration workflow until they are done.
......
...@@ -29,12 +29,11 @@ class LocalCardMigrationDialogView : public LocalCardMigrationDialog, ...@@ -29,12 +29,11 @@ class LocalCardMigrationDialogView : public LocalCardMigrationDialog,
content::WebContents* web_contents); content::WebContents* web_contents);
~LocalCardMigrationDialogView() override; ~LocalCardMigrationDialogView() 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; ui::ModalType GetModalType() const override;
bool ShouldShowCloseButton() const override; bool ShouldShowCloseButton() const override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override; bool IsDialogButtonEnabled(ui::DialogButton button) const override;
......
...@@ -396,6 +396,9 @@ ContentSettingBubbleContents::ContentSettingBubbleContents( ...@@ -396,6 +396,9 @@ ContentSettingBubbleContents::ContentSettingBubbleContents(
base::BindOnce(&ContentSettingBubbleModel::OnCancelButtonClicked, base::BindOnce(&ContentSettingBubbleModel::OnCancelButtonClicked,
base::Unretained(content_setting_bubble_model_.get()))); base::Unretained(content_setting_bubble_model_.get())));
} }
SetFixedWidth(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH));
} }
ContentSettingBubbleContents::~ContentSettingBubbleContents() { ContentSettingBubbleContents::~ContentSettingBubbleContents() {
...@@ -409,13 +412,6 @@ void ContentSettingBubbleContents::WindowClosing() { ...@@ -409,13 +412,6 @@ void ContentSettingBubbleContents::WindowClosing() {
content_setting_bubble_model_->CommitChanges(); content_setting_bubble_model_->CommitChanges();
} }
gfx::Size ContentSettingBubbleContents::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
void ContentSettingBubbleContents::OnListItemAdded( void ContentSettingBubbleContents::OnListItemAdded(
const ContentSettingBubbleModel::ListItem& item) { const ContentSettingBubbleModel::ListItem& item) {
DCHECK(list_item_container_); DCHECK(list_item_container_);
......
...@@ -48,7 +48,6 @@ class ContentSettingBubbleContents : public content::WebContentsObserver, ...@@ -48,7 +48,6 @@ class ContentSettingBubbleContents : public content::WebContentsObserver,
~ContentSettingBubbleContents() override; ~ContentSettingBubbleContents() override;
// views::BubbleDialogDelegateView: // views::BubbleDialogDelegateView:
gfx::Size CalculatePreferredSize() const override;
void WindowClosing() override; void WindowClosing() override;
// ContentSettingBubbleModel::Owner: // ContentSettingBubbleModel::Owner:
......
...@@ -92,6 +92,8 @@ ExtensionsMenuView::ExtensionsMenuView( ...@@ -92,6 +92,8 @@ ExtensionsMenuView::ExtensionsMenuView(
// Let anchor view's MenuButtonController handle the highlight. // Let anchor view's MenuButtonController handle the highlight.
set_highlight_button_when_shown(false); set_highlight_button_when_shown(false);
SetFixedWidth(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH));
SetLayoutManager(std::make_unique<views::BoxLayout>( SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical)); views::BoxLayout::Orientation::kVertical));
Populate(); Populate();
...@@ -107,13 +109,6 @@ ExtensionsMenuView::~ExtensionsMenuView() { ...@@ -107,13 +109,6 @@ ExtensionsMenuView::~ExtensionsMenuView() {
// directly within TabStripModelObserver::~TabStripModelObserver(). // directly within TabStripModelObserver::~TabStripModelObserver().
} }
gfx::Size ExtensionsMenuView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
void ExtensionsMenuView::Populate() { void ExtensionsMenuView::Populate() {
// The actions for the profile haven't been initialized yet. We'll call in // The actions for the profile haven't been initialized yet. We'll call in
// again once they have. // again once they have.
......
...@@ -58,12 +58,6 @@ class ExtensionsMenuView : public views::BubbleDialogDelegateView, ...@@ -58,12 +58,6 @@ class ExtensionsMenuView : public views::BubbleDialogDelegateView,
// Returns the currently-showing ExtensionsMenuView, if any exists. // Returns the currently-showing ExtensionsMenuView, if any exists.
static ExtensionsMenuView* GetExtensionsMenuViewForTesting(); static ExtensionsMenuView* GetExtensionsMenuViewForTesting();
// views::BubbleDialogDelegateView:
// TODO(crbug.com/1003072): This override is copied from PasswordItemsView to
// contrain the width. It would be nice to have a unified way of getting the
// preferred size to not duplicate the code.
gfx::Size CalculatePreferredSize() const override;
// TabStripModelObserver: // TabStripModelObserver:
void TabChangedAt(content::WebContents* contents, void TabChangedAt(content::WebContents* contents,
int index, int index,
......
...@@ -92,9 +92,7 @@ PrintJobConfirmationDialogView::PrintJobConfirmationDialogView( ...@@ -92,9 +92,7 @@ PrintJobConfirmationDialogView::PrintJobConfirmationDialogView(
: BubbleDialogDelegateView(anchor_view, : BubbleDialogDelegateView(anchor_view,
anchor_view ? views::BubbleBorder::TOP_RIGHT anchor_view ? views::BubbleBorder::TOP_RIGHT
: views::BubbleBorder::NONE), : views::BubbleBorder::NONE),
callback_(std::move(callback)), callback_(std::move(callback)) {
dialog_is_bubble_(anchor_view != nullptr) {
SetModalType(dialog_is_bubble_ ? ui::MODAL_TYPE_NONE : ui::MODAL_TYPE_WINDOW);
SetButtonLabel(ui::DIALOG_BUTTON_OK, SetButtonLabel(ui::DIALOG_BUTTON_OK,
l10n_util::GetStringUTF16( l10n_util::GetStringUTF16(
IDS_EXTENSIONS_PRINTING_API_PRINT_REQUEST_ALLOW)); IDS_EXTENSIONS_PRINTING_API_PRINT_REQUEST_ALLOW));
...@@ -117,10 +115,15 @@ PrintJobConfirmationDialogView::PrintJobConfirmationDialogView( ...@@ -117,10 +115,15 @@ PrintJobConfirmationDialogView::PrintJobConfirmationDialogView(
SetCancelCallback( SetCancelCallback(
base::BindOnce(run_callback, base::Unretained(this), false)); base::BindOnce(run_callback, base::Unretained(this), false));
ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); ChromeLayoutProvider* const provider = ChromeLayoutProvider::Get();
SetLayoutManager(std::make_unique<views::BoxLayout>( SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical, gfx::Insets(), views::BoxLayout::Orientation::kVertical, gfx::Insets(),
provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL))); provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL)));
const bool dialog_is_bubble = anchor_view != nullptr;
SetModalType(dialog_is_bubble ? ui::MODAL_TYPE_NONE : ui::MODAL_TYPE_WINDOW);
SetFixedWidth(provider->GetDistanceMetric(
dialog_is_bubble ? views::DISTANCE_BUBBLE_PREFERRED_WIDTH
: views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH));
// Add margins for the icon plus the icon-title padding so that the dialog // Add margins for the icon plus the icon-title padding so that the dialog
// contents align with the title text. // contents align with the title text.
...@@ -145,15 +148,6 @@ PrintJobConfirmationDialogView::PrintJobConfirmationDialogView( ...@@ -145,15 +148,6 @@ PrintJobConfirmationDialogView::PrintJobConfirmationDialogView(
PrintJobConfirmationDialogView::~PrintJobConfirmationDialogView() = default; PrintJobConfirmationDialogView::~PrintJobConfirmationDialogView() = default;
gfx::Size PrintJobConfirmationDialogView::CalculatePreferredSize() const {
const int width =
ChromeLayoutProvider::Get()->GetDistanceMetric(
dialog_is_bubble_ ? views::DISTANCE_BUBBLE_PREFERRED_WIDTH
: views::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
namespace chrome { namespace chrome {
void ShowPrintJobConfirmationDialog(gfx::NativeWindow parent, void ShowPrintJobConfirmationDialog(gfx::NativeWindow parent,
......
...@@ -42,18 +42,11 @@ class PrintJobConfirmationDialogView : public views::BubbleDialogDelegateView { ...@@ -42,18 +42,11 @@ class PrintJobConfirmationDialogView : public views::BubbleDialogDelegateView {
const PrintJobConfirmationDialogView&) = delete; const PrintJobConfirmationDialogView&) = delete;
private: private:
// views::DialogDelegateView:
gfx::Size CalculatePreferredSize() const override;
// The name of the extension we are showing the dialog for. // The name of the extension we are showing the dialog for.
const base::string16 extension_name_; const base::string16 extension_name_;
// Callback to call after the dialog is accepted or rejected. // Callback to call after the dialog is accepted or rejected.
base::OnceCallback<void(bool)> callback_; base::OnceCallback<void(bool)> callback_;
// TODO(pbos): Find a more direct way of determining if there's a bubble than
// checking |anchor_view|.
const bool dialog_is_bubble_;
}; };
#endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_PRINT_JOB_CONFIRMATION_DIALOG_VIEW_H_ #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_PRINT_JOB_CONFIRMATION_DIALOG_VIEW_H_
...@@ -154,12 +154,6 @@ void CastDialogView::OnControllerInvalidated() { ...@@ -154,12 +154,6 @@ void CastDialogView::OnControllerInvalidated() {
// cause the dialog to immediately open again. // cause the dialog to immediately open again.
} }
gfx::Size CastDialogView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH);
return gfx::Size(width, GetHeightForWidth(width));
}
void CastDialogView::OnPaint(gfx::Canvas* canvas) { void CastDialogView::OnPaint(gfx::Canvas* canvas) {
views::BubbleDialogDelegateView::OnPaint(canvas); views::BubbleDialogDelegateView::OnPaint(canvas);
metrics_.OnPaint(base::Time::Now()); metrics_.OnPaint(base::Time::Now());
...@@ -231,6 +225,8 @@ CastDialogView::CastDialogView(views::View* anchor_view, ...@@ -231,6 +225,8 @@ CastDialogView::CastDialogView(views::View* anchor_view,
metrics_(start_time, activation_location, profile) { metrics_(start_time, activation_location, profile) {
SetShowCloseButton(true); SetShowCloseButton(true);
SetButtons(ui::DIALOG_BUTTON_NONE); SetButtons(ui::DIALOG_BUTTON_NONE);
SetFixedWidth(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH));
sources_button_ = sources_button_ =
SetExtraView(std::make_unique<views::MdTextButtonWithDownArrow>( SetExtraView(std::make_unique<views::MdTextButtonWithDownArrow>(
base::BindRepeating(&CastDialogView::ShowSourcesMenu, base::BindRepeating(&CastDialogView::ShowSourcesMenu,
......
...@@ -88,8 +88,7 @@ class CastDialogView : public views::BubbleDialogDelegateView, ...@@ -88,8 +88,7 @@ class CastDialogView : public views::BubbleDialogDelegateView,
void OnModelUpdated(const CastDialogModel& model) override; void OnModelUpdated(const CastDialogModel& model) override;
void OnControllerInvalidated() override; void OnControllerInvalidated() override;
// views::View: // views::BubbleDialogDelegateView:
gfx::Size CalculatePreferredSize() const override;
void OnPaint(gfx::Canvas* canvas) override; void OnPaint(gfx::Canvas* canvas) override;
// ui::SimpleMenuModel::Delegate: // ui::SimpleMenuModel::Delegate:
......
...@@ -72,13 +72,6 @@ void CloudServicesDialogView::OnDialogAccepted() { ...@@ -72,13 +72,6 @@ void CloudServicesDialogView::OnDialogAccepted() {
pref_service->SetBoolean(prefs::kMediaRouterCloudServicesPrefSet, true); pref_service->SetBoolean(prefs::kMediaRouterCloudServicesPrefSet, true);
} }
gfx::Size CloudServicesDialogView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
CloudServicesDialogView::CloudServicesDialogView(views::View* anchor_view, CloudServicesDialogView::CloudServicesDialogView(views::View* anchor_view,
Browser* browser) Browser* browser)
: BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT),
...@@ -93,8 +86,11 @@ CloudServicesDialogView::CloudServicesDialogView(views::View* anchor_view, ...@@ -93,8 +86,11 @@ CloudServicesDialogView::CloudServicesDialogView(views::View* anchor_view,
l10n_util::GetStringUTF16(IDS_MEDIA_ROUTER_CLOUD_SERVICES_DIALOG_CANCEL)); l10n_util::GetStringUTF16(IDS_MEDIA_ROUTER_CLOUD_SERVICES_DIALOG_CANCEL));
SetAcceptCallback(base::BindOnce(&CloudServicesDialogView::OnDialogAccepted, SetAcceptCallback(base::BindOnce(&CloudServicesDialogView::OnDialogAccepted,
base::Unretained(this))); base::Unretained(this)));
set_close_on_deactivate(false); set_close_on_deactivate(false);
SetLayoutManager(std::make_unique<views::FillLayout>()); SetLayoutManager(std::make_unique<views::FillLayout>());
SetFixedWidth(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH));
} }
CloudServicesDialogView::~CloudServicesDialogView() = default; CloudServicesDialogView::~CloudServicesDialogView() = default;
......
...@@ -27,9 +27,6 @@ class CloudServicesDialogView : public views::BubbleDialogDelegateView { ...@@ -27,9 +27,6 @@ class CloudServicesDialogView : public views::BubbleDialogDelegateView {
// Called by tests. Returns the singleton dialog instance. // Called by tests. Returns the singleton dialog instance.
static CloudServicesDialogView* GetDialogForTest(); static CloudServicesDialogView* GetDialogForTest();
// views::View:
gfx::Size CalculatePreferredSize() const override;
private: private:
CloudServicesDialogView(views::View* anchor_view, Browser* browser); CloudServicesDialogView(views::View* anchor_view, Browser* browser);
~CloudServicesDialogView() override; ~CloudServicesDialogView() override;
......
...@@ -74,13 +74,6 @@ bool MediaRemotingDialogView::IsShowing() { ...@@ -74,13 +74,6 @@ bool MediaRemotingDialogView::IsShowing() {
return instance_ != nullptr; return instance_ != nullptr;
} }
gfx::Size MediaRemotingDialogView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
MediaRemotingDialogView::MediaRemotingDialogView( MediaRemotingDialogView::MediaRemotingDialogView(
views::View* anchor_view, views::View* anchor_view,
PrefService* pref_service, PrefService* pref_service,
...@@ -105,6 +98,9 @@ MediaRemotingDialogView::MediaRemotingDialogView( ...@@ -105,6 +98,9 @@ MediaRemotingDialogView::MediaRemotingDialogView(
SetCancelCallback(base::BindOnce(&MediaRemotingDialogView::ReportPermission, SetCancelCallback(base::BindOnce(&MediaRemotingDialogView::ReportPermission,
base::Unretained(this), false)); base::Unretained(this), false));
SetFixedWidth(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH));
SetLayoutManager(std::make_unique<views::BoxLayout>( SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical)); views::BoxLayout::Orientation::kVertical));
// Depress the Cast toolbar icon. // Depress the Cast toolbar icon.
......
...@@ -39,9 +39,6 @@ class MediaRemotingDialogView : public views::BubbleDialogDelegateView { ...@@ -39,9 +39,6 @@ class MediaRemotingDialogView : public views::BubbleDialogDelegateView {
static bool IsShowing(); static bool IsShowing();
// views::View:
gfx::Size CalculatePreferredSize() const override;
private: private:
MediaRemotingDialogView(views::View* anchor_view, MediaRemotingDialogView(views::View* anchor_view,
PrefService* pref_service, PrefService* pref_service,
......
...@@ -352,6 +352,8 @@ NativeFileSystemUsageBubbleView::NativeFileSystemUsageBubbleView( ...@@ -352,6 +352,8 @@ NativeFileSystemUsageBubbleView::NativeFileSystemUsageBubbleView(
SetCancelCallback( SetCancelCallback(
base::BindOnce(&NativeFileSystemUsageBubbleView::OnDialogCancelled, base::BindOnce(&NativeFileSystemUsageBubbleView::OnDialogCancelled,
base::Unretained(this))); base::Unretained(this)));
SetFixedWidth(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH));
} }
NativeFileSystemUsageBubbleView::~NativeFileSystemUsageBubbleView() = default; NativeFileSystemUsageBubbleView::~NativeFileSystemUsageBubbleView() = default;
...@@ -464,13 +466,6 @@ void NativeFileSystemUsageBubbleView::CloseBubble() { ...@@ -464,13 +466,6 @@ void NativeFileSystemUsageBubbleView::CloseBubble() {
LocationBarBubbleDelegateView::CloseBubble(); LocationBarBubbleDelegateView::CloseBubble();
} }
gfx::Size NativeFileSystemUsageBubbleView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
void NativeFileSystemUsageBubbleView::ChildPreferredSizeChanged( void NativeFileSystemUsageBubbleView::ChildPreferredSizeChanged(
views::View* child) { views::View* child) {
LocationBarBubbleDelegateView::ChildPreferredSizeChanged(child); LocationBarBubbleDelegateView::ChildPreferredSizeChanged(child);
......
...@@ -71,7 +71,6 @@ class NativeFileSystemUsageBubbleView : public LocationBarBubbleDelegateView { ...@@ -71,7 +71,6 @@ class NativeFileSystemUsageBubbleView : public LocationBarBubbleDelegateView {
void Init() override; void Init() override;
void WindowClosing() override; void WindowClosing() override;
void CloseBubble() override; void CloseBubble() override;
gfx::Size CalculatePreferredSize() const override;
void ChildPreferredSizeChanged(views::View* child) override; void ChildPreferredSizeChanged(views::View* child) override;
void OnDialogCancelled(); void OnDialogCancelled();
......
...@@ -82,6 +82,9 @@ PermissionPromptBubbleView::PermissionPromptBubbleView( ...@@ -82,6 +82,9 @@ PermissionPromptBubbleView::PermissionPromptBubbleView(
ChromeLayoutProvider::Get()->GetDistanceMetric( ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_RELATED_CONTROL_VERTICAL))); views::DISTANCE_RELATED_CONTROL_VERTICAL)));
SetFixedWidth(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH));
for (permissions::PermissionRequest* request : visible_requests_) for (permissions::PermissionRequest* request : visible_requests_)
AddPermissionRequestLine(request); AddPermissionRequestLine(request);
...@@ -244,13 +247,6 @@ base::string16 PermissionPromptBubbleView::GetAccessibleWindowTitle() const { ...@@ -244,13 +247,6 @@ base::string16 PermissionPromptBubbleView::GetAccessibleWindowTitle() const {
visible_requests_[1]->GetMessageTextFragment()); visible_requests_[1]->GetMessageTextFragment());
} }
gfx::Size PermissionPromptBubbleView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
void PermissionPromptBubbleView::ButtonPressed(views::Button* sender, void PermissionPromptBubbleView::ButtonPressed(views::Button* sender,
const ui::Event& event) { const ui::Event& event) {
DCHECK_EQ(sender, GetExtraView()); DCHECK_EQ(sender, GetExtraView());
......
...@@ -34,7 +34,6 @@ class PermissionPromptBubbleView : public views::ButtonListener, ...@@ -34,7 +34,6 @@ class PermissionPromptBubbleView : public views::ButtonListener,
bool ShouldShowCloseButton() const override; bool ShouldShowCloseButton() const override;
base::string16 GetAccessibleWindowTitle() const override; base::string16 GetAccessibleWindowTitle() const override;
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
gfx::Size CalculatePreferredSize() const override;
// Button Listener // Button Listener
void ButtonPressed(views::Button* sender, const ui::Event& event) override; void ButtonPressed(views::Button* sender, const ui::Event& event) override;
......
...@@ -117,13 +117,6 @@ void RelaunchRecommendedBubbleView::Init() { ...@@ -117,13 +117,6 @@ void RelaunchRecommendedBubbleView::Init() {
base::RecordAction(base::UserMetricsAction("RelaunchRecommendedShown")); base::RecordAction(base::UserMetricsAction("RelaunchRecommendedShown"));
} }
gfx::Size RelaunchRecommendedBubbleView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
void RelaunchRecommendedBubbleView::VisibilityChanged( void RelaunchRecommendedBubbleView::VisibilityChanged(
views::View* starting_from, views::View* starting_from,
bool is_visible) { bool is_visible) {
...@@ -154,9 +147,12 @@ RelaunchRecommendedBubbleView::RelaunchRecommendedBubbleView( ...@@ -154,9 +147,12 @@ RelaunchRecommendedBubbleView::RelaunchRecommendedBubbleView(
base::BindOnce(&base::RecordAction, base::BindOnce(&base::RecordAction,
base::UserMetricsAction("RelaunchRecommended_Close"))); base::UserMetricsAction("RelaunchRecommended_Close")));
chrome::RecordDialogCreation(chrome::DialogIdentifier::RELAUNCH_RECOMMENDED); SetFixedWidth(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH));
set_margins(ChromeLayoutProvider::Get()->GetDialogInsetsForContentType( set_margins(ChromeLayoutProvider::Get()->GetDialogInsetsForContentType(
views::TEXT, views::TEXT)); views::TEXT, views::TEXT));
chrome::RecordDialogCreation(chrome::DialogIdentifier::RELAUNCH_RECOMMENDED);
} }
void RelaunchRecommendedBubbleView::UpdateWindowTitle() { void RelaunchRecommendedBubbleView::UpdateWindowTitle() {
......
...@@ -40,7 +40,6 @@ class RelaunchRecommendedBubbleView : public LocationBarBubbleDelegateView { ...@@ -40,7 +40,6 @@ class RelaunchRecommendedBubbleView : public LocationBarBubbleDelegateView {
protected: protected:
// LocationBarBubbleDelegateView: // LocationBarBubbleDelegateView:
void Init() override; void Init() override;
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;
private: private:
......
...@@ -43,6 +43,8 @@ SendTabToSelfBubbleViewImpl::SendTabToSelfBubbleViewImpl( ...@@ -43,6 +43,8 @@ SendTabToSelfBubbleViewImpl::SendTabToSelfBubbleViewImpl(
web_contents_(web_contents), web_contents_(web_contents),
controller_(controller) { controller_(controller) {
SetButtons(ui::DIALOG_BUTTON_NONE); SetButtons(ui::DIALOG_BUTTON_NONE);
SetFixedWidth(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH));
DCHECK(controller); DCHECK(controller);
} }
...@@ -76,12 +78,6 @@ void SendTabToSelfBubbleViewImpl::ButtonPressed(views::Button* sender, ...@@ -76,12 +78,6 @@ void SendTabToSelfBubbleViewImpl::ButtonPressed(views::Button* sender,
DevicePressed(sender->tag()); DevicePressed(sender->tag());
} }
gfx::Size SendTabToSelfBubbleViewImpl::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH);
return gfx::Size(width, GetHeightForWidth(width));
}
void SendTabToSelfBubbleViewImpl::OnPaint(gfx::Canvas* canvas) { void SendTabToSelfBubbleViewImpl::OnPaint(gfx::Canvas* canvas) {
views::BubbleDialogDelegateView::OnPaint(canvas); views::BubbleDialogDelegateView::OnPaint(canvas);
} }
......
...@@ -55,8 +55,7 @@ class SendTabToSelfBubbleViewImpl : public SendTabToSelfBubbleView, ...@@ -55,8 +55,7 @@ class SendTabToSelfBubbleViewImpl : public SendTabToSelfBubbleView,
// views::ButtonListener: // views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override; void ButtonPressed(views::Button* sender, const ui::Event& event) override;
// views::View: // LocationBarBubbleDelegateView:
gfx::Size CalculatePreferredSize() const override;
void OnPaint(gfx::Canvas* canvas) override; void OnPaint(gfx::Canvas* canvas) override;
// Shows the bubble view. // Shows the bubble view.
......
...@@ -122,6 +122,9 @@ SharingDialogView::SharingDialogView(views::View* anchor_view, ...@@ -122,6 +122,9 @@ SharingDialogView::SharingDialogView(views::View* anchor_view,
data_(std::move(data)) { data_(std::move(data)) {
SetButtons(ui::DIALOG_BUTTON_NONE); SetButtons(ui::DIALOG_BUTTON_NONE);
SetFixedWidth(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH));
if (data_.type == SharingDialogType::kDialogWithoutDevicesWithApp) { if (data_.type == SharingDialogType::kDialogWithoutDevicesWithApp) {
SetFootnoteView(CreateHelpText()); SetFootnoteView(CreateHelpText());
} else if ((data_.type == SharingDialogType::kDialogWithDevicesMaybeApps) && } else if ((data_.type == SharingDialogType::kDialogWithDevicesMaybeApps) &&
...@@ -158,12 +161,6 @@ void SharingDialogView::WebContentsDestroyed() { ...@@ -158,12 +161,6 @@ void SharingDialogView::WebContentsDestroyed() {
WindowClosing(); WindowClosing();
} }
gfx::Size SharingDialogView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH);
return gfx::Size(width, GetHeightForWidth(width));
}
void SharingDialogView::AddedToWidget() { void SharingDialogView::AddedToWidget() {
views::BubbleFrameView* frame_view = GetBubbleFrameView(); views::BubbleFrameView* frame_view = GetBubbleFrameView();
if (frame_view && data_.header_icons) { if (frame_view && data_.header_icons) {
......
...@@ -40,7 +40,6 @@ class SharingDialogView : public SharingDialog, ...@@ -40,7 +40,6 @@ class SharingDialogView : public SharingDialog,
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
void WindowClosing() override; void WindowClosing() override;
void WebContentsDestroyed() override; void WebContentsDestroyed() override;
gfx::Size CalculatePreferredSize() const override;
void AddedToWidget() override; void AddedToWidget() override;
// views::ButtonListener: // views::ButtonListener:
......
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