Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / content / common / speech_recognition_messages.h
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 // Multiply-included message file, hence no include guard.
6
7 #include <string>
8
9 #include "content/public/common/speech_recognition_error.h"
10 #include "content/public/common/speech_recognition_grammar.h"
11 #include "content/public/common/speech_recognition_result.h"
12 #include "ipc/ipc_message_macros.h"
13 #include "ipc/ipc_param_traits.h"
14 #include "ui/gfx/rect.h"
15
16 #define IPC_MESSAGE_START SpeechRecognitionMsgStart
17
18 IPC_ENUM_TRAITS_MAX_VALUE(content::SpeechAudioErrorDetails,
19                           content::SPEECH_AUDIO_ERROR_DETAILS_LAST)
20 IPC_ENUM_TRAITS_MAX_VALUE(content::SpeechRecognitionErrorCode,
21                           content::SPEECH_RECOGNITION_ERROR_LAST)
22
23 IPC_STRUCT_TRAITS_BEGIN(content::SpeechRecognitionError)
24   IPC_STRUCT_TRAITS_MEMBER(code)
25   IPC_STRUCT_TRAITS_MEMBER(details)
26 IPC_STRUCT_TRAITS_END()
27
28 IPC_STRUCT_TRAITS_BEGIN(content::SpeechRecognitionHypothesis)
29   IPC_STRUCT_TRAITS_MEMBER(utterance)
30   IPC_STRUCT_TRAITS_MEMBER(confidence)
31 IPC_STRUCT_TRAITS_END()
32
33 IPC_STRUCT_TRAITS_BEGIN(content::SpeechRecognitionResult)
34   IPC_STRUCT_TRAITS_MEMBER(is_provisional)
35   IPC_STRUCT_TRAITS_MEMBER(hypotheses)
36 IPC_STRUCT_TRAITS_END()
37
38 IPC_STRUCT_TRAITS_BEGIN(content::SpeechRecognitionGrammar)
39   IPC_STRUCT_TRAITS_MEMBER(url)
40   IPC_STRUCT_TRAITS_MEMBER(weight)
41 IPC_STRUCT_TRAITS_END()
42
43 // Used to start a speech recognition session.
44 IPC_STRUCT_BEGIN(InputTagSpeechHostMsg_StartRecognition_Params)
45   // The render view requesting speech recognition.
46   IPC_STRUCT_MEMBER(int, render_view_id)
47   // Request ID used within the render view.
48   IPC_STRUCT_MEMBER(int, request_id)
49   // Position of the UI element in page coordinates.
50   IPC_STRUCT_MEMBER(gfx::Rect, element_rect)
51   // Language to use for speech recognition.
52   IPC_STRUCT_MEMBER(std::string, language)
53   // Speech grammar given by the speech recognition element.
54   IPC_STRUCT_MEMBER(std::string, grammar)
55   // URL of the page (or iframe if applicable).
56   IPC_STRUCT_MEMBER(std::string, origin_url)
57 IPC_STRUCT_END()
58
59 // Renderer -> Browser messages.
60
61 // Requests the speech recognition service to start speech recognition on behalf
62 // of the given |render_view_id|.
63 IPC_MESSAGE_CONTROL1(InputTagSpeechHostMsg_StartRecognition,
64                      InputTagSpeechHostMsg_StartRecognition_Params)
65
66 // Requests the speech recognition service to cancel speech recognition on
67 // behalf of the given |render_view_id|. If speech recognition is not happening
68 // or is happening on behalf of some other render view, this call does nothing.
69 IPC_MESSAGE_CONTROL2(InputTagSpeechHostMsg_CancelRecognition,
70                      int /* render_view_id */,
71                      int /* request_id */)
72
73 // Requests the speech recognition service to stop audio recording on behalf of
74 // the given |render_view_id|. Any audio recorded so far will be fed to the
75 // speech recognizer. If speech recognition is not happening nor or is
76 // happening on behalf of some other render view, this call does nothing.
77 IPC_MESSAGE_CONTROL2(InputTagSpeechHostMsg_StopRecording,
78                      int /* render_view_id */,
79                      int /* request_id */)
80
81 // Browser -> Renderer messages.
82
83 // Relays a speech recognition result, either partial or final.
84 IPC_MESSAGE_ROUTED2(InputTagSpeechMsg_SetRecognitionResults,
85                     int /* request_id */,
86                     content::SpeechRecognitionResults /* results */)
87
88 // Indicates that speech recognizer has stopped recording and started
89 // recognition.
90 IPC_MESSAGE_ROUTED1(InputTagSpeechMsg_RecordingComplete,
91                     int /* request_id */)
92
93 // Indicates that speech recognizer has completed recognition. This will be the
94 // last message sent in response to a InputTagSpeechHostMsg_StartRecognition.
95 IPC_MESSAGE_ROUTED1(InputTagSpeechMsg_RecognitionComplete,
96                     int /* request_id */)
97
98 // Toggles speech recognition on or off on the speech input control for the
99 // current focused element. Has no effect if the current element doesn't
100 // support speech recognition.
101 IPC_MESSAGE_ROUTED0(InputTagSpeechMsg_ToggleSpeechInput)
102
103
104 // ------- Messages for Speech JS APIs (SpeechRecognitionDispatcher) ----------
105
106 // Renderer -> Browser messages.
107
108 // Used to start a speech recognition session.
109 IPC_STRUCT_BEGIN(SpeechRecognitionHostMsg_StartRequest_Params)
110   // The render view requesting speech recognition.
111   IPC_STRUCT_MEMBER(int, render_view_id)
112   // Unique ID associated with the JS object making the calls.
113   IPC_STRUCT_MEMBER(int, request_id)
114   // Language to use for speech recognition.
115   IPC_STRUCT_MEMBER(std::string, language)
116   // Speech grammars to use.
117   IPC_STRUCT_MEMBER(content::SpeechRecognitionGrammarArray, grammars)
118   // URL of the page (or iframe if applicable).
119   IPC_STRUCT_MEMBER(std::string, origin_url)
120   // Maximum number of hypotheses allowed for each results.
121   IPC_STRUCT_MEMBER(uint32, max_hypotheses)
122   // Whether the user requested continuous recognition or not.
123   IPC_STRUCT_MEMBER(bool, continuous)
124   // Whether the user requested interim results or not.
125   IPC_STRUCT_MEMBER(bool, interim_results)
126 IPC_STRUCT_END()
127
128
129 // Requests the speech recognition service to start speech recognition.
130 IPC_MESSAGE_CONTROL1(SpeechRecognitionHostMsg_StartRequest,
131                      SpeechRecognitionHostMsg_StartRequest_Params)
132
133 // Requests the speech recognition service to abort speech recognition on
134 // behalf of the given |render_view_id|. If speech recognition is not happening
135 // or is happening on behalf of some other render view, this call does nothing.
136 IPC_MESSAGE_CONTROL2(SpeechRecognitionHostMsg_AbortRequest,
137                      int /* render_view_id */,
138                      int /* request_id */)
139
140 // Requests the speech recognition service to stop audio capture on behalf of
141 // the given |render_view_id|. Any audio recorded so far will be fed to the
142 // speech recognizer. If speech recognition is not happening nor or is
143 // happening on behalf of some other render view, this call does nothing.
144 IPC_MESSAGE_CONTROL2(SpeechRecognitionHostMsg_StopCaptureRequest,
145                      int /* render_view_id */,
146                      int /* request_id */)
147
148 // Browser -> Renderer messages.
149
150 // The messages below follow exactly the same semantic of the corresponding
151 // events defined in content/public/browser/speech_recognition_event_listener.h.
152 IPC_MESSAGE_ROUTED2(SpeechRecognitionMsg_ResultRetrieved,
153                     int /* request_id */,
154                     content::SpeechRecognitionResults /* results */)
155
156 IPC_MESSAGE_ROUTED2(SpeechRecognitionMsg_ErrorOccurred,
157                     int /* request_id */,
158                     content::SpeechRecognitionError /* error */)
159
160 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_Started, int /* request_id */)
161
162 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_AudioStarted, int /* request_id */)
163
164 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_SoundStarted, int /* request_id */)
165
166 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_SoundEnded, int /* request_id */)
167
168 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_AudioEnded, int /* request_id */)
169
170 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_Ended, int /* request_id */)