Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: chrome/browser/ui/views/translate/translate_bubble_view.cc

Issue 425223003: Translate: Have the bubble not to steal focus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" 5 #include "chrome/browser/ui/views/translate/translate_bubble_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 ChromeTranslateClient::GetManagerFromWebContents(web_contents) 119 ChromeTranslateClient::GetManagerFromWebContents(web_contents)
120 ->GetWeakPtr(), 120 ->GetWeakPtr(),
121 source_language, 121 source_language,
122 target_language)); 122 target_language));
123 scoped_ptr<TranslateBubbleModel> model( 123 scoped_ptr<TranslateBubbleModel> model(
124 new TranslateBubbleModelImpl(step, ui_delegate.Pass())); 124 new TranslateBubbleModelImpl(step, ui_delegate.Pass()));
125 TranslateBubbleView* view = new TranslateBubbleView(anchor_view, 125 TranslateBubbleView* view = new TranslateBubbleView(anchor_view,
126 model.Pass(), 126 model.Pass(),
127 error_type, 127 error_type,
128 web_contents); 128 web_contents);
129 views::BubbleDelegateView::CreateBubble(view)->Show(); 129 if (is_user_gesture)
130 views::BubbleDelegateView::CreateBubble(view)->Show();
131 else
132 views::BubbleDelegateView::CreateBubble(view)->ShowInactive();
130 } 133 }
131 134
132 // static 135 // static
136 void TranslateBubbleView::CloseBubble() {
137 if (!IsShowing())
138 return;
139
140 translate_bubble_view_->GetWidget()->CloseNow();
sky 2014/07/31 15:53:19 Is there a reason you need closenow rather than cl
hajimehoshi 2014/08/01 09:46:06 No. Done.
141 }
142
143 // static
133 bool TranslateBubbleView::IsShowing() { 144 bool TranslateBubbleView::IsShowing() {
134 return translate_bubble_view_ != NULL; 145 return translate_bubble_view_ != NULL;
135 } 146 }
136 147
137 // static 148 // static
138 TranslateBubbleView* TranslateBubbleView::GetCurrentBubble() { 149 TranslateBubbleView* TranslateBubbleView::GetCurrentBubble() {
139 return translate_bubble_view_; 150 return translate_bubble_view_;
140 } 151 }
141 152
142 void TranslateBubbleView::Init() { 153 void TranslateBubbleView::Init() {
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 model_->ShouldAlwaysTranslate()); 762 model_->ShouldAlwaysTranslate());
752 } 763 }
753 764
754 base::string16 label; 765 base::string16 label;
755 if (model_->IsPageTranslatedInCurrentLanguages()) 766 if (model_->IsPageTranslatedInCurrentLanguages())
756 label = l10n_util::GetStringUTF16(IDS_DONE); 767 label = l10n_util::GetStringUTF16(IDS_DONE);
757 else 768 else
758 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT); 769 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT);
759 advanced_done_button_->SetText(label); 770 advanced_done_button_->SetText(label);
760 } 771 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698