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

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

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