Translate: Have the bubble not to steal focus

This CL changes the Translate bubble's behavior not to steal the focus.

BUG=378643

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288019 0039d316-1c4b-4281-b951-d872f2087c98
parent f69b4289
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
#include "chrome/browser/ui/views/location_bar/zoom_view.h" #include "chrome/browser/ui/views/location_bar/zoom_view.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h" #include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h"
#include "chrome/browser/ui/views/translate/translate_bubble_view.h"
#include "chrome/browser/ui/zoom/zoom_controller.h" #include "chrome/browser/ui/zoom/zoom_controller.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
...@@ -1040,6 +1041,7 @@ void LocationBarView::Update(const WebContents* contents) { ...@@ -1040,6 +1041,7 @@ void LocationBarView::Update(const WebContents* contents) {
RefreshContentSettingViews(); RefreshContentSettingViews();
generated_credit_card_view_->Update(); generated_credit_card_view_->Update();
ZoomBubbleView::CloseBubble(); ZoomBubbleView::CloseBubble();
TranslateBubbleView::CloseBubble();
RefreshZoomView(); RefreshZoomView();
RefreshPageActionViews(); RefreshPageActionViews();
RefreshTranslateIcon(); RefreshTranslateIcon();
......
...@@ -126,7 +126,18 @@ void TranslateBubbleView::ShowBubble( ...@@ -126,7 +126,18 @@ void TranslateBubbleView::ShowBubble(
model.Pass(), model.Pass(),
error_type, error_type,
web_contents); web_contents);
if (is_user_gesture)
views::BubbleDelegateView::CreateBubble(view)->Show(); views::BubbleDelegateView::CreateBubble(view)->Show();
else
views::BubbleDelegateView::CreateBubble(view)->ShowInactive();
}
// static
void TranslateBubbleView::CloseBubble() {
if (!IsShowing())
return;
translate_bubble_view_->GetWidget()->Close();
} }
// static // static
......
...@@ -51,6 +51,9 @@ class TranslateBubbleView : public views::BubbleDelegateView, ...@@ -51,6 +51,9 @@ class TranslateBubbleView : public views::BubbleDelegateView,
translate::TranslateErrors::Type error_type, translate::TranslateErrors::Type error_type,
bool is_user_gesture); bool is_user_gesture);
// Closes the current bubble if existing.
static void CloseBubble();
// If true, the Translate bubble is being shown. // If true, the Translate bubble is being shown.
static bool IsShowing(); static bool IsShowing();
......
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