Show the Translate bubble when the content web view is not focused

This CL changes the logic to determine whether the Translate bubble is
to be shown. Before this CL, it is not considered the case when the
contents web view is NOT focused. This CL changes this logic to show the
bubble when the content webview and an input element is focused and the
user is NOT trying to show the bubble explicitly. The latter condition
is checked by GetLocationBarView()->IsMouseHovered() because just after
clicking the Translate icon on the Omnibox, the content web view might
still be focused.

BUG=372755
TEST=manual

Review URL: https://codereview.chromium.org/289983002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271966 0039d316-1c4b-4281-b951-d872f2087c98
parent a5473ab0
......@@ -517,10 +517,6 @@ void TranslateTabHelper::ShowBubble(translate::TranslateStep step,
if (web_contents() != browser->tab_strip_model()->GetActiveWebContents())
return;
content::RenderViewHost* rvh = web_contents()->GetRenderViewHost();
if (rvh->IsFocusedElementEditable())
return;
// This ShowBubble function is also used for upating the existing bubble.
// However, with the bubble shown, any browser windows are NOT activated
// because the bubble takes the focus from the other widgets including the
......
......@@ -1160,6 +1160,13 @@ void BrowserView::ShowBookmarkAppBubble(
void BrowserView::ShowTranslateBubble(content::WebContents* web_contents,
translate::TranslateStep step,
TranslateErrors::Type error_type) {
if (contents_web_view_->HasFocus() &&
!GetLocationBarView()->IsMouseHovered()) {
content::RenderViewHost* rvh = web_contents->GetRenderViewHost();
if (rvh->IsFocusedElementEditable())
return;
}
TranslateTabHelper* translate_tab_helper =
TranslateTabHelper::FromWebContents(web_contents);
LanguageState& language_state = translate_tab_helper->GetLanguageState();
......
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