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

Side by Side Diff: chrome/browser/speech/speech_input_manager.cc

Issue 6128001: If speech input is disabled and we receive IPC calls, terminate the renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/speech/speech_input_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_manager.h" 5 #include "chrome/browser/speech/speech_input_manager.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
11 #include "base/command_line.h"
11 #include "base/lock.h" 12 #include "base/lock.h"
12 #include "base/ref_counted.h" 13 #include "base/ref_counted.h"
13 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
15 #include "base/threading/thread_restrictions.h"
14 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
15 #include "chrome/browser/browser_thread.h" 17 #include "chrome/browser/browser_thread.h"
18 #include "chrome/common/chrome_switches.h"
16 #include "chrome/browser/prefs/pref_service.h" 19 #include "chrome/browser/prefs/pref_service.h"
17 #include "chrome/browser/speech/speech_input_bubble_controller.h" 20 #include "chrome/browser/speech/speech_input_bubble_controller.h"
18 #include "chrome/browser/speech/speech_recognizer.h" 21 #include "chrome/browser/speech/speech_recognizer.h"
19 #include "chrome/browser/tab_contents/infobar_delegate.h" 22 #include "chrome/browser/tab_contents/infobar_delegate.h"
20 #include "chrome/browser/tab_contents/tab_util.h" 23 #include "chrome/browser/tab_contents/tab_util.h"
21 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
22 #include "grit/generated_resources.h" 25 #include "grit/generated_resources.h"
23 #include "media/audio/audio_manager.h" 26 #include "media/audio/audio_manager.h"
24 27
25 #if defined(OS_WIN) 28 #if defined(OS_WIN)
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 scoped_refptr<HardwareInfo> hardware_info_; 146 scoped_refptr<HardwareInfo> hardware_info_;
144 }; 147 };
145 148
146 static ::base::LazyInstance<SpeechInputManagerImpl> g_speech_input_manager_impl( 149 static ::base::LazyInstance<SpeechInputManagerImpl> g_speech_input_manager_impl(
147 base::LINKER_INITIALIZED); 150 base::LINKER_INITIALIZED);
148 151
149 SpeechInputManager* SpeechInputManager::Get() { 152 SpeechInputManager* SpeechInputManager::Get() {
150 return g_speech_input_manager_impl.Pointer(); 153 return g_speech_input_manager_impl.Pointer();
151 } 154 }
152 155
156 bool SpeechInputManager::IsFeatureEnabled() {
157 bool enabled = true;
158 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
159
160 if (command_line.HasSwitch(switches::kDisableSpeechInput)) {
161 enabled = false;
162 #if defined(GOOGLE_CHROME_BUILD)
163 } else if (!command_line.HasSwitch(switches::kEnableSpeechInput)) {
164 // We need to evaluate whether IO is OK here. http://crbug.com/63335.
165 base::ThreadRestrictions::ScopedAllowIO allow_io;
166 // Official Chrome builds have speech input enabled by default only in the
167 // dev channel.
168 std::string channel = platform_util::GetVersionStringModifier();
169 enabled = (channel == "dev");
170 #endif
171 }
172
173 return enabled;
174 }
175
153 SpeechInputManagerImpl::SpeechInputManagerImpl() 176 SpeechInputManagerImpl::SpeechInputManagerImpl()
154 : recording_caller_id_(0), 177 : recording_caller_id_(0),
155 bubble_controller_(new SpeechInputBubbleController( 178 bubble_controller_(new SpeechInputBubbleController(
156 ALLOW_THIS_IN_INITIALIZER_LIST(this))) { 179 ALLOW_THIS_IN_INITIALIZER_LIST(this))) {
157 } 180 }
158 181
159 SpeechInputManagerImpl::~SpeechInputManagerImpl() { 182 SpeechInputManagerImpl::~SpeechInputManagerImpl() {
160 while (requests_.begin() != requests_.end()) 183 while (requests_.begin() != requests_.end())
161 CancelRecognition(requests_.begin()->first); 184 CancelRecognition(requests_.begin()->first);
162 } 185 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 // to the user, abort it since user has switched focus. Otherwise 354 // to the user, abort it since user has switched focus. Otherwise
332 // recognition has started and keep that going so user can start speaking to 355 // recognition has started and keep that going so user can start speaking to
333 // another element while this gets the results in parallel. 356 // another element while this gets the results in parallel.
334 if (recording_caller_id_ == caller_id || !requests_[caller_id].is_active) { 357 if (recording_caller_id_ == caller_id || !requests_[caller_id].is_active) {
335 CancelRecognitionAndInformDelegate(caller_id); 358 CancelRecognitionAndInformDelegate(caller_id);
336 } 359 }
337 } 360 }
338 } 361 }
339 362
340 } // namespace speech_input 363 } // namespace speech_input
OLDNEW
« no previous file with comments | « chrome/browser/speech/speech_input_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698