OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/views/frame/browser_view.h" | 11 #include "chrome/browser/ui/views/frame/browser_view.h" |
12 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 12 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
13 #include "chrome/browser/ui/views/toolbar_view.h" | 13 #include "chrome/browser/ui/views/toolbar_view.h" |
14 #include "chrome/browser/ui/views/window.h" | 14 #include "chrome/browser/ui/views/window.h" |
| 15 #include "content/browser/resource_context.h" |
| 16 #include "content/browser/speech/speech_input_manager.h" |
15 #include "content/browser/tab_contents/tab_contents.h" | 17 #include "content/browser/tab_contents/tab_contents.h" |
16 #include "content/browser/tab_contents/tab_contents_view.h" | 18 #include "content/browser/tab_contents/tab_contents_view.h" |
17 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
18 #include "grit/theme_resources.h" | 20 #include "grit/theme_resources.h" |
19 #include "media/audio/audio_manager.h" | |
20 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
21 #include "ui/base/resource/resource_bundle.h" | 22 #include "ui/base/resource/resource_bundle.h" |
22 #include "ui/views/bubble/bubble_delegate.h" | 23 #include "ui/views/bubble/bubble_delegate.h" |
23 #include "ui/views/controls/button/text_button.h" | 24 #include "ui/views/controls/button/text_button.h" |
24 #include "ui/views/controls/image_view.h" | 25 #include "ui/views/controls/image_view.h" |
25 #include "ui/views/controls/label.h" | 26 #include "ui/views/controls/label.h" |
26 #include "ui/views/controls/link.h" | 27 #include "ui/views/controls/link.h" |
27 #include "ui/views/controls/link_listener.h" | 28 #include "ui/views/controls/link_listener.h" |
28 #include "ui/views/layout/layout_constants.h" | 29 #include "ui/views/layout/layout_constants.h" |
29 | 30 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 delegate_->InfoBubbleButtonClicked(SpeechInputBubble::BUTTON_CANCEL); | 198 delegate_->InfoBubbleButtonClicked(SpeechInputBubble::BUTTON_CANCEL); |
198 } else if (source == try_again_) { | 199 } else if (source == try_again_) { |
199 delegate_->InfoBubbleButtonClicked(SpeechInputBubble::BUTTON_TRY_AGAIN); | 200 delegate_->InfoBubbleButtonClicked(SpeechInputBubble::BUTTON_TRY_AGAIN); |
200 } else { | 201 } else { |
201 NOTREACHED() << "Unknown button"; | 202 NOTREACHED() << "Unknown button"; |
202 } | 203 } |
203 } | 204 } |
204 | 205 |
205 void SpeechInputBubbleView::LinkClicked(views::Link* source, int event_flags) { | 206 void SpeechInputBubbleView::LinkClicked(views::Link* source, int event_flags) { |
206 DCHECK_EQ(source, mic_settings_); | 207 DCHECK_EQ(source, mic_settings_); |
207 AudioManager::GetAudioManager()->ShowAudioInputSettings(); | 208 speech_input::SpeechInputManager::ShowAudioInputSettingsFromUI( |
| 209 &tab_contents_->browser_context()->GetResourceContext()); |
208 } | 210 } |
209 | 211 |
210 gfx::Size SpeechInputBubbleView::GetPreferredSize() { | 212 gfx::Size SpeechInputBubbleView::GetPreferredSize() { |
211 int width = heading_->GetPreferredSize().width(); | 213 int width = heading_->GetPreferredSize().width(); |
212 int control_width = cancel_->GetPreferredSize().width(); | 214 int control_width = cancel_->GetPreferredSize().width(); |
213 if (try_again_->IsVisible()) { | 215 if (try_again_->IsVisible()) { |
214 control_width += try_again_->GetPreferredSize().width() + | 216 control_width += try_again_->GetPreferredSize().width() + |
215 views::kRelatedButtonHSpacing; | 217 views::kRelatedButtonHSpacing; |
216 } | 218 } |
217 width = std::max(width, control_width); | 219 width = std::max(width, control_width); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 } | 369 } |
368 | 370 |
369 } // namespace | 371 } // namespace |
370 | 372 |
371 SpeechInputBubble* SpeechInputBubble::CreateNativeBubble( | 373 SpeechInputBubble* SpeechInputBubble::CreateNativeBubble( |
372 TabContents* tab_contents, | 374 TabContents* tab_contents, |
373 SpeechInputBubble::Delegate* delegate, | 375 SpeechInputBubble::Delegate* delegate, |
374 const gfx::Rect& element_rect) { | 376 const gfx::Rect& element_rect) { |
375 return new SpeechInputBubbleImpl(tab_contents, delegate, element_rect); | 377 return new SpeechInputBubbleImpl(tab_contents, delegate, element_rect); |
376 } | 378 } |
OLD | NEW |