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

Side by Side Diff: content/browser/speech/speech_input_manager_impl.h

Issue 9568002: Renamed speech input implementation from to speech_recognition_*. The namespace has been renamed fr… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebased from master. Created 8 years, 9 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
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_
6 #define CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/singleton.h"
15 #include "content/public/browser/speech_input_manager.h"
16 #include "content/public/browser/speech_recognizer_delegate.h"
17 #include "ui/gfx/rect.h"
18
19 class AudioManager;
20
21 namespace content {
22 class ResourceContext;
23 class SpeechInputManagerDelegate;
24 class SpeechInputPreferences;
25 struct SpeechInputResult;
26 }
27
28 namespace net {
29 class URLRequestContextGetter;
30 }
31
32 namespace speech_input {
33
34 class SpeechInputDispatcherHost;
35 class SpeechRecognizerImpl;
36
37 class CONTENT_EXPORT SpeechInputManagerImpl
38 : NON_EXPORTED_BASE(public content::SpeechInputManager),
39 NON_EXPORTED_BASE(public content::SpeechRecognizerDelegate) {
40 public:
41 static SpeechInputManagerImpl* GetInstance();
42
43 // SpeechInputManager implementation:
44 virtual void StartRecognitionForRequest(int caller_id) OVERRIDE;
45 virtual void CancelRecognitionForRequest(int caller_id) OVERRIDE;
46 virtual void FocusLostForRequest(int caller_id) OVERRIDE;
47 virtual bool HasAudioInputDevices() OVERRIDE;
48 virtual bool IsRecordingInProcess() OVERRIDE;
49 virtual string16 GetAudioInputDeviceModel() OVERRIDE;
50 virtual void ShowAudioInputSettings() OVERRIDE;
51
52 // Handlers for requests from render views.
53
54 // |delegate| is a weak pointer and should remain valid until
55 // its |DidCompleteRecognition| method is called or recognition is cancelled.
56 // |render_process_id| is the ID of the renderer process initiating the
57 // request.
58 // |element_rect| is the display bounds of the html element requesting speech
59 // input (in page coordinates).
60 virtual void StartRecognition(
61 SpeechInputDispatcherHost* delegate,
62 int caller_id,
63 int render_process_id,
64 int render_view_id,
65 const gfx::Rect& element_rect,
66 const std::string& language,
67 const std::string& grammar,
68 const std::string& origin_url,
69 net::URLRequestContextGetter* context_getter,
70 content::SpeechInputPreferences* speech_input_prefs);
71 virtual void CancelRecognition(int caller_id);
72 virtual void CancelAllRequestsWithDelegate(
73 SpeechInputDispatcherHost* delegate);
74 virtual void StopRecording(int caller_id);
75
76 // Overridden from content::SpeechRecognizerDelegate:
77 virtual void DidStartReceivingAudio(int caller_id) OVERRIDE;
78 virtual void SetRecognitionResult(
79 int caller_id,
80 const content::SpeechInputResult& result) OVERRIDE;
81 virtual void DidCompleteRecording(int caller_id) OVERRIDE;
82 virtual void DidCompleteRecognition(int caller_id) OVERRIDE;
83 virtual void DidStartReceivingSpeech(int caller_id) OVERRIDE;
84 virtual void DidStopReceivingSpeech(int caller_id) OVERRIDE;
85
86 virtual void OnRecognizerError(int caller_id,
87 content::SpeechInputError error) OVERRIDE;
88 virtual void DidCompleteEnvironmentEstimation(int caller_id) OVERRIDE;
89 virtual void SetInputVolume(int caller_id, float volume,
90 float noise_volume) OVERRIDE;
91
92 protected:
93 // Private constructor to enforce singleton.
94 friend struct DefaultSingletonTraits<SpeechInputManagerImpl>;
95 SpeechInputManagerImpl();
96 virtual ~SpeechInputManagerImpl();
97
98 bool HasPendingRequest(int caller_id) const;
99
100 private:
101 struct SpeechInputRequest {
102 SpeechInputRequest();
103 ~SpeechInputRequest();
104
105 SpeechInputDispatcherHost* delegate;
106 scoped_refptr<SpeechRecognizerImpl> recognizer;
107 bool is_active; // Set to true when recording or recognition is going on.
108 };
109
110 struct SpeechInputParams;
111
112 SpeechInputDispatcherHost* GetDelegate(int caller_id) const;
113
114 void CheckRenderViewTypeAndStartRecognition(const SpeechInputParams& params);
115 void ProceedStartingRecognition(const SpeechInputParams& params);
116
117 void CancelRecognitionAndInformDelegate(int caller_id);
118
119 typedef std::map<int, SpeechInputRequest> SpeechRecognizerMap;
120 SpeechRecognizerMap requests_;
121 std::string request_info_;
122 bool can_report_metrics_;
123 int recording_caller_id_;
124 content::SpeechInputManagerDelegate* delegate_;
125 };
126
127 } // namespace speech_input
128
129 #endif // CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_
OLDNEW
« no previous file with comments | « content/browser/speech/speech_input_dispatcher_host.cc ('k') | content/browser/speech/speech_input_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698