Commit f494f22f authored by Sophey Dong's avatar Sophey Dong Committed by Commit Bot

[SendTabToSelf] Make omnibox icon disappear after "Sending..." animation is shown.

This is flag protected by kSendTabToSelfOmniboxSendingAnimation.

Screencast: http://dr/file/d/1ySVzuot-OZuP-fsyNGWTnKlf2E5Th4p-/view

Bug: 1007536
Change-Id: I5911277b245ae4e7656de10f37c7cc2645016e5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2131847Reviewed-by: default avatarKristi Park <kristipark@chromium.org>
Reviewed-by: default avatarTanya Gupta <tgupta@chromium.org>
Commit-Queue: Sophey Dong <sophey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756739}
parent 1b16ea95
...@@ -55,6 +55,9 @@ void SendTabToSelfIconView::UpdateImpl() { ...@@ -55,6 +55,9 @@ void SendTabToSelfIconView::UpdateImpl() {
return; return;
} }
if (!is_animating_label() && !omnibox_view->model()->has_focus()) {
sending_animation_state_ = AnimationState::kNotShown;
}
if (GetVisible() || if (GetVisible() ||
base::FeatureList::IsEnabled(kSendTabToSelfOmniboxSendingAnimation)) { base::FeatureList::IsEnabled(kSendTabToSelfOmniboxSendingAnimation)) {
SendTabToSelfBubbleController* controller = GetController(); SendTabToSelfBubbleController* controller = GetController();
...@@ -71,6 +74,7 @@ void SendTabToSelfIconView::UpdateImpl() { ...@@ -71,6 +74,7 @@ void SendTabToSelfIconView::UpdateImpl() {
} else { } else {
AnimateIn(IDS_BROWSER_SHARING_OMNIBOX_SENDING_LABEL); AnimateIn(IDS_BROWSER_SHARING_OMNIBOX_SENDING_LABEL);
} }
sending_animation_state_ = AnimationState::kShowing;
} }
} }
if (!GetVisible() && omnibox_view->model()->has_focus() && if (!GetVisible() && omnibox_view->model()->has_focus() &&
...@@ -86,7 +90,10 @@ void SendTabToSelfIconView::UpdateImpl() { ...@@ -86,7 +90,10 @@ void SendTabToSelfIconView::UpdateImpl() {
initial_animation_state_ = AnimationState::kShowing; initial_animation_state_ = AnimationState::kShowing;
controller->SetInitialSendAnimationShown(true); controller->SetInitialSendAnimationShown(true);
} }
SetVisible(true); if (!base::FeatureList::IsEnabled(kSendTabToSelfOmniboxSendingAnimation) ||
sending_animation_state_ == AnimationState::kNotShown) {
SetVisible(true);
}
} }
} }
...@@ -115,9 +122,44 @@ SendTabToSelfBubbleController* SendTabToSelfIconView::GetController() const { ...@@ -115,9 +122,44 @@ SendTabToSelfBubbleController* SendTabToSelfIconView::GetController() const {
web_contents); web_contents);
} }
void SendTabToSelfIconView::AnimationProgressed(
const gfx::Animation* animation) {
if (base::FeatureList::IsEnabled(kSendTabToSelfOmniboxSendingAnimation) &&
sending_animation_state_ == AnimationState::kShowing) {
UpdateOpacity();
}
return PageActionIconView::AnimationProgressed(animation);
}
void SendTabToSelfIconView::AnimationEnded(const gfx::Animation* animation) { void SendTabToSelfIconView::AnimationEnded(const gfx::Animation* animation) {
PageActionIconView::AnimationEnded(animation); PageActionIconView::AnimationEnded(animation);
initial_animation_state_ = AnimationState::kShown; initial_animation_state_ = AnimationState::kShown;
if (base::FeatureList::IsEnabled(kSendTabToSelfOmniboxSendingAnimation) &&
sending_animation_state_ == AnimationState::kShowing) {
UpdateOpacity();
SetVisible(false);
sending_animation_state_ = AnimationState::kShown;
}
}
void SendTabToSelfIconView::UpdateOpacity() {
if (!IsShrinking()) {
DestroyLayer();
SetTextSubpixelRenderingEnabled(true);
return;
}
if (!layer()) {
SetPaintToLayer();
SetTextSubpixelRenderingEnabled(false);
layer()->SetFillsBoundsOpaquely(false);
}
// Large enough number so that there is enough granularity (1/kLargeNumber) in
// the opacity as the animation shrinks.
int kLargeNumber = 100;
layer()->SetOpacity(GetWidthBetween(0, kLargeNumber) /
static_cast<float>(kLargeNumber));
} }
} // namespace send_tab_to_self } // namespace send_tab_to_self
...@@ -30,6 +30,7 @@ class SendTabToSelfIconView : public PageActionIconView { ...@@ -30,6 +30,7 @@ class SendTabToSelfIconView : public PageActionIconView {
base::string16 GetTextForTooltipAndAccessibleName() const override; base::string16 GetTextForTooltipAndAccessibleName() const override;
// gfx::AnimationDelegate: // gfx::AnimationDelegate:
void AnimationProgressed(const gfx::Animation* animation) override;
void AnimationEnded(const gfx::Animation* animation) override; void AnimationEnded(const gfx::Animation* animation) override;
protected: protected:
...@@ -38,6 +39,10 @@ class SendTabToSelfIconView : public PageActionIconView { ...@@ -38,6 +39,10 @@ class SendTabToSelfIconView : public PageActionIconView {
const gfx::VectorIcon& GetVectorIcon() const override; const gfx::VectorIcon& GetVectorIcon() const override;
const char* GetClassName() const override; const char* GetClassName() const override;
// Updates the opacity according to the length of the label view as it is
// shrinking.
void UpdateOpacity();
private: private:
enum class AnimationState { kNotShown, kShowing, kShown }; enum class AnimationState { kNotShown, kShowing, kShown };
...@@ -45,6 +50,9 @@ class SendTabToSelfIconView : public PageActionIconView { ...@@ -45,6 +50,9 @@ class SendTabToSelfIconView : public PageActionIconView {
// Indicates the current state of the initial "Send" animation. // Indicates the current state of the initial "Send" animation.
AnimationState initial_animation_state_ = AnimationState::kNotShown; AnimationState initial_animation_state_ = AnimationState::kNotShown;
// Indicates whether the "Sending..." animation has been shown since the last
// time the omnibox was in focus.
AnimationState sending_animation_state_ = AnimationState::kNotShown;
DISALLOW_COPY_AND_ASSIGN(SendTabToSelfIconView); DISALLOW_COPY_AND_ASSIGN(SendTabToSelfIconView);
}; };
......
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