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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/command_line.h" | |
9 #include "base/lock.h" | |
Satish
2011/01/06 21:49:41
is this required?
| |
8 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
9 #include "base/singleton.h" | 11 #include "base/lazy_instance.h" |
Satish
2011/01/06 21:49:41
are these 2 lines required?
| |
10 #include "chrome/browser/chrome_thread.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/browser_thread.h" | |
14 #include "chrome/common/chrome_switches.h" | |
15 #include "chrome/browser/prefs/pref_service.h" | |
11 #include "chrome/browser/speech/speech_input_bubble_controller.h" | 16 #include "chrome/browser/speech/speech_input_bubble_controller.h" |
12 #include "chrome/browser/speech/speech_recognizer.h" | 17 #include "chrome/browser/speech/speech_recognizer.h" |
13 #include "chrome/browser/tab_contents/infobar_delegate.h" | 18 #include "chrome/browser/tab_contents/infobar_delegate.h" |
14 #include "chrome/browser/tab_contents/tab_contents.h" | 19 #include "chrome/browser/tab_contents/tab_contents.h" |
15 #include "chrome/browser/tab_contents/tab_util.h" | 20 #include "chrome/browser/tab_contents/tab_util.h" |
16 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
17 #include "media/audio/audio_manager.h" | 22 #include "media/audio/audio_manager.h" |
18 #include <map> | 23 #include <map> |
19 | 24 |
20 namespace speech_input { | 25 namespace speech_input { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 typedef std::map<int, SpeechInputRequest> SpeechRecognizerMap; | 76 typedef std::map<int, SpeechInputRequest> SpeechRecognizerMap; |
72 SpeechRecognizerMap requests_; | 77 SpeechRecognizerMap requests_; |
73 int recording_caller_id_; | 78 int recording_caller_id_; |
74 scoped_refptr<SpeechInputBubbleController> bubble_controller_; | 79 scoped_refptr<SpeechInputBubbleController> bubble_controller_; |
75 }; | 80 }; |
76 | 81 |
77 SpeechInputManager* SpeechInputManager::Get() { | 82 SpeechInputManager* SpeechInputManager::Get() { |
78 return Singleton<SpeechInputManagerImpl>::get(); | 83 return Singleton<SpeechInputManagerImpl>::get(); |
79 } | 84 } |
80 | 85 |
86 bool SpeechInputManager::IsFeatureEnabled() { | |
87 bool enabled = true; | |
88 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
89 | |
90 if (command_line.HasSwitch(switches::kDisableSpeechInput)) { | |
91 enabled = false; | |
92 #if defined(GOOGLE_CHROME_BUILD) | |
93 } else if (!command_line.HasSwitch(switches::kEnableSpeechInput)) { | |
94 // We need to evaluate whether IO is OK here. http://crbug.com/63335. | |
Satish
2011/01/06 21:49:41
since are only rolling out stable channel from thi
| |
95 base::ThreadRestrictions::ScopedAllowIO allow_io; | |
96 // Official Chrome builds have speech input enabled by default only in the | |
97 // dev channel. | |
98 std::string channel = platform_util::GetVersionStringModifier(); | |
99 enabled = (channel == "dev"); | |
100 #endif | |
101 } | |
102 | |
103 return enabled; | |
104 } | |
105 | |
81 SpeechInputManagerImpl::SpeechInputManagerImpl() | 106 SpeechInputManagerImpl::SpeechInputManagerImpl() |
82 : recording_caller_id_(0), | 107 : recording_caller_id_(0), |
83 bubble_controller_(new SpeechInputBubbleController( | 108 bubble_controller_(new SpeechInputBubbleController( |
84 ALLOW_THIS_IN_INITIALIZER_LIST(this))) { | 109 ALLOW_THIS_IN_INITIALIZER_LIST(this))) { |
85 } | 110 } |
86 | 111 |
87 SpeechInputManagerImpl::~SpeechInputManagerImpl() { | 112 SpeechInputManagerImpl::~SpeechInputManagerImpl() { |
88 while (requests_.begin() != requests_.end()) | 113 while (requests_.begin() != requests_.end()) |
89 CancelRecognition(requests_.begin()->first); | 114 CancelRecognition(requests_.begin()->first); |
90 } | 115 } |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 // to the user, abort it since user has switched focus. Otherwise | 271 // to the user, abort it since user has switched focus. Otherwise |
247 // recognition has started and keep that going so user can start speaking to | 272 // recognition has started and keep that going so user can start speaking to |
248 // another element while this gets the results in parallel. | 273 // another element while this gets the results in parallel. |
249 if (recording_caller_id_ == caller_id || !requests_[caller_id].is_active) { | 274 if (recording_caller_id_ == caller_id || !requests_[caller_id].is_active) { |
250 CancelRecognitionAndInformDelegate(caller_id); | 275 CancelRecognitionAndInformDelegate(caller_id); |
251 } | 276 } |
252 } | 277 } |
253 } | 278 } |
254 | 279 |
255 } // namespace speech_input | 280 } // namespace speech_input |
OLD | NEW |