Commit 8288c8d6 authored by Anne Lim's avatar Anne Lim Committed by Commit Bot

[AF] Add highlight animation on password save

A blue round circle highlight animation around the avatar button
is displayed when a password is saved. The animation is same as
the one which currently appears on credit card save.

Bug: 964127
Change-Id: I2b76945716201f28c1b15bb8303a1c637a248900
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1817585Reviewed-by: default avatarJared Saul <jsaul@google.com>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarSiyu An <siyua@chromium.org>
Commit-Queue: Anne Lim <annelim@google.com>
Cr-Commit-Position: refs/heads/master@{#702093}
parent 984dcbf9
...@@ -248,6 +248,9 @@ class BrowserWindow : public ui::BaseWindow { ...@@ -248,6 +248,9 @@ class BrowserWindow : public ui::BaseWindow {
// the window. Returns whether any change occurred. // the window. Returns whether any change occurred.
virtual bool UpdatePageActionIcon(PageActionIconType type) = 0; virtual bool UpdatePageActionIcon(PageActionIconType type) = 0;
// Executes highlight animation on toolbar's avatar.
virtual void ShowAvatarHighlightAnimation() = 0;
// Executes the action for the specified page action icon. // Executes the action for the specified page action icon.
virtual void ExecutePageActionIconForTesting(PageActionIconType type) = 0; virtual void ExecutePageActionIconForTesting(PageActionIconType type) = 0;
......
...@@ -518,6 +518,10 @@ bool ManagePasswordsUIController::ArePasswordsRevealedWhenBubbleIsOpened() ...@@ -518,6 +518,10 @@ bool ManagePasswordsUIController::ArePasswordsRevealedWhenBubbleIsOpened()
void ManagePasswordsUIController::SavePasswordInternal() { void ManagePasswordsUIController::SavePasswordInternal() {
passwords_data_.form_manager()->Save(); passwords_data_.form_manager()->Save();
Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
if (!browser)
return;
browser->window()->ShowAvatarHighlightAnimation();
} }
void ManagePasswordsUIController::NeverSavePasswordInternal() { void ManagePasswordsUIController::NeverSavePasswordInternal() {
......
...@@ -1106,6 +1106,13 @@ bool BrowserView::UpdatePageActionIcon(PageActionIconType type) { ...@@ -1106,6 +1106,13 @@ bool BrowserView::UpdatePageActionIcon(PageActionIconType type) {
return icon ? icon->Update() : false; return icon ? icon->Update() : false;
} }
void BrowserView::ShowAvatarHighlightAnimation() {
AvatarToolbarButton* avatar_button = toolbar_->GetAvatarToolbarButton();
if (!avatar_button)
return;
avatar_button->ShowAvatarHighlightAnimation();
}
void BrowserView::ExecutePageActionIconForTesting(PageActionIconType type) { void BrowserView::ExecutePageActionIconForTesting(PageActionIconType type) {
toolbar_button_provider_->GetPageActionIconView(type)->ExecuteForTesting(); toolbar_button_provider_->GetPageActionIconView(type)->ExecuteForTesting();
} }
......
...@@ -346,6 +346,7 @@ class BrowserView : public BrowserWindow, ...@@ -346,6 +346,7 @@ class BrowserView : public BrowserWindow,
bool IsFullscreen() const override; bool IsFullscreen() const override;
bool IsFullscreenBubbleVisible() const override; bool IsFullscreenBubbleVisible() const override;
bool UpdatePageActionIcon(PageActionIconType type) override; bool UpdatePageActionIcon(PageActionIconType type) override;
void ShowAvatarHighlightAnimation() override;
void ExecutePageActionIconForTesting(PageActionIconType type) override; void ExecutePageActionIconForTesting(PageActionIconType type) override;
LocationBar* GetLocationBar() const override; LocationBar* GetLocationBar() const override;
void SetFocusToLocationBar(bool select_all) override; void SetFocusToLocationBar(bool select_all) override;
......
...@@ -233,6 +233,19 @@ void AvatarToolbarButton::SetAutofillIconVisible(bool autofill_icon_visible) { ...@@ -233,6 +233,19 @@ void AvatarToolbarButton::SetAutofillIconVisible(bool autofill_icon_visible) {
UpdateText(); UpdateText();
} }
void AvatarToolbarButton::ShowAvatarHighlightAnimation() {
DCHECK_NE(GetState(), State::kIncognitoProfile);
DCHECK_NE(GetState(), State::kGuestSession);
DCHECK(!profile_->IsOffTheRecord());
ShowHighlightAnimation();
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::BindOnce(&AvatarToolbarButton::HideHighlightAnimation,
weak_ptr_factory_.GetWeakPtr()),
kHighlightAnimationDuration);
}
void AvatarToolbarButton::NotifyClick(const ui::Event& event) { void AvatarToolbarButton::NotifyClick(const ui::Event& event) {
Button::NotifyClick(event); Button::NotifyClick(event);
if (should_reset_user_email_when_no_longer_hovered_or_focused_) if (should_reset_user_email_when_no_longer_hovered_or_focused_)
...@@ -340,16 +353,7 @@ void AvatarToolbarButton::OnTouchUiChanged() { ...@@ -340,16 +353,7 @@ void AvatarToolbarButton::OnTouchUiChanged() {
} }
void AvatarToolbarButton::OnCreditCardSaved() { void AvatarToolbarButton::OnCreditCardSaved() {
DCHECK_NE(GetState(), State::kIncognitoProfile); ShowAvatarHighlightAnimation();
DCHECK_NE(GetState(), State::kGuestSession);
DCHECK(!profile_->IsOffTheRecord());
ShowHighlightAnimation();
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::BindOnce(&AvatarToolbarButton::HideHighlightAnimation,
weak_ptr_factory_.GetWeakPtr()),
kHighlightAnimationDuration);
} }
void AvatarToolbarButton::ExpandToShowEmail() { void AvatarToolbarButton::ExpandToShowEmail() {
......
...@@ -37,6 +37,7 @@ class AvatarToolbarButton : public ToolbarButton, ...@@ -37,6 +37,7 @@ class AvatarToolbarButton : public ToolbarButton,
void UpdateIcon(); void UpdateIcon();
void UpdateText(); void UpdateText();
void SetAutofillIconVisible(bool autofill_icon_visible); void SetAutofillIconVisible(bool autofill_icon_visible);
void ShowAvatarHighlightAnimation();
private: private:
FRIEND_TEST_ALL_PREFIXES(AvatarToolbarButtonTest, FRIEND_TEST_ALL_PREFIXES(AvatarToolbarButtonTest,
......
...@@ -143,6 +143,8 @@ bool TestBrowserWindow::UpdatePageActionIcon(PageActionIconType type) { ...@@ -143,6 +143,8 @@ bool TestBrowserWindow::UpdatePageActionIcon(PageActionIconType type) {
return false; return false;
} }
void TestBrowserWindow::ShowAvatarHighlightAnimation() {}
ToolbarActionsBar* TestBrowserWindow::GetToolbarActionsBar() { ToolbarActionsBar* TestBrowserWindow::GetToolbarActionsBar() {
return nullptr; return nullptr;
} }
......
...@@ -94,6 +94,7 @@ class TestBrowserWindow : public BrowserWindow { ...@@ -94,6 +94,7 @@ class TestBrowserWindow : public BrowserWindow {
bool IsFullscreenBubbleVisible() const override; bool IsFullscreenBubbleVisible() const override;
LocationBar* GetLocationBar() const override; LocationBar* GetLocationBar() const override;
bool UpdatePageActionIcon(PageActionIconType type) override; bool UpdatePageActionIcon(PageActionIconType type) override;
void ShowAvatarHighlightAnimation() override;
void ExecutePageActionIconForTesting(PageActionIconType type) override {} void ExecutePageActionIconForTesting(PageActionIconType type) override {}
void SetFocusToLocationBar(bool select_all) override {} void SetFocusToLocationBar(bool select_all) override {}
void UpdateReloadStopState(bool is_loading, bool force) override {} void UpdateReloadStopState(bool is_loading, bool force) override {}
......
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