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

Side by Side Diff: content/browser/speech/speech_input_dispatcher_host.cc

Issue 7989001: Remove use of default request context and fix use of speech censor flag (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 3 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
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 "content/browser/speech/speech_input_dispatcher_host.h" 5 #include "content/browser/speech/speech_input_dispatcher_host.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "content/browser/content_browser_client.h" 8 #include "content/browser/content_browser_client.h"
9 #include "content/common/speech_input_messages.h" 9 #include "content/common/speech_input_messages.h"
10 10
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 97 }
98 98
99 int SpeechInputDispatcherHost::SpeechInputCallers::request_id(int id) { 99 int SpeechInputDispatcherHost::SpeechInputCallers::request_id(int id) {
100 return callers_[id].request_id; 100 return callers_[id].request_id;
101 } 101 }
102 102
103 //-------------------------- SpeechInputDispatcherHost ------------------------- 103 //-------------------------- SpeechInputDispatcherHost -------------------------
104 104
105 SpeechInputManager* SpeechInputDispatcherHost::manager_; 105 SpeechInputManager* SpeechInputDispatcherHost::manager_;
106 106
107 SpeechInputDispatcherHost::SpeechInputDispatcherHost(int render_process_id) 107 SpeechInputDispatcherHost::SpeechInputDispatcherHost(
108 int render_process_id,
109 net::URLRequestContextGetter* context_getter,
110 bool censor_results)
108 : render_process_id_(render_process_id), 111 : render_process_id_(render_process_id),
109 may_have_pending_requests_(false) { 112 may_have_pending_requests_(false),
113 context_getter_(context_getter),
114 censor_results_(censor_results) {
110 // This is initialized by Browser. Do not add any non-trivial 115 // This is initialized by Browser. Do not add any non-trivial
111 // initialization here, instead do it lazily when required (e.g. see the 116 // initialization here, instead do it lazily when required (e.g. see the
112 // method |manager()|) or add an Init() method. 117 // method |manager()|) or add an Init() method.
113 } 118 }
114 119
115 SpeechInputDispatcherHost::~SpeechInputDispatcherHost() { 120 SpeechInputDispatcherHost::~SpeechInputDispatcherHost() {
116 // If the renderer crashed for some reason or if we didn't receive a proper 121 // If the renderer crashed for some reason or if we didn't receive a proper
117 // Cancel/Stop call for an existing session, cancel such active sessions now. 122 // Cancel/Stop call for an existing session, cancel such active sessions now.
118 // We first check if this dispatcher received any speech IPC requst so that 123 // We first check if this dispatcher received any speech IPC requst so that
119 // we don't end up creating the speech input manager for web pages which don't 124 // we don't end up creating the speech input manager for web pages which don't
(...skipping 28 matching lines...) Expand all
148 } 153 }
149 154
150 void SpeechInputDispatcherHost::OnStartRecognition( 155 void SpeechInputDispatcherHost::OnStartRecognition(
151 const SpeechInputHostMsg_StartRecognition_Params &params) { 156 const SpeechInputHostMsg_StartRecognition_Params &params) {
152 int caller_id = g_speech_input_callers.Get().CreateId( 157 int caller_id = g_speech_input_callers.Get().CreateId(
153 render_process_id_, params.render_view_id, params.request_id); 158 render_process_id_, params.render_view_id, params.request_id);
154 manager()->StartRecognition(this, caller_id, 159 manager()->StartRecognition(this, caller_id,
155 render_process_id_, 160 render_process_id_,
156 params.render_view_id, params.element_rect, 161 params.render_view_id, params.element_rect,
157 params.language, params.grammar, 162 params.language, params.grammar,
158 params.origin_url); 163 params.origin_url,
164 context_getter_.get(),
165 censor_results_);
159 } 166 }
160 167
161 void SpeechInputDispatcherHost::OnCancelRecognition(int render_view_id, 168 void SpeechInputDispatcherHost::OnCancelRecognition(int render_view_id,
162 int request_id) { 169 int request_id) {
163 int caller_id = g_speech_input_callers.Get().GetId( 170 int caller_id = g_speech_input_callers.Get().GetId(
164 render_process_id_, render_view_id, request_id); 171 render_process_id_, render_view_id, request_id);
165 if (caller_id) { 172 if (caller_id) {
166 manager()->CancelRecognition(caller_id); 173 manager()->CancelRecognition(caller_id);
167 // Request sequence ended so remove mapping. 174 // Request sequence ended so remove mapping.
168 g_speech_input_callers.Get().RemoveId(caller_id); 175 g_speech_input_callers.Get().RemoveId(caller_id);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 g_speech_input_callers.Get().render_view_id(caller_id); 215 g_speech_input_callers.Get().render_view_id(caller_id);
209 int caller_request_id = g_speech_input_callers.Get().request_id(caller_id); 216 int caller_request_id = g_speech_input_callers.Get().request_id(caller_id);
210 Send(new SpeechInputMsg_RecognitionComplete(caller_render_view_id, 217 Send(new SpeechInputMsg_RecognitionComplete(caller_render_view_id,
211 caller_request_id)); 218 caller_request_id));
212 // Request sequence ended, so remove mapping. 219 // Request sequence ended, so remove mapping.
213 g_speech_input_callers.Get().RemoveId(caller_id); 220 g_speech_input_callers.Get().RemoveId(caller_id);
214 VLOG(1) << "SpeechInputDispatcherHost::DidCompleteRecognition exit"; 221 VLOG(1) << "SpeechInputDispatcherHost::DidCompleteRecognition exit";
215 } 222 }
216 223
217 } // namespace speech_input 224 } // namespace speech_input
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698