OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 // Multiply-included message file, hence no include guard. | 5 // Multiply-included message file, hence no include guard. |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "content/public/common/speech_recognition_error.h" | 9 #include "content/public/common/speech_recognition_error.h" |
10 #include "content/public/common/speech_recognition_grammar.h" | |
10 #include "content/public/common/speech_recognition_result.h" | 11 #include "content/public/common/speech_recognition_result.h" |
11 #include "ipc/ipc_message_macros.h" | 12 #include "ipc/ipc_message_macros.h" |
12 #include "ipc/ipc_param_traits.h" | 13 #include "ipc/ipc_param_traits.h" |
13 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
14 | 15 |
15 #define IPC_MESSAGE_START SpeechRecognitionMsgStart | 16 #define IPC_MESSAGE_START SpeechRecognitionMsgStart |
16 | 17 |
18 IPC_ENUM_TRAITS(content::SpeechAudioErrorDetails) | |
17 IPC_ENUM_TRAITS(content::SpeechRecognitionErrorCode) | 19 IPC_ENUM_TRAITS(content::SpeechRecognitionErrorCode) |
18 | 20 |
21 IPC_STRUCT_TRAITS_BEGIN(content::SpeechRecognitionError) | |
22 IPC_STRUCT_TRAITS_MEMBER(code) | |
23 IPC_STRUCT_TRAITS_MEMBER(details) | |
24 IPC_STRUCT_TRAITS_END() | |
25 | |
19 IPC_STRUCT_TRAITS_BEGIN(content::SpeechRecognitionHypothesis) | 26 IPC_STRUCT_TRAITS_BEGIN(content::SpeechRecognitionHypothesis) |
20 IPC_STRUCT_TRAITS_MEMBER(utterance) | 27 IPC_STRUCT_TRAITS_MEMBER(utterance) |
21 IPC_STRUCT_TRAITS_MEMBER(confidence) | 28 IPC_STRUCT_TRAITS_MEMBER(confidence) |
22 IPC_STRUCT_TRAITS_END() | 29 IPC_STRUCT_TRAITS_END() |
23 | 30 |
24 IPC_STRUCT_TRAITS_BEGIN(content::SpeechRecognitionResult) | 31 IPC_STRUCT_TRAITS_BEGIN(content::SpeechRecognitionResult) |
32 IPC_STRUCT_TRAITS_MEMBER(provisional) | |
25 IPC_STRUCT_TRAITS_MEMBER(hypotheses) | 33 IPC_STRUCT_TRAITS_MEMBER(hypotheses) |
26 IPC_STRUCT_TRAITS_END() | 34 IPC_STRUCT_TRAITS_END() |
27 | 35 |
36 IPC_STRUCT_TRAITS_BEGIN(content::SpeechRecognitionGrammar) | |
37 IPC_STRUCT_TRAITS_MEMBER(url) | |
38 IPC_STRUCT_TRAITS_MEMBER(weight) | |
39 IPC_STRUCT_TRAITS_END() | |
40 | |
28 // Used to start a speech recognition session. | 41 // Used to start a speech recognition session. |
29 IPC_STRUCT_BEGIN(InputTagSpeechHostMsg_StartRecognition_Params) | 42 IPC_STRUCT_BEGIN(InputTagSpeechHostMsg_StartRecognition_Params) |
30 // The render view requesting speech recognition. | 43 // The render view requesting speech recognition. |
31 IPC_STRUCT_MEMBER(int, render_view_id) | 44 IPC_STRUCT_MEMBER(int, render_view_id) |
32 // Request ID used within the render view. | 45 // Request ID used within the render view. |
33 IPC_STRUCT_MEMBER(int, request_id) | 46 IPC_STRUCT_MEMBER(int, request_id) |
34 // Position of the UI element in page coordinates. | 47 // Position of the UI element in page coordinates. |
35 IPC_STRUCT_MEMBER(gfx::Rect, element_rect) | 48 IPC_STRUCT_MEMBER(gfx::Rect, element_rect) |
36 // Language to use for speech recognition. | 49 // Language to use for speech recognition. |
37 IPC_STRUCT_MEMBER(std::string, language) | 50 IPC_STRUCT_MEMBER(std::string, language) |
38 // Speech grammar given by the speech recognition element. | 51 // Speech grammar given by the speech recognition element. |
39 IPC_STRUCT_MEMBER(std::string, grammar) | 52 IPC_STRUCT_MEMBER(std::string, grammar) |
40 // URL of the page (or iframe if applicable). | 53 // URL of the page (or iframe if applicable). |
41 IPC_STRUCT_MEMBER(std::string, origin_url) | 54 IPC_STRUCT_MEMBER(std::string, origin_url) |
42 IPC_STRUCT_END() | 55 IPC_STRUCT_END() |
43 | 56 |
44 // Speech recognition messages sent from the renderer to the browser. | 57 // Renderer -> Browser messages. |
45 | 58 |
46 // Requests the speech recognition service to start speech recognition on behalf | 59 // Requests the speech recognition service to start speech recognition on behalf |
47 // of the given |render_view_id|. | 60 // of the given |render_view_id|. |
48 IPC_MESSAGE_CONTROL1(InputTagSpeechHostMsg_StartRecognition, | 61 IPC_MESSAGE_CONTROL1(InputTagSpeechHostMsg_StartRecognition, |
49 InputTagSpeechHostMsg_StartRecognition_Params) | 62 InputTagSpeechHostMsg_StartRecognition_Params) |
50 | 63 |
51 // Requests the speech recognition service to cancel speech recognition on | 64 // Requests the speech recognition service to cancel speech recognition on |
52 // behalf of the given |render_view_id|. If speech recognition is not happening | 65 // behalf of the given |render_view_id|. If speech recognition is not happening |
53 // or is happening on behalf of some other render view, this call does nothing. | 66 // or is happening on behalf of some other render view, this call does nothing. |
54 IPC_MESSAGE_CONTROL2(InputTagSpeechHostMsg_CancelRecognition, | 67 IPC_MESSAGE_CONTROL2(InputTagSpeechHostMsg_CancelRecognition, |
55 int /* render_view_id */, | 68 int /* render_view_id */, |
56 int /* request_id */) | 69 int /* request_id */) |
57 | 70 |
58 // Requests the speech recognition service to stop audio recording on behalf of | 71 // Requests the speech recognition service to stop audio recording on behalf of |
59 // the given |render_view_id|. Any audio recorded so far will be fed to the | 72 // the given |render_view_id|. Any audio recorded so far will be fed to the |
60 // speech recognizer. If speech recognition is not happening nor or is | 73 // speech recognizer. If speech recognition is not happening nor or is |
61 // happening on behalf of some other render view, this call does nothing. | 74 // happening on behalf of some other render view, this call does nothing. |
62 IPC_MESSAGE_CONTROL2(InputTagSpeechHostMsg_StopRecording, | 75 IPC_MESSAGE_CONTROL2(InputTagSpeechHostMsg_StopRecording, |
63 int /* render_view_id */, | 76 int /* render_view_id */, |
64 int /* request_id */) | 77 int /* request_id */) |
65 | 78 |
66 // Speech recognition messages sent from the browser to the renderer. | 79 // Browser -> Renderer messages. |
67 | 80 |
68 // Relay a speech recognition result, either partial or final. | 81 // Relay a speech recognition result, either partial or final. |
69 IPC_MESSAGE_ROUTED2(InputTagSpeechMsg_SetRecognitionResult, | 82 IPC_MESSAGE_ROUTED2(InputTagSpeechMsg_SetRecognitionResult, |
70 int /* request_id */, | 83 int /* request_id */, |
71 content::SpeechRecognitionResult /* result */) | 84 content::SpeechRecognitionResult /* result */) |
72 | 85 |
73 // Indicate that speech recognizer has stopped recording and started | 86 // Indicate that speech recognizer has stopped recording and started |
74 // recognition. | 87 // recognition. |
75 IPC_MESSAGE_ROUTED1(InputTagSpeechMsg_RecordingComplete, | 88 IPC_MESSAGE_ROUTED1(InputTagSpeechMsg_RecordingComplete, |
76 int /* request_id */) | 89 int /* request_id */) |
77 | 90 |
78 // Indicate that speech recognizer has completed recognition. This will be the | 91 // Indicate that speech recognizer has completed recognition. This will be the |
79 // last message sent in response to a InputTagSpeechHostMsg_StartRecognition. | 92 // last message sent in response to a InputTagSpeechHostMsg_StartRecognition. |
80 IPC_MESSAGE_ROUTED1(InputTagSpeechMsg_RecognitionComplete, | 93 IPC_MESSAGE_ROUTED1(InputTagSpeechMsg_RecognitionComplete, |
81 int /* request_id */) | 94 int /* request_id */) |
82 | 95 |
83 // Toggle speech recognition on or off on the speech input control for the | 96 // Toggle speech recognition on or off on the speech input control for the |
84 // current focused element. Has no effect if the current element doesn't | 97 // current focused element. Has no effect if the current element doesn't |
85 // support speech recognition. | 98 // support speech recognition. |
86 IPC_MESSAGE_ROUTED0(InputTagSpeechMsg_ToggleSpeechInput) | 99 IPC_MESSAGE_ROUTED0(InputTagSpeechMsg_ToggleSpeechInput) |
100 | |
101 | |
102 // ------- Messages for Speech JS APIs (SpeechRecognitionDispatcher) ---------- | |
103 | |
104 // Used to start a speech recognition session. | |
105 IPC_STRUCT_BEGIN(SpeechRecognitionHostMsg_StartRequest_Params) | |
106 // The render view requesting speech recognition. | |
107 IPC_STRUCT_MEMBER(int, render_view_id) | |
108 // Unique ID associated to the JS object making the calls. | |
109 IPC_STRUCT_MEMBER(int, js_handle_id) | |
110 // Language to use for speech recognition. | |
111 IPC_STRUCT_MEMBER(std::string, language) | |
112 // Speech grammar to use. | |
hans
2012/04/26 16:23:25
nit: s/grammar/grammars/
Primiano Tucci (use gerrit)
2012/04/27 09:27:13
Done.
| |
113 IPC_STRUCT_MEMBER(content::SpeechRecognitionGrammarArray, grammars) | |
114 // URL of the page (or iframe if applicable). | |
115 IPC_STRUCT_MEMBER(std::string, origin_url) | |
116 // Continuous recognition mode. | |
117 IPC_STRUCT_MEMBER(bool, continuous) | |
118 IPC_STRUCT_END() | |
119 | |
120 // Render -> Browser messages. | |
121 | |
122 // Requests the speech recognition service to start speech recognition on behalf | |
123 // of the given |render_view_id|. | |
124 IPC_MESSAGE_CONTROL1(SpeechRecognitionHostMsg_StartRequest, | |
125 SpeechRecognitionHostMsg_StartRequest_Params) | |
126 | |
127 // Requests the speech recognition service to abort speech recognition on | |
128 // behalf of the given |render_view_id|. If speech recognition is not happening | |
129 // or is happening on behalf of some other render view, this call does nothing. | |
130 IPC_MESSAGE_CONTROL2(SpeechRecognitionHostMsg_AbortRequest, | |
131 int /* render_view_id */, | |
132 int /* js_handle_id */) | |
133 | |
134 // Requests the speech recognition service to stop audio capture on behalf of | |
135 // the given |render_view_id|. Any audio recorded so far will be fed to the | |
136 // speech recognizer. If speech recognition is not happening nor or is | |
137 // happening on behalf of some other render view, this call does nothing. | |
138 IPC_MESSAGE_CONTROL2(SpeechRecognitionHostMsg_StopCaptureRequest, | |
139 int /* render_view_id */, | |
140 int /* js_handle_id */) | |
141 | |
142 // Browser -> Render messages. | |
143 | |
144 IPC_MESSAGE_ROUTED2(SpeechRecognitionMsg_ResultRetrieved, | |
hans
2012/04/26 16:23:25
we should probably have comments for this, and the
| |
145 int /* js_handle_id */, | |
146 content::SpeechRecognitionResult /* result */) | |
147 | |
148 IPC_MESSAGE_ROUTED2(SpeechRecognitionMsg_ErrorOccurred, | |
149 int /* js_handle_id */, | |
150 content::SpeechRecognitionError /* error */) | |
151 | |
152 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_Started, int /* js_handle_id */) | |
153 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_AudioStarted, int /* js_handle_id */) | |
154 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_SoundStarted, int /* js_handle_id */) | |
155 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_SoundEnded, int /* js_handle_id */) | |
156 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_AudioEnded, int /* js_handle_id */) | |
157 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_Ended, int /* js_handle_id */) | |
OLD | NEW |