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

Unified Diff: chrome/browser/ui/views/speech_recognition_bubble_views.cc

Issue 167283005: Close SpeechRecognitionBubble on pressing the Escape key. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed review comment. Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/speech_recognition_bubble_views.cc
diff --git a/chrome/browser/ui/views/speech_recognition_bubble_views.cc b/chrome/browser/ui/views/speech_recognition_bubble_views.cc
index f7a122c5f24f4c1251d2bcceca1dac7bee0eb3c2..e1699dfbebf49548b9cc0032981ad7411613790a 100644
--- a/chrome/browser/ui/views/speech_recognition_bubble_views.cc
+++ b/chrome/browser/ui/views/speech_recognition_bubble_views.cc
@@ -64,6 +64,7 @@ class SpeechRecognitionBubbleView : public views::BubbleDelegateView,
virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
// views::View overrides.
+ virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
virtual gfx::Size GetPreferredSize() OVERRIDE;
virtual void Layout() OVERRIDE;
@@ -107,10 +108,12 @@ SpeechRecognitionBubbleView::SpeechRecognitionBubbleView(
display_mode_(SpeechRecognitionBubbleBase::DISPLAY_MODE_WARM_UP),
kIconLayoutMinWidth(ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
IDR_SPEECH_INPUT_MIC_EMPTY)->width()) {
- // The bubble lifetime is managed by its controller; closing on escape or
- // explicitly closing on deactivation will cause unexpected behavior.
- set_close_on_esc(false);
+ // The bubble lifetime is managed by its controller; explicitly closing
+ // on deactivation will cause unexpected behavior.
set_close_on_deactivate(false);
+ // Prevent default behavior of bubble closure on escape key and handle
+ // it in the AcceleratorPressed() to avoid an unexpected behavior.
+ set_close_on_esc(false);
}
void SpeechRecognitionBubbleView::OnWidgetActivationChanged(
@@ -225,6 +228,17 @@ void SpeechRecognitionBubbleView::LinkClicked(views::Link* source,
content::SpeechRecognitionManager::GetInstance()->ShowAudioInputSettings();
}
+bool SpeechRecognitionBubbleView::AcceleratorPressed(
+ const ui::Accelerator& accelerator) {
+ // The accelerator is added by BubbleDelegateView.
+ if (accelerator.key_code() == ui::VKEY_ESCAPE) {
+ delegate_->InfoBubbleButtonClicked(SpeechRecognitionBubble::BUTTON_CANCEL);
+ return true;
+ }
+
+ return BubbleDelegateView::AcceleratorPressed(accelerator);
+}
+
gfx::Size SpeechRecognitionBubbleView::GetPreferredSize() {
int width = heading_->GetPreferredSize().width();
int control_width = cancel_->GetPreferredSize().width();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698