Commit 115d4878 authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

[Passwords] Migrate Password Manager Bubble to use SetTitle() API

All subclasses PasswordBubbleControllerBase return a fixed
title (i.e. the title doesn't change during the life time
of the controller)
except SaveUpdateBubbleController.

Therefore, for all other controllers, it's safe to set the title
only once.

For SaveUpdateBubbleController(), GetTitle() has been made public
such that the view can query it when the title changes.

Bug: 1044038,1090740
Change-Id: I47799ad4b2b55568bfbae3ef9b884c1b25085d04
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2231038
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#775747}
parent ab3b65fe
...@@ -233,6 +233,10 @@ bool SaveUpdateBubbleController::RevealPasswords() { ...@@ -233,6 +233,10 @@ bool SaveUpdateBubbleController::RevealPasswords() {
return reveal_immediately; return reveal_immediately;
} }
base::string16 SaveUpdateBubbleController::GetTitle() const {
return title_;
}
void SaveUpdateBubbleController::ReportInteractions() { void SaveUpdateBubbleController::ReportInteractions() {
if (state_ == password_manager::ui::CHROME_SIGN_IN_PROMO_STATE) if (state_ == password_manager::ui::CHROME_SIGN_IN_PROMO_STATE)
return; return;
...@@ -278,7 +282,3 @@ void SaveUpdateBubbleController::ReportInteractions() { ...@@ -278,7 +282,3 @@ void SaveUpdateBubbleController::ReportInteractions() {
if (metrics_recorder_) if (metrics_recorder_)
metrics_recorder_->RecordUIDismissalReason(dismissal_reason_); metrics_recorder_->RecordUIDismissalReason(dismissal_reason_);
} }
base::string16 SaveUpdateBubbleController::GetTitle() const {
return title_;
}
...@@ -61,6 +61,9 @@ class SaveUpdateBubbleController : public PasswordBubbleControllerBase { ...@@ -61,6 +61,9 @@ class SaveUpdateBubbleController : public PasswordBubbleControllerBase {
// re-authentication is successful. // re-authentication is successful.
bool RevealPasswords(); bool RevealPasswords();
// PasswordBubbleControllerBase methods:
base::string16 GetTitle() const override;
password_manager::ui::State state() const { return state_; } password_manager::ui::State state() const { return state_; }
const autofill::PasswordForm& pending_password() const { const autofill::PasswordForm& pending_password() const {
...@@ -87,7 +90,6 @@ class SaveUpdateBubbleController : public PasswordBubbleControllerBase { ...@@ -87,7 +90,6 @@ class SaveUpdateBubbleController : public PasswordBubbleControllerBase {
private: private:
// PasswordBubbleControllerBase methods: // PasswordBubbleControllerBase methods:
base::string16 GetTitle() const override;
void ReportInteractions() override; void ReportInteractions() override;
// Origin of the page from where this bubble was triggered. // Origin of the page from where this bubble was triggered.
......
...@@ -119,18 +119,6 @@ const content::WebContents* PasswordBubbleViewBase::GetWebContents() const { ...@@ -119,18 +119,6 @@ const content::WebContents* PasswordBubbleViewBase::GetWebContents() const {
return controller->GetWebContents(); return controller->GetWebContents();
} }
base::string16 PasswordBubbleViewBase::GetWindowTitle() const {
const PasswordBubbleControllerBase* controller = GetController();
DCHECK(controller);
return controller->GetTitle();
}
bool PasswordBubbleViewBase::ShouldShowWindowTitle() const {
const PasswordBubbleControllerBase* controller = GetController();
DCHECK(controller);
return !controller->GetTitle().empty();
}
PasswordBubbleViewBase::PasswordBubbleViewBase( PasswordBubbleViewBase::PasswordBubbleViewBase(
content::WebContents* web_contents, content::WebContents* web_contents,
views::View* anchor_view, views::View* anchor_view,
...@@ -151,6 +139,14 @@ PasswordBubbleViewBase::~PasswordBubbleViewBase() { ...@@ -151,6 +139,14 @@ PasswordBubbleViewBase::~PasswordBubbleViewBase() {
g_manage_passwords_bubble_ = nullptr; g_manage_passwords_bubble_ = nullptr;
} }
void PasswordBubbleViewBase::Init() {
LocationBarBubbleDelegateView::Init();
const PasswordBubbleControllerBase* controller = GetController();
DCHECK(controller);
SetTitle(controller->GetTitle());
SetShowTitle(!controller->GetTitle().empty());
}
void PasswordBubbleViewBase::OnWidgetClosing(views::Widget* widget) { void PasswordBubbleViewBase::OnWidgetClosing(views::Widget* widget) {
LocationBarBubbleDelegateView::OnWidgetClosing(widget); LocationBarBubbleDelegateView::OnWidgetClosing(widget);
if (widget != GetWidget()) if (widget != GetWidget())
......
...@@ -57,10 +57,6 @@ class PasswordBubbleViewBase : public LocationBarBubbleDelegateView { ...@@ -57,10 +57,6 @@ class PasswordBubbleViewBase : public LocationBarBubbleDelegateView {
virtual PasswordBubbleControllerBase* GetController() = 0; virtual PasswordBubbleControllerBase* GetController() = 0;
virtual const PasswordBubbleControllerBase* GetController() const = 0; virtual const PasswordBubbleControllerBase* GetController() const = 0;
// LocationBarBubbleDelegateView:
base::string16 GetWindowTitle() const override;
bool ShouldShowWindowTitle() const override;
protected: protected:
// The |easily_dismissable| flag indicates if the bubble should close upon // The |easily_dismissable| flag indicates if the bubble should close upon
// a click in the content area of the browser. // a click in the content area of the browser.
...@@ -71,6 +67,9 @@ class PasswordBubbleViewBase : public LocationBarBubbleDelegateView { ...@@ -71,6 +67,9 @@ class PasswordBubbleViewBase : public LocationBarBubbleDelegateView {
~PasswordBubbleViewBase() override; ~PasswordBubbleViewBase() override;
private: private:
// views::BubbleDialogDelegateView:
void Init() override;
// WidgetObserver: // WidgetObserver:
void OnWidgetClosing(views::Widget* widget) override; void OnWidgetClosing(views::Widget* widget) override;
......
...@@ -466,7 +466,7 @@ void PasswordSaveUpdateView::ReplaceWithPromo() { ...@@ -466,7 +466,7 @@ void PasswordSaveUpdateView::ReplaceWithPromo() {
NOTREACHED(); NOTREACHED();
} }
GetWidget()->UpdateWindowIcon(); GetWidget()->UpdateWindowIcon();
GetWidget()->UpdateWindowTitle(); SetTitle(controller_.GetTitle());
UpdateDialogButtons(); UpdateDialogButtons();
DialogModelChanged(); DialogModelChanged();
......
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