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

Side by Side Diff: chrome/browser/speech/speech_input_bubble_gtk.cc

Issue 3352018: Show error messages in speech bubble allowing user to retry as well. (Closed)
Patch Set: Address joth's comments. Created 10 years, 3 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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/speech/speech_input_bubble.h" 5 #include "chrome/browser/speech/speech_input_bubble.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "chrome/browser/gtk/gtk_theme_provider.h" 9 #include "chrome/browser/gtk/gtk_theme_provider.h"
10 #include "chrome/browser/gtk/info_bubble_gtk.h" 10 #include "chrome/browser/gtk/info_bubble_gtk.h"
11 #include "chrome/browser/gtk/owned_widget_gtk.h" 11 #include "chrome/browser/gtk/owned_widget_gtk.h"
12 #include "chrome/browser/tab_contents/tab_contents.h" 12 #include "chrome/browser/tab_contents/tab_contents.h"
13 #include "gfx/gtk_util.h" 13 #include "gfx/gtk_util.h"
14 #include "gfx/rect.h" 14 #include "gfx/rect.h"
15 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
16 #include "grit/theme_resources.h" 16 #include "grit/theme_resources.h"
17 17
18 namespace { 18 namespace {
19 19
20 const int kBubbleControlVerticalSpacing = 10; 20 const int kBubbleControlVerticalSpacing = 10;
21 const int kBubbleControlHorizontalSpacing = 50; 21 const int kBubbleControlHorizontalSpacing = 50;
22 22
23 // Use black for text labels since the bubble has white background. 23 // Use black for text labels since the bubble has white background.
24 const GdkColor kLabelTextColor = gfx::kGdkBlack; 24 const GdkColor kLabelTextColor = gfx::kGdkBlack;
25 25
26 // Implementation of SpeechInputBubble for GTK. This shows a speech input 26 // Implementation of SpeechInputBubble for GTK. This shows a speech input
27 // info bubble on screen. 27 // info bubble on screen.
28 class SpeechInputBubbleGtk 28 class SpeechInputBubbleGtk
29 : public SpeechInputBubble, 29 : public SpeechInputBubbleBase,
30 public InfoBubbleGtkDelegate { 30 public InfoBubbleGtkDelegate {
31 public: 31 public:
32 SpeechInputBubbleGtk(TabContents* tab_contents, 32 SpeechInputBubbleGtk(TabContents* tab_contents,
33 Delegate* delegate, 33 Delegate* delegate,
34 const gfx::Rect& element_rect); 34 const gfx::Rect& element_rect);
35 ~SpeechInputBubbleGtk(); 35 ~SpeechInputBubbleGtk();
36 36
37 private: 37 private:
38 // InfoBubbleDelegate methods. 38 // InfoBubbleDelegate methods.
39 virtual void InfoBubbleClosing(InfoBubbleGtk* info_bubble, 39 virtual void InfoBubbleClosing(InfoBubbleGtk* info_bubble,
40 bool closed_by_escape); 40 bool closed_by_escape);
41 41
42 // SpeechInputBubble methods. 42 // SpeechInputBubble methods.
43 virtual void SetRecognizingMode(); 43 virtual void Show();
44 virtual void Hide();
45 virtual void UpdateLayout();
44 46
45 CHROMEGTK_CALLBACK_0(SpeechInputBubbleGtk, void, OnCancelClicked); 47 CHROMEGTK_CALLBACK_0(SpeechInputBubbleGtk, void, OnCancelClicked);
46 48
47 Delegate* delegate_; 49 Delegate* delegate_;
48 InfoBubbleGtk* info_bubble_; 50 InfoBubbleGtk* info_bubble_;
49 GtkWidget* icon_; 51 GtkWidget* icon_;
50 OwnedWidgetGtk content_; 52 OwnedWidgetGtk content_;
51 53
52 DISALLOW_COPY_AND_ASSIGN(SpeechInputBubbleGtk); 54 DISALLOW_COPY_AND_ASSIGN(SpeechInputBubbleGtk);
53 }; 55 };
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // were destroyed by the caller we don't need to call them back, hence set 106 // were destroyed by the caller we don't need to call them back, hence set
105 // the delegate to NULL here. 107 // the delegate to NULL here.
106 delegate_ = NULL; 108 delegate_ = NULL;
107 content_.Destroy(); 109 content_.Destroy();
108 info_bubble_->Close(); 110 info_bubble_->Close();
109 } 111 }
110 112
111 void SpeechInputBubbleGtk::InfoBubbleClosing(InfoBubbleGtk* info_bubble, 113 void SpeechInputBubbleGtk::InfoBubbleClosing(InfoBubbleGtk* info_bubble,
112 bool closed_by_escape) { 114 bool closed_by_escape) {
113 if (delegate_) 115 if (delegate_)
114 delegate_->InfoBubbleClosed(); 116 delegate_->InfoBubbleFocusChanged();
115 } 117 }
116 118
117 void SpeechInputBubbleGtk::OnCancelClicked(GtkWidget* widget) { 119 void SpeechInputBubbleGtk::OnCancelClicked(GtkWidget* widget) {
118 delegate_->RecognitionCancelled(); 120 delegate_->InfoBubbleButtonClicked(BUTTON_CANCEL);
119 } 121 }
120 122
121 void SpeechInputBubbleGtk::SetRecognizingMode() { 123 void SpeechInputBubbleGtk::Show() {
122 SkBitmap* image = ResourceBundle::GetSharedInstance().GetBitmapNamed( 124 // TODO(satish): Implement.
123 IDR_SPEECH_INPUT_PROCESSING); 125 NOTREACHED();
124 GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(image); 126 }
125 gtk_image_set_from_pixbuf(GTK_IMAGE(icon_), pixbuf); 127
126 g_object_unref(pixbuf); 128 void SpeechInputBubbleGtk::Hide() {
129 // TODO(satish): Implement.
130 NOTREACHED();
131 }
132
133 void SpeechInputBubbleGtk::UpdateLayout() {
134 // TODO: Implement.
135 NOTREACHED();
127 } 136 }
128 137
129 } // namespace 138 } // namespace
130 139
131 SpeechInputBubble* SpeechInputBubble::CreateNativeBubble( 140 SpeechInputBubble* SpeechInputBubble::CreateNativeBubble(
132 TabContents* tab_contents, 141 TabContents* tab_contents,
133 Delegate* delegate, 142 Delegate* delegate,
134 const gfx::Rect& element_rect) { 143 const gfx::Rect& element_rect) {
135 return new SpeechInputBubbleGtk(tab_contents, delegate, element_rect); 144 return new SpeechInputBubbleGtk(tab_contents, delegate, element_rect);
136 } 145 }
137 146
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698