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

Use set_fixed_width() in PasswordBubbleViewBase

Removes overrides in all child classes of PasswordBubbleViewBase. Also
replaces ShouldShowCloseButton() overrides.

Bug: 1128500
Change-Id: I7f875679888beeb4f138a6bb62abf78c0d2b1542
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2493126
Commit-Queue: Peter Boström <pbos@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820051}
parent f437a87e
...@@ -326,17 +326,6 @@ void MoveToAccountStoreBubbleView::OnThemeChanged() { ...@@ -326,17 +326,6 @@ void MoveToAccountStoreBubbleView::OnThemeChanged() {
: IDR_SAVE_PASSWORD_MULTI_DEVICE)); : IDR_SAVE_PASSWORD_MULTI_DEVICE));
} }
gfx::Size MoveToAccountStoreBubbleView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
bool MoveToAccountStoreBubbleView::ShouldShowCloseButton() const {
return true;
}
MoveToAccountStoreBubbleController* MoveToAccountStoreBubbleController*
MoveToAccountStoreBubbleView::GetController() { MoveToAccountStoreBubbleView::GetController() {
return &controller_; return &controller_;
......
...@@ -22,8 +22,6 @@ class MoveToAccountStoreBubbleView : public PasswordBubbleViewBase { ...@@ -22,8 +22,6 @@ class MoveToAccountStoreBubbleView : public PasswordBubbleViewBase {
// PasswordBubbleViewBase // PasswordBubbleViewBase
void AddedToWidget() override; void AddedToWidget() override;
void OnThemeChanged() override; void OnThemeChanged() override;
gfx::Size CalculatePreferredSize() const override;
bool ShouldShowCloseButton() const override;
MoveToAccountStoreBubbleController* GetController() override; MoveToAccountStoreBubbleController* GetController() override;
const MoveToAccountStoreBubbleController* GetController() const override; const MoveToAccountStoreBubbleController* GetController() const override;
......
...@@ -36,6 +36,7 @@ PasswordAutoSignInView::PasswordAutoSignInView( ...@@ -36,6 +36,7 @@ PasswordAutoSignInView::PasswordAutoSignInView(
SetLayoutManager(std::make_unique<views::FillLayout>()); SetLayoutManager(std::make_unique<views::FillLayout>());
const autofill::PasswordForm& form = controller_.pending_password(); const autofill::PasswordForm& form = controller_.pending_password();
SetShowCloseButton(false);
SetButtons(ui::DIALOG_BUTTON_NONE); SetButtons(ui::DIALOG_BUTTON_NONE);
set_margins( set_margins(
...@@ -84,13 +85,6 @@ void PasswordAutoSignInView::OnWidgetActivationChanged(views::Widget* widget, ...@@ -84,13 +85,6 @@ void PasswordAutoSignInView::OnWidgetActivationChanged(views::Widget* widget,
LocationBarBubbleDelegateView::OnWidgetActivationChanged(widget, active); LocationBarBubbleDelegateView::OnWidgetActivationChanged(widget, active);
} }
gfx::Size PasswordAutoSignInView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
void PasswordAutoSignInView::OnTimer() { void PasswordAutoSignInView::OnTimer() {
controller_.OnAutoSignInToastTimeout(); controller_.OnAutoSignInToastTimeout();
CloseBubble(); CloseBubble();
......
...@@ -33,7 +33,6 @@ class PasswordAutoSignInView : public PasswordBubbleViewBase { ...@@ -33,7 +33,6 @@ class PasswordAutoSignInView : public PasswordBubbleViewBase {
const PasswordBubbleControllerBase* GetController() const override; const PasswordBubbleControllerBase* GetController() const override;
// LocationBarBubbleDelegateView: // LocationBarBubbleDelegateView:
gfx::Size CalculatePreferredSize() const override;
void OnWidgetActivationChanged(views::Widget* widget, bool active) override; void OnWidgetActivationChanged(views::Widget* widget, bool active) override;
void OnTimer(); void OnTimer();
......
...@@ -136,6 +136,9 @@ PasswordBubbleViewBase::PasswordBubbleViewBase( ...@@ -136,6 +136,9 @@ PasswordBubbleViewBase::PasswordBubbleViewBase(
views::View* anchor_view, views::View* anchor_view,
bool easily_dismissable) bool easily_dismissable)
: LocationBarBubbleDelegateView(anchor_view, web_contents) { : LocationBarBubbleDelegateView(anchor_view, web_contents) {
SetShowCloseButton(true);
set_fixed_width(views::LayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH));
// The |mouse_handler| closes the bubble if a keyboard or mouse // The |mouse_handler| closes the bubble if a keyboard or mouse
// interactions happens outside of the bubble. By this the bubble becomes // interactions happens outside of the bubble. By this the bubble becomes
// 'easily-dismissable' and this behavior can be enforced by the // 'easily-dismissable' and this behavior can be enforced by the
......
...@@ -60,20 +60,9 @@ PasswordGenerationConfirmationView::GetController() const { ...@@ -60,20 +60,9 @@ PasswordGenerationConfirmationView::GetController() const {
return &controller_; return &controller_;
} }
bool PasswordGenerationConfirmationView::ShouldShowCloseButton() const {
return true;
}
void PasswordGenerationConfirmationView::StyledLabelLinkClicked() { void PasswordGenerationConfirmationView::StyledLabelLinkClicked() {
controller_.OnNavigateToPasswordManagerAccountDashboardLinkClicked( controller_.OnNavigateToPasswordManagerAccountDashboardLinkClicked(
password_manager::ManagePasswordsReferrer:: password_manager::ManagePasswordsReferrer::
kPasswordGenerationConfirmation); kPasswordGenerationConfirmation);
CloseBubble(); CloseBubble();
} }
gfx::Size PasswordGenerationConfirmationView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
...@@ -20,16 +20,12 @@ class PasswordGenerationConfirmationView : public PasswordBubbleViewBase { ...@@ -20,16 +20,12 @@ class PasswordGenerationConfirmationView : public PasswordBubbleViewBase {
~PasswordGenerationConfirmationView() override; ~PasswordGenerationConfirmationView() override;
private: private:
// PasswordBubbleViewBase // PasswordBubbleViewBase:
PasswordBubbleControllerBase* GetController() override; PasswordBubbleControllerBase* GetController() override;
const PasswordBubbleControllerBase* GetController() const override; const PasswordBubbleControllerBase* GetController() const override;
void StyledLabelLinkClicked(); void StyledLabelLinkClicked();
// LocationBarBubbleDelegateView:
bool ShouldShowCloseButton() const override;
gfx::Size CalculatePreferredSize() const override;
GenerationConfirmationBubbleController controller_; GenerationConfirmationBubbleController controller_;
DISALLOW_COPY_AND_ASSIGN(PasswordGenerationConfirmationView); DISALLOW_COPY_AND_ASSIGN(PasswordGenerationConfirmationView);
......
...@@ -341,17 +341,6 @@ void PasswordItemsView::NotifyPasswordFormAction( ...@@ -341,17 +341,6 @@ void PasswordItemsView::NotifyPasswordFormAction(
controller_.OnPasswordAction(password_form, action); controller_.OnPasswordAction(password_form, action);
} }
bool PasswordItemsView::ShouldShowCloseButton() const {
return true;
}
gfx::Size PasswordItemsView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
void PasswordItemsView::OnFaviconReady(const gfx::Image& favicon) { void PasswordItemsView::OnFaviconReady(const gfx::Image& favicon) {
if (!favicon.IsEmpty()) { if (!favicon.IsEmpty()) {
favicon_ = favicon; favicon_ = favicon;
......
...@@ -35,10 +35,6 @@ class PasswordItemsView : public PasswordBubbleViewBase { ...@@ -35,10 +35,6 @@ class PasswordItemsView : public PasswordBubbleViewBase {
PasswordBubbleControllerBase::PasswordAction action); PasswordBubbleControllerBase::PasswordAction action);
void RecreateLayout(); void RecreateLayout();
// LocationBarBubbleDelegateView:
bool ShouldShowCloseButton() const override;
gfx::Size CalculatePreferredSize() const override;
// Called when the favicon is loaded. If |favicon| isn't empty, it sets // Called when the favicon is loaded. If |favicon| isn't empty, it sets
// |favicon_| and invokes RecreateLayout(). // |favicon_| and invokes RecreateLayout().
void OnFaviconReady(const gfx::Image& favicon); void OnFaviconReady(const gfx::Image& favicon);
......
...@@ -120,15 +120,3 @@ void PasswordSaveUnsyncedCredentialsLocallyView::OnSaveClicked() { ...@@ -120,15 +120,3 @@ void PasswordSaveUnsyncedCredentialsLocallyView::OnSaveClicked() {
} }
controller_.OnSaveClicked(was_credential_selected); controller_.OnSaveClicked(was_credential_selected);
} }
bool PasswordSaveUnsyncedCredentialsLocallyView::ShouldShowCloseButton() const {
return true;
}
gfx::Size PasswordSaveUnsyncedCredentialsLocallyView::CalculatePreferredSize()
const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
...@@ -27,14 +27,10 @@ class PasswordSaveUnsyncedCredentialsLocallyView ...@@ -27,14 +27,10 @@ class PasswordSaveUnsyncedCredentialsLocallyView
~PasswordSaveUnsyncedCredentialsLocallyView() override; ~PasswordSaveUnsyncedCredentialsLocallyView() override;
private: private:
// PasswordBubbleViewBase overrides. // PasswordBubbleViewBase:
PasswordBubbleControllerBase* GetController() override; PasswordBubbleControllerBase* GetController() override;
const PasswordBubbleControllerBase* GetController() const override; const PasswordBubbleControllerBase* GetController() const override;
// LocationBarBubbleDelegateView overrides.
bool ShouldShowCloseButton() const override;
gfx::Size CalculatePreferredSize() const override;
void CreateLayout(); void CreateLayout();
void ButtonPressed(views::Checkbox* checkbox); void ButtonPressed(views::Checkbox* checkbox);
......
...@@ -343,13 +343,6 @@ bool PasswordSaveUpdateView::Accept() { ...@@ -343,13 +343,6 @@ bool PasswordSaveUpdateView::Accept() {
return true; return true;
} }
gfx::Size PasswordSaveUpdateView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
views::View* PasswordSaveUpdateView::GetInitiallyFocusedView() { views::View* PasswordSaveUpdateView::GetInitiallyFocusedView() {
if (username_dropdown_ && username_dropdown_->GetText().empty()) if (username_dropdown_ && username_dropdown_->GetText().empty())
return username_dropdown_; return username_dropdown_;
...@@ -373,10 +366,6 @@ gfx::ImageSkia PasswordSaveUpdateView::GetWindowIcon() { ...@@ -373,10 +366,6 @@ gfx::ImageSkia PasswordSaveUpdateView::GetWindowIcon() {
return gfx::ImageSkia(); return gfx::ImageSkia();
} }
bool PasswordSaveUpdateView::ShouldShowCloseButton() const {
return true;
}
void PasswordSaveUpdateView::AddedToWidget() { void PasswordSaveUpdateView::AddedToWidget() {
static_cast<views::Label*>(GetBubbleFrameView()->title()) static_cast<views::Label*>(GetBubbleFrameView()->title())
->SetAllowCharacterBreak(true); ->SetAllowCharacterBreak(true);
......
...@@ -35,11 +35,9 @@ class PasswordSaveUpdateView : public PasswordBubbleViewBase { ...@@ -35,11 +35,9 @@ class PasswordSaveUpdateView : public PasswordBubbleViewBase {
const PasswordBubbleControllerBase* GetController() const override; const PasswordBubbleControllerBase* GetController() const override;
// PasswordBubbleViewBase: // PasswordBubbleViewBase:
gfx::Size CalculatePreferredSize() const override;
views::View* GetInitiallyFocusedView() override; views::View* GetInitiallyFocusedView() override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override; bool IsDialogButtonEnabled(ui::DialogButton button) const override;
gfx::ImageSkia GetWindowIcon() override; gfx::ImageSkia GetWindowIcon() override;
bool ShouldShowCloseButton() const override;
bool Accept() override; bool Accept() override;
// View: // View:
......
...@@ -560,14 +560,6 @@ void PasswordSaveUpdateWithAccountStoreView::OnWidgetDestroying( ...@@ -560,14 +560,6 @@ void PasswordSaveUpdateWithAccountStoreView::OnWidgetDestroying(
} }
} }
gfx::Size PasswordSaveUpdateWithAccountStoreView::CalculatePreferredSize()
const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
views::View* PasswordSaveUpdateWithAccountStoreView::GetInitiallyFocusedView() { views::View* PasswordSaveUpdateWithAccountStoreView::GetInitiallyFocusedView() {
if (username_dropdown_ && username_dropdown_->GetText().empty()) if (username_dropdown_ && username_dropdown_->GetText().empty())
return username_dropdown_; return username_dropdown_;
...@@ -591,10 +583,6 @@ gfx::ImageSkia PasswordSaveUpdateWithAccountStoreView::GetWindowIcon() { ...@@ -591,10 +583,6 @@ gfx::ImageSkia PasswordSaveUpdateWithAccountStoreView::GetWindowIcon() {
return gfx::ImageSkia(); return gfx::ImageSkia();
} }
bool PasswordSaveUpdateWithAccountStoreView::ShouldShowCloseButton() const {
return true;
}
void PasswordSaveUpdateWithAccountStoreView::AddedToWidget() { void PasswordSaveUpdateWithAccountStoreView::AddedToWidget() {
static_cast<views::Label*>(GetBubbleFrameView()->title()) static_cast<views::Label*>(GetBubbleFrameView()->title())
->SetAllowCharacterBreak(true); ->SetAllowCharacterBreak(true);
......
...@@ -62,11 +62,9 @@ class PasswordSaveUpdateWithAccountStoreView ...@@ -62,11 +62,9 @@ class PasswordSaveUpdateWithAccountStoreView
void OnWidgetDestroying(views::Widget* widget) override; void OnWidgetDestroying(views::Widget* widget) override;
// PasswordBubbleViewBase: // PasswordBubbleViewBase:
gfx::Size CalculatePreferredSize() const override;
views::View* GetInitiallyFocusedView() override; views::View* GetInitiallyFocusedView() override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override; bool IsDialogButtonEnabled(ui::DialogButton button) const override;
gfx::ImageSkia GetWindowIcon() override; gfx::ImageSkia GetWindowIcon() override;
bool ShouldShowCloseButton() const override;
// View: // View:
void AddedToWidget() override; void AddedToWidget() override;
......
...@@ -63,17 +63,6 @@ PostSaveCompromisedBubbleView::GetController() const { ...@@ -63,17 +63,6 @@ PostSaveCompromisedBubbleView::GetController() const {
return &controller_; return &controller_;
} }
gfx::Size PostSaveCompromisedBubbleView::CalculatePreferredSize() const {
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
bool PostSaveCompromisedBubbleView::ShouldShowCloseButton() const {
return true;
}
void PostSaveCompromisedBubbleView::OnThemeChanged() { void PostSaveCompromisedBubbleView::OnThemeChanged() {
PasswordBubbleViewBase::OnThemeChanged(); PasswordBubbleViewBase::OnThemeChanged();
int image_id = controller_.GetImageID( int image_id = controller_.GetImageID(
......
...@@ -20,8 +20,6 @@ class PostSaveCompromisedBubbleView : public PasswordBubbleViewBase { ...@@ -20,8 +20,6 @@ class PostSaveCompromisedBubbleView : public PasswordBubbleViewBase {
// PasswordBubbleViewBase: // PasswordBubbleViewBase:
PostSaveCompromisedBubbleController* GetController() override; PostSaveCompromisedBubbleController* GetController() override;
const PostSaveCompromisedBubbleController* GetController() const override; const PostSaveCompromisedBubbleController* GetController() const override;
gfx::Size CalculatePreferredSize() const override;
bool ShouldShowCloseButton() const override;
void OnThemeChanged() override; void OnThemeChanged() override;
PostSaveCompromisedBubbleController controller_; PostSaveCompromisedBubbleController controller_;
......
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