| 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 "content/browser/speech/speech_input_manager.h" | 5 #include "content/browser/speech/speech_input_manager.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/command_line.h" | |
| 11 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 12 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
| 13 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
| 14 #include "base/threading/thread_restrictions.h" | 13 #include "base/threading/thread_restrictions.h" |
| 15 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/platform_util.h" | 16 #include "chrome/browser/platform_util.h" |
| 18 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
| 19 #include "chrome/browser/speech/speech_input_bubble_controller.h" | 18 #include "chrome/browser/speech/speech_input_bubble_controller.h" |
| 20 #include "chrome/browser/tab_contents/tab_util.h" | 19 #include "chrome/browser/tab_contents/tab_util.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 155 |
| 157 base::LazyInstance<SpeechInputManagerImpl> g_speech_input_manager_impl( | 156 base::LazyInstance<SpeechInputManagerImpl> g_speech_input_manager_impl( |
| 158 base::LINKER_INITIALIZED); | 157 base::LINKER_INITIALIZED); |
| 159 | 158 |
| 160 } // namespace | 159 } // namespace |
| 161 | 160 |
| 162 SpeechInputManager* SpeechInputManager::Get() { | 161 SpeechInputManager* SpeechInputManager::Get() { |
| 163 return g_speech_input_manager_impl.Pointer(); | 162 return g_speech_input_manager_impl.Pointer(); |
| 164 } | 163 } |
| 165 | 164 |
| 166 bool SpeechInputManager::IsFeatureEnabled() { | |
| 167 bool enabled = true; | |
| 168 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 169 | |
| 170 if (command_line.HasSwitch(switches::kDisableSpeechInput)) { | |
| 171 enabled = false; | |
| 172 #if defined(GOOGLE_CHROME_BUILD) | |
| 173 } else if (!command_line.HasSwitch(switches::kEnableSpeechInput)) { | |
| 174 // We need to evaluate whether IO is OK here. http://crbug.com/63335. | |
| 175 base::ThreadRestrictions::ScopedAllowIO allow_io; | |
| 176 // Official Chrome builds have speech input enabled by default only in the | |
| 177 // dev channel. | |
| 178 std::string channel = platform_util::GetVersionStringModifier(); | |
| 179 enabled = (channel == "dev"); | |
| 180 #endif | |
| 181 } | |
| 182 | |
| 183 return enabled; | |
| 184 } | |
| 185 | |
| 186 void SpeechInputManager::ShowAudioInputSettings() { | 165 void SpeechInputManager::ShowAudioInputSettings() { |
| 187 // Since AudioManager::ShowAudioInputSettings can potentially launch external | 166 // Since AudioManager::ShowAudioInputSettings can potentially launch external |
| 188 // processes, do that in the FILE thread to not block the calling threads. | 167 // processes, do that in the FILE thread to not block the calling threads. |
| 189 if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) { | 168 if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) { |
| 190 BrowserThread::PostTask( | 169 BrowserThread::PostTask( |
| 191 BrowserThread::FILE, FROM_HERE, | 170 BrowserThread::FILE, FROM_HERE, |
| 192 NewRunnableFunction(&SpeechInputManager::ShowAudioInputSettings)); | 171 NewRunnableFunction(&SpeechInputManager::ShowAudioInputSettings)); |
| 193 return; | 172 return; |
| 194 } | 173 } |
| 195 | 174 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 // to the user, abort it since user has switched focus. Otherwise | 375 // to the user, abort it since user has switched focus. Otherwise |
| 397 // recognition has started and keep that going so user can start speaking to | 376 // recognition has started and keep that going so user can start speaking to |
| 398 // another element while this gets the results in parallel. | 377 // another element while this gets the results in parallel. |
| 399 if (recording_caller_id_ == caller_id || !requests_[caller_id].is_active) { | 378 if (recording_caller_id_ == caller_id || !requests_[caller_id].is_active) { |
| 400 CancelRecognitionAndInformDelegate(caller_id); | 379 CancelRecognitionAndInformDelegate(caller_id); |
| 401 } | 380 } |
| 402 } | 381 } |
| 403 } | 382 } |
| 404 | 383 |
| 405 } // namespace speech_input | 384 } // namespace speech_input |
| OLD | NEW |