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

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: Separate overriden methods in profile_impl.h Created 9 years, 2 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) 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_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/browser/speech/speech_input_preferences.h"
9 #include "content/common/speech_input_messages.h" 10 #include "content/common/speech_input_messages.h"
10 11
11 namespace speech_input { 12 namespace speech_input {
12 13
13 //----------------------------- SpeechInputCallers ----------------------------- 14 //----------------------------- SpeechInputCallers -----------------------------
14 15
15 // A singleton class to map the tuple 16 // A singleton class to map the tuple
16 // (render-process-id, render-view-id, requestid) to a single ID which is passed 17 // (render-process-id, render-view-id, requestid) to a single ID which is passed
17 // through rest of the speech code. 18 // through rest of the speech code.
18 class SpeechInputDispatcherHost::SpeechInputCallers { 19 class SpeechInputDispatcherHost::SpeechInputCallers {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 98 }
98 99
99 int SpeechInputDispatcherHost::SpeechInputCallers::request_id(int id) { 100 int SpeechInputDispatcherHost::SpeechInputCallers::request_id(int id) {
100 return callers_[id].request_id; 101 return callers_[id].request_id;
101 } 102 }
102 103
103 //-------------------------- SpeechInputDispatcherHost ------------------------- 104 //-------------------------- SpeechInputDispatcherHost -------------------------
104 105
105 SpeechInputManager* SpeechInputDispatcherHost::manager_; 106 SpeechInputManager* SpeechInputDispatcherHost::manager_;
106 107
107 SpeechInputDispatcherHost::SpeechInputDispatcherHost(int render_process_id) 108 SpeechInputDispatcherHost::SpeechInputDispatcherHost(
109 int render_process_id,
110 net::URLRequestContextGetter* context_getter,
111 SpeechInputPreferences* speech_input_preferences)
108 : render_process_id_(render_process_id), 112 : render_process_id_(render_process_id),
109 may_have_pending_requests_(false) { 113 may_have_pending_requests_(false),
114 context_getter_(context_getter),
115 speech_input_preferences_(speech_input_preferences) {
110 // This is initialized by Browser. Do not add any non-trivial 116 // This is initialized by Browser. Do not add any non-trivial
111 // initialization here, instead do it lazily when required (e.g. see the 117 // initialization here, instead do it lazily when required (e.g. see the
112 // method |manager()|) or add an Init() method. 118 // method |manager()|) or add an Init() method.
113 } 119 }
114 120
115 SpeechInputDispatcherHost::~SpeechInputDispatcherHost() { 121 SpeechInputDispatcherHost::~SpeechInputDispatcherHost() {
116 // If the renderer crashed for some reason or if we didn't receive a proper 122 // 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. 123 // 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 124 // 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 125 // we don't end up creating the speech input manager for web pages which don't
(...skipping 28 matching lines...) Expand all
148 } 154 }
149 155
150 void SpeechInputDispatcherHost::OnStartRecognition( 156 void SpeechInputDispatcherHost::OnStartRecognition(
151 const SpeechInputHostMsg_StartRecognition_Params &params) { 157 const SpeechInputHostMsg_StartRecognition_Params &params) {
152 int caller_id = g_speech_input_callers.Get().CreateId( 158 int caller_id = g_speech_input_callers.Get().CreateId(
153 render_process_id_, params.render_view_id, params.request_id); 159 render_process_id_, params.render_view_id, params.request_id);
154 manager()->StartRecognition(this, caller_id, 160 manager()->StartRecognition(this, caller_id,
155 render_process_id_, 161 render_process_id_,
156 params.render_view_id, params.element_rect, 162 params.render_view_id, params.element_rect,
157 params.language, params.grammar, 163 params.language, params.grammar,
158 params.origin_url); 164 params.origin_url,
165 context_getter_.get(),
166 speech_input_preferences_.get());
159 } 167 }
160 168
161 void SpeechInputDispatcherHost::OnCancelRecognition(int render_view_id, 169 void SpeechInputDispatcherHost::OnCancelRecognition(int render_view_id,
162 int request_id) { 170 int request_id) {
163 int caller_id = g_speech_input_callers.Get().GetId( 171 int caller_id = g_speech_input_callers.Get().GetId(
164 render_process_id_, render_view_id, request_id); 172 render_process_id_, render_view_id, request_id);
165 if (caller_id) { 173 if (caller_id) {
166 manager()->CancelRecognition(caller_id); 174 manager()->CancelRecognition(caller_id);
167 // Request sequence ended so remove mapping. 175 // Request sequence ended so remove mapping.
168 g_speech_input_callers.Get().RemoveId(caller_id); 176 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); 216 g_speech_input_callers.Get().render_view_id(caller_id);
209 int caller_request_id = g_speech_input_callers.Get().request_id(caller_id); 217 int caller_request_id = g_speech_input_callers.Get().request_id(caller_id);
210 Send(new SpeechInputMsg_RecognitionComplete(caller_render_view_id, 218 Send(new SpeechInputMsg_RecognitionComplete(caller_render_view_id,
211 caller_request_id)); 219 caller_request_id));
212 // Request sequence ended, so remove mapping. 220 // Request sequence ended, so remove mapping.
213 g_speech_input_callers.Get().RemoveId(caller_id); 221 g_speech_input_callers.Get().RemoveId(caller_id);
214 VLOG(1) << "SpeechInputDispatcherHost::DidCompleteRecognition exit"; 222 VLOG(1) << "SpeechInputDispatcherHost::DidCompleteRecognition exit";
215 } 223 }
216 224
217 } // namespace speech_input 225 } // namespace speech_input
OLDNEW
« no previous file with comments | « content/browser/speech/speech_input_dispatcher_host.h ('k') | content/browser/speech/speech_input_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698