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

Side by Side Diff: chrome/browser/speech/speech_input_bubble_views.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 "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "chrome/browser/browser.h" 10 #include "chrome/browser/browser.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 78
79 void ContentView::SetRecognizingMode() { 79 void ContentView::SetRecognizingMode() {
80 icon_->SetImage(*ResourceBundle::GetSharedInstance().GetBitmapNamed( 80 icon_->SetImage(*ResourceBundle::GetSharedInstance().GetBitmapNamed(
81 IDR_SPEECH_INPUT_PROCESSING)); 81 IDR_SPEECH_INPUT_PROCESSING));
82 } 82 }
83 83
84 void ContentView::ButtonPressed(views::Button* source, 84 void ContentView::ButtonPressed(views::Button* source,
85 const views::Event& event) { 85 const views::Event& event) {
86 if (source == cancel_) { 86 if (source == cancel_) {
87 delegate_->RecognitionCancelled(); 87 delegate_->InfoBubbleButtonClicked(SpeechInputBubble::BUTTON_CANCEL);
88 } else { 88 } else {
89 NOTREACHED() << "Unknown view"; 89 NOTREACHED() << "Unknown view";
90 } 90 }
91 } 91 }
92 92
93 gfx::Size ContentView::GetPreferredSize() { 93 gfx::Size ContentView::GetPreferredSize() {
94 int width = heading_->GetPreferredSize().width(); 94 int width = heading_->GetPreferredSize().width();
95 int control_width = cancel_->GetPreferredSize().width(); 95 int control_width = cancel_->GetPreferredSize().width();
96 if (control_width > width) 96 if (control_width > width)
97 width = control_width; 97 width = control_width;
(...skipping 21 matching lines...) Expand all
119 height = icon_->GetImage().height(); 119 height = icon_->GetImage().height();
120 icon_->SetBounds(x, y, control_width, height); 120 icon_->SetBounds(x, y, control_width, height);
121 y += height; 121 y += height;
122 122
123 height = cancel_->GetPreferredSize().height(); 123 height = cancel_->GetPreferredSize().height();
124 cancel_->SetBounds(x, y, control_width, height); 124 cancel_->SetBounds(x, y, control_width, height);
125 } 125 }
126 126
127 // Implementation of SpeechInputBubble. 127 // Implementation of SpeechInputBubble.
128 class SpeechInputBubbleImpl 128 class SpeechInputBubbleImpl
129 : public SpeechInputBubble, 129 : public SpeechInputBubbleBase,
130 public InfoBubbleDelegate, 130 public InfoBubbleDelegate,
131 public NotificationObserver { 131 public NotificationObserver {
132 public: 132 public:
133 SpeechInputBubbleImpl(TabContents* tab_contents, 133 SpeechInputBubbleImpl(TabContents* tab_contents,
134 Delegate* delegate, 134 Delegate* delegate,
135 const gfx::Rect& element_rect); 135 const gfx::Rect& element_rect);
136 virtual ~SpeechInputBubbleImpl(); 136 virtual ~SpeechInputBubbleImpl();
137 137
138 virtual void SetRecognizingMode(); 138 virtual void SetRecognizingMode();
139 139
140 // SpeechInputBubble methods.
141 virtual void Show();
142 virtual void Hide();
143 virtual void UpdateLayout();
144
140 // Returns the screen rectangle to use as the info bubble's target. 145 // Returns the screen rectangle to use as the info bubble's target.
141 // |element_rect| is the html element's bounds in page coordinates. 146 // |element_rect| is the html element's bounds in page coordinates.
142 gfx::Rect GetInfoBubbleTarget(const gfx::Rect& element_rect); 147 gfx::Rect GetInfoBubbleTarget(const gfx::Rect& element_rect);
143 148
144 // NotificationObserver implementation. 149 // NotificationObserver implementation.
145 virtual void Observe(NotificationType type, 150 virtual void Observe(NotificationType type,
146 const NotificationSource& source, 151 const NotificationSource& source,
147 const NotificationDetails& details); 152 const NotificationDetails& details);
148 153
149 // InfoBubbleDelegate 154 // InfoBubbleDelegate
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 tab_contents_->GetContainerBounds(&container_rect); 218 tab_contents_->GetContainerBounds(&container_rect);
214 return gfx::Rect( 219 return gfx::Rect(
215 container_rect.x() + element_rect.x() + kBubbleTargetOffsetX, 220 container_rect.x() + element_rect.x() + kBubbleTargetOffsetX,
216 container_rect.y() + element_rect.y() + element_rect.height(), 1, 1); 221 container_rect.y() + element_rect.y() + element_rect.height(), 1, 1);
217 } 222 }
218 223
219 void SpeechInputBubbleImpl::Observe(NotificationType type, 224 void SpeechInputBubbleImpl::Observe(NotificationType type,
220 const NotificationSource& source, 225 const NotificationSource& source,
221 const NotificationDetails& details) { 226 const NotificationDetails& details) {
222 if (type == NotificationType::TAB_CONTENTS_DESTROYED) { 227 if (type == NotificationType::TAB_CONTENTS_DESTROYED) {
223 delegate_->RecognitionCancelled(); 228 delegate_->InfoBubbleButtonClicked(BUTTON_CANCEL);
224 } else { 229 } else {
225 NOTREACHED() << "Unknown notification"; 230 NOTREACHED() << "Unknown notification";
226 } 231 }
227 } 232 }
228 233
229 void SpeechInputBubbleImpl::InfoBubbleClosing(InfoBubble* info_bubble, 234 void SpeechInputBubbleImpl::InfoBubbleClosing(InfoBubble* info_bubble,
230 bool closed_by_escape) { 235 bool closed_by_escape) {
231 registrar_.Remove(this, NotificationType::TAB_CONTENTS_DESTROYED, 236 registrar_.Remove(this, NotificationType::TAB_CONTENTS_DESTROYED,
232 Source<TabContents>(tab_contents_)); 237 Source<TabContents>(tab_contents_));
233 info_bubble_ = NULL; 238 info_bubble_ = NULL;
234 bubble_content_ = NULL; 239 bubble_content_ = NULL;
235 if (!did_invoke_close_) 240 if (!did_invoke_close_)
236 delegate_->InfoBubbleClosed(); 241 delegate_->InfoBubbleFocusChanged();
237 } 242 }
238 243
239 bool SpeechInputBubbleImpl::CloseOnEscape() { 244 bool SpeechInputBubbleImpl::CloseOnEscape() {
240 return false; 245 return false;
241 } 246 }
242 247
243 bool SpeechInputBubbleImpl::FadeInOnShow() { 248 bool SpeechInputBubbleImpl::FadeInOnShow() {
244 return false; 249 return false;
245 } 250 }
246 251
252 void SpeechInputBubbleImpl::Show() {
253 // TODO(satish): Implement.
254 NOTREACHED();
255 }
256
257 void SpeechInputBubbleImpl::Hide() {
258 // TODO(satish): Implement.
259 NOTREACHED();
260 }
261
262 void SpeechInputBubbleImpl::UpdateLayout() {
263 // TODO: Implement.
264 NOTREACHED();
265 }
266
247 } // namespace 267 } // namespace
248 268
249 SpeechInputBubble* SpeechInputBubble::CreateNativeBubble( 269 SpeechInputBubble* SpeechInputBubble::CreateNativeBubble(
250 TabContents* tab_contents, 270 TabContents* tab_contents,
251 SpeechInputBubble::Delegate* delegate, 271 SpeechInputBubble::Delegate* delegate,
252 const gfx::Rect& element_rect) { 272 const gfx::Rect& element_rect) {
253 return new SpeechInputBubbleImpl(tab_contents, delegate, element_rect); 273 return new SpeechInputBubbleImpl(tab_contents, delegate, element_rect);
254 } 274 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698