Commit 63244525 authored by Tina Wang's avatar Tina Wang Committed by Commit Bot

[SendTabToSelf]Keep omnibox icon when the user unfocus the omnibox

Previously the omnibox icon will show and hide according to whether the
user focuses on the omnibox. Now it won't hide when the user unfocuses
the omnibox.

There is a updated summary of how send tab to self omnibox icon shows
and hides:
- If showing:
	keep showing til the user start to edit the url.
- If hidden:
	show if send tab to self feature is offered, omnibox is focused,
	and the url has not been edited.

Bug: 978520
Change-Id: Id3f2a368a283c43f35dbe83847d593eba2498e66
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1715511
Commit-Queue: Tina Wang <tinazwang@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682540}
parent 342b0294
......@@ -106,6 +106,7 @@
#include "chrome/browser/ui/views/profiles/profile_indicator_icon.h"
#include "chrome/browser/ui/views/profiles/profile_menu_view_base.h"
#include "chrome/browser/ui/views/send_tab_to_self/send_tab_to_self_bubble_view_impl.h"
#include "chrome/browser/ui/views/send_tab_to_self/send_tab_to_self_icon_view.h"
#include "chrome/browser/ui/views/sharing/click_to_call/click_to_call_dialog_view.h"
#include "chrome/browser/ui/views/status_bubble_views.h"
#include "chrome/browser/ui/views/tab_contents/chrome_web_contents_view_focus_helper.h"
......@@ -1419,13 +1420,13 @@ send_tab_to_self::SendTabToSelfBubbleView* BrowserView::ShowSendTabToSelfBubble(
return nullptr;
}
LocationBarView* location_bar = GetLocationBarView();
views::View* anchor_view = location_bar;
send_tab_to_self::SendTabToSelfBubbleViewImpl* bubble =
new send_tab_to_self::SendTabToSelfBubbleViewImpl(
anchor_view, gfx::Point(), web_contents, controller);
GetLocationBarView(), gfx::Point(), web_contents, controller);
PageActionIconView* icon_view =
GetLocationBarView()->send_tab_to_self_icon_view();
if (icon_view)
bubble->SetHighlightedButton(icon_view);
views::BubbleDialogDelegateView::CreateBubble(bubble);
bubble->Show(send_tab_to_self::SendTabToSelfBubbleViewImpl::USER_GESTURE);
......
......@@ -97,16 +97,6 @@ void SendTabToSelfBubbleViewImpl::OnPaint(gfx::Canvas* canvas) {
void SendTabToSelfBubbleViewImpl::Show(DisplayReason reason) {
ShowForReason(reason);
// Keeps the send tab to self icon in omnibox and be highlighted while
// showing the bubble.
views::Button* highlight_button =
BrowserView::GetBrowserViewForBrowser(
chrome::FindBrowserWithWebContents(web_contents_))
->toolbar_button_provider()
->GetOmniboxPageActionIconContainerView()
->GetPageActionIconView(PageActionIconType::kSendTabToSelf);
highlight_button->SetVisible(true);
SetHighlightedButton(highlight_button);
}
const std::vector<std::unique_ptr<SendTabToSelfBubbleDeviceButton>>&
......
......@@ -50,6 +50,14 @@ bool SendTabToSelfIconView::Update() {
return false;
}
if (was_visible) {
// If send tab to self icon is showing:
// Hides the icon if the url is being editing.
if (omnibox_view->model()->user_input_in_progress()) {
SetVisible(false);
}
} else {
// If send tab to self icon is hiding:
// Shows the send tab to self icon in omnibox when:
// send tab to self feature offered, and
// mouse focuses on the omnibox, and
......@@ -57,14 +65,13 @@ bool SendTabToSelfIconView::Update() {
if (send_tab_to_self::ShouldOfferFeature(web_contents) &&
omnibox_view->model()->has_focus() &&
!omnibox_view->model()->user_input_in_progress()) {
// Shows the animation one time per browser session.
// Shows the animation one time per window.
if (!was_animation_shown_) {
AnimateIn(IDS_OMNIBOX_ICON_SEND_TAB_TO_SELF);
was_animation_shown_ = true;
}
SetVisible(true);
} else {
SetVisible(false);
}
}
return was_visible != GetVisible();
......
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