| OLD | NEW |
| 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_manager.h" | 5 #include "chrome/browser/speech/speech_input_manager.h" |
| 6 | 6 |
| 7 #include <map> |
| 8 #include <string> |
| 9 |
| 7 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| 8 #include "base/lock.h" | 11 #include "base/lock.h" |
| 9 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
| 10 #include "base/singleton.h" | 13 #include "base/singleton.h" |
| 11 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/browser_process.h" | |
| 13 #include "chrome/browser/browser_thread.h" | 15 #include "chrome/browser/browser_thread.h" |
| 14 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
| 15 #include "chrome/browser/speech/speech_input_bubble_controller.h" | 17 #include "chrome/browser/speech/speech_input_bubble_controller.h" |
| 16 #include "chrome/browser/speech/speech_recognizer.h" | 18 #include "chrome/browser/speech/speech_recognizer.h" |
| 17 #include "chrome/browser/tab_contents/infobar_delegate.h" | 19 #include "chrome/browser/tab_contents/infobar_delegate.h" |
| 18 #include "chrome/browser/tab_contents/tab_contents.h" | 20 #include "chrome/browser/tab_contents/tab_contents.h" |
| 19 #include "chrome/browser/tab_contents/tab_util.h" | 21 #include "chrome/browser/tab_contents/tab_util.h" |
| 20 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 21 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
| 22 #include "media/audio/audio_manager.h" | 24 #include "media/audio/audio_manager.h" |
| 23 #include <map> | |
| 24 | 25 |
| 25 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
| 27 #include "chrome/browser/browser_process.h" |
| 26 #include "chrome/installer/util/wmi.h" | 28 #include "chrome/installer/util/wmi.h" |
| 27 #endif | 29 #endif |
| 28 | 30 |
| 29 namespace { | 31 namespace { |
| 30 | 32 |
| 31 // Asynchronously fetches the PC and audio hardware/driver info on windows if | 33 // Asynchronously fetches the PC and audio hardware/driver info on windows if |
| 32 // the user has opted into UMA. This information is sent with speech input | 34 // the user has opted into UMA. This information is sent with speech input |
| 33 // requests to the server for identifying and improving quality issues with | 35 // requests to the server for identifying and improving quality issues with |
| 34 // specific device configurations. | 36 // specific device configurations. |
| 35 class HardwareInfo : public base::RefCountedThreadSafe<HardwareInfo> { | 37 class HardwareInfo : public base::RefCountedThreadSafe<HardwareInfo> { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 64 | 66 |
| 65 std::string value() { | 67 std::string value() { |
| 66 AutoLock lock(lock_); | 68 AutoLock lock(lock_); |
| 67 return value_; | 69 return value_; |
| 68 } | 70 } |
| 69 | 71 |
| 70 private: | 72 private: |
| 71 Lock lock_; | 73 Lock lock_; |
| 72 std::string value_; | 74 std::string value_; |
| 73 | 75 |
| 74 #else // defined(OS_WIN) | 76 #else // defined(OS_WIN) |
| 75 void Refresh() {} | 77 void Refresh() {} |
| 76 std::string value() { return std::string(); } | 78 std::string value() { return std::string(); } |
| 77 #endif // defined(OS_WIN) | 79 #endif // defined(OS_WIN) |
| 78 | 80 |
| 79 DISALLOW_COPY_AND_ASSIGN(HardwareInfo); | 81 DISALLOW_COPY_AND_ASSIGN(HardwareInfo); |
| 80 }; | 82 }; |
| 81 | 83 |
| 82 } | 84 } // namespace |
| 83 | 85 |
| 84 namespace speech_input { | 86 namespace speech_input { |
| 85 | 87 |
| 86 class SpeechInputManagerImpl : public SpeechInputManager, | 88 class SpeechInputManagerImpl : public SpeechInputManager, |
| 87 public SpeechInputBubbleControllerDelegate, | 89 public SpeechInputBubbleControllerDelegate, |
| 88 public SpeechRecognizerDelegate { | 90 public SpeechRecognizerDelegate { |
| 89 public: | 91 public: |
| 90 // SpeechInputManager methods. | 92 // SpeechInputManager methods. |
| 91 virtual void StartRecognition(SpeechInputManagerDelegate* delegate, | 93 virtual void StartRecognition(SpeechInputManagerDelegate* delegate, |
| 92 int caller_id, | 94 int caller_id, |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 // to the user, abort it since user has switched focus. Otherwise | 329 // to the user, abort it since user has switched focus. Otherwise |
| 328 // recognition has started and keep that going so user can start speaking to | 330 // recognition has started and keep that going so user can start speaking to |
| 329 // another element while this gets the results in parallel. | 331 // another element while this gets the results in parallel. |
| 330 if (recording_caller_id_ == caller_id || !requests_[caller_id].is_active) { | 332 if (recording_caller_id_ == caller_id || !requests_[caller_id].is_active) { |
| 331 CancelRecognitionAndInformDelegate(caller_id); | 333 CancelRecognitionAndInformDelegate(caller_id); |
| 332 } | 334 } |
| 333 } | 335 } |
| 334 } | 336 } |
| 335 | 337 |
| 336 } // namespace speech_input | 338 } // namespace speech_input |
| OLD | NEW |