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() {
: 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*
MoveToAccountStoreBubbleView::GetController() {
return &controller_;
......
......@@ -22,8 +22,6 @@ class MoveToAccountStoreBubbleView : public PasswordBubbleViewBase {
// PasswordBubbleViewBase
void AddedToWidget() override;
void OnThemeChanged() override;
gfx::Size CalculatePreferredSize() const override;
bool ShouldShowCloseButton() const override;
MoveToAccountStoreBubbleController* GetController() override;
const MoveToAccountStoreBubbleController* GetController() const override;
......
......@@ -36,6 +36,7 @@ PasswordAutoSignInView::PasswordAutoSignInView(
SetLayoutManager(std::make_unique<views::FillLayout>());
const autofill::PasswordForm& form = controller_.pending_password();
SetShowCloseButton(false);
SetButtons(ui::DIALOG_BUTTON_NONE);
set_margins(
......@@ -84,13 +85,6 @@ void PasswordAutoSignInView::OnWidgetActivationChanged(views::Widget* widget,
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() {
controller_.OnAutoSignInToastTimeout();
CloseBubble();
......
......@@ -33,7 +33,6 @@ class PasswordAutoSignInView : public PasswordBubbleViewBase {
const PasswordBubbleControllerBase* GetController() const override;
// LocationBarBubbleDelegateView:
gfx::Size CalculatePreferredSize() const override;
void OnWidgetActivationChanged(views::Widget* widget, bool active) override;
void OnTimer();
......
......@@ -136,6 +136,9 @@ PasswordBubbleViewBase::PasswordBubbleViewBase(
views::View* anchor_view,
bool easily_dismissable)
: 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
// interactions happens outside of the bubble. By this the bubble becomes
// 'easily-dismissable' and this behavior can be enforced by the
......
......@@ -60,20 +60,9 @@ PasswordGenerationConfirmationView::GetController() const {
return &controller_;
}
bool PasswordGenerationConfirmationView::ShouldShowCloseButton() const {
return true;
}
void PasswordGenerationConfirmationView::StyledLabelLinkClicked() {
controller_.OnNavigateToPasswordManagerAccountDashboardLinkClicked(
password_manager::ManagePasswordsReferrer::
kPasswordGenerationConfirmation);
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 {
~PasswordGenerationConfirmationView() override;
private:
// PasswordBubbleViewBase
// PasswordBubbleViewBase:
PasswordBubbleControllerBase* GetController() override;
const PasswordBubbleControllerBase* GetController() const override;
void StyledLabelLinkClicked();
// LocationBarBubbleDelegateView:
bool ShouldShowCloseButton() const override;
gfx::Size CalculatePreferredSize() const override;
GenerationConfirmationBubbleController controller_;
DISALLOW_COPY_AND_ASSIGN(PasswordGenerationConfirmationView);
......
......@@ -341,17 +341,6 @@ void PasswordItemsView::NotifyPasswordFormAction(
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) {
if (!favicon.IsEmpty()) {
favicon_ = favicon;
......
......@@ -35,10 +35,6 @@ class PasswordItemsView : public PasswordBubbleViewBase {
PasswordBubbleControllerBase::PasswordAction action);
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
// |favicon_| and invokes RecreateLayout().
void OnFaviconReady(const gfx::Image& favicon);
......
......@@ -120,15 +120,3 @@ void PasswordSaveUnsyncedCredentialsLocallyView::OnSaveClicked() {
}
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
~PasswordSaveUnsyncedCredentialsLocallyView() override;
private:
// PasswordBubbleViewBase overrides.
// PasswordBubbleViewBase:
PasswordBubbleControllerBase* GetController() override;
const PasswordBubbleControllerBase* GetController() const override;
// LocationBarBubbleDelegateView overrides.
bool ShouldShowCloseButton() const override;
gfx::Size CalculatePreferredSize() const override;
void CreateLayout();
void ButtonPressed(views::Checkbox* checkbox);
......
......@@ -343,13 +343,6 @@ bool PasswordSaveUpdateView::Accept() {
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() {
if (username_dropdown_ && username_dropdown_->GetText().empty())
return username_dropdown_;
......@@ -373,10 +366,6 @@ gfx::ImageSkia PasswordSaveUpdateView::GetWindowIcon() {
return gfx::ImageSkia();
}
bool PasswordSaveUpdateView::ShouldShowCloseButton() const {
return true;
}
void PasswordSaveUpdateView::AddedToWidget() {
static_cast<views::Label*>(GetBubbleFrameView()->title())
->SetAllowCharacterBreak(true);
......
......@@ -35,11 +35,9 @@ class PasswordSaveUpdateView : public PasswordBubbleViewBase {
const PasswordBubbleControllerBase* GetController() const override;
// PasswordBubbleViewBase:
gfx::Size CalculatePreferredSize() const override;
views::View* GetInitiallyFocusedView() override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override;
gfx::ImageSkia GetWindowIcon() override;
bool ShouldShowCloseButton() const override;
bool Accept() override;
// View:
......
......@@ -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() {
if (username_dropdown_ && username_dropdown_->GetText().empty())
return username_dropdown_;
......@@ -591,10 +583,6 @@ gfx::ImageSkia PasswordSaveUpdateWithAccountStoreView::GetWindowIcon() {
return gfx::ImageSkia();
}
bool PasswordSaveUpdateWithAccountStoreView::ShouldShowCloseButton() const {
return true;
}
void PasswordSaveUpdateWithAccountStoreView::AddedToWidget() {
static_cast<views::Label*>(GetBubbleFrameView()->title())
->SetAllowCharacterBreak(true);
......
......@@ -62,11 +62,9 @@ class PasswordSaveUpdateWithAccountStoreView
void OnWidgetDestroying(views::Widget* widget) override;
// PasswordBubbleViewBase:
gfx::Size CalculatePreferredSize() const override;
views::View* GetInitiallyFocusedView() override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override;
gfx::ImageSkia GetWindowIcon() override;
bool ShouldShowCloseButton() const override;
// View:
void AddedToWidget() override;
......
......@@ -63,17 +63,6 @@ PostSaveCompromisedBubbleView::GetController() const {
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() {
PasswordBubbleViewBase::OnThemeChanged();
int image_id = controller_.GetImageID(
......
......@@ -20,8 +20,6 @@ class PostSaveCompromisedBubbleView : public PasswordBubbleViewBase {
// PasswordBubbleViewBase:
PostSaveCompromisedBubbleController* GetController() override;
const PostSaveCompromisedBubbleController* GetController() const override;
gfx::Size CalculatePreferredSize() const override;
bool ShouldShowCloseButton() const override;
void OnThemeChanged() override;
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