| 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 // Relays 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 // Indicates 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 // Indicates 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 // Toggles 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 with 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 grammars to use. |
| 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 // One-shot/continuous recognition mode. |
| 117 IPC_STRUCT_MEMBER(bool, is_one_shot) |
| 118 IPC_STRUCT_END() |
| 119 |
| 120 // Renderer -> Browser messages. |
| 121 |
| 122 // Requests the speech recognition service to start speech recognition. |
| 123 IPC_MESSAGE_CONTROL1(SpeechRecognitionHostMsg_StartRequest, |
| 124 SpeechRecognitionHostMsg_StartRequest_Params) |
| 125 |
| 126 // Requests the speech recognition service to abort speech recognition on |
| 127 // behalf of the given |render_view_id|. If speech recognition is not happening |
| 128 // or is happening on behalf of some other render view, this call does nothing. |
| 129 IPC_MESSAGE_CONTROL2(SpeechRecognitionHostMsg_AbortRequest, |
| 130 int /* render_view_id */, |
| 131 int /* js_handle_id */) |
| 132 |
| 133 // Requests the speech recognition service to stop audio capture on behalf of |
| 134 // the given |render_view_id|. Any audio recorded so far will be fed to the |
| 135 // speech recognizer. If speech recognition is not happening nor or is |
| 136 // happening on behalf of some other render view, this call does nothing. |
| 137 IPC_MESSAGE_CONTROL2(SpeechRecognitionHostMsg_StopCaptureRequest, |
| 138 int /* render_view_id */, |
| 139 int /* js_handle_id */) |
| 140 |
| 141 // Browser -> Renderer messages. |
| 142 |
| 143 // The messages below follow exactly the same semantic of the corresponding |
| 144 // events defined in content/public/browser/speech_recognition_event_listener.h. |
| 145 IPC_MESSAGE_ROUTED2(SpeechRecognitionMsg_ResultRetrieved, |
| 146 int /* js_handle_id */, |
| 147 content::SpeechRecognitionResult /* result */) |
| 148 IPC_MESSAGE_ROUTED2(SpeechRecognitionMsg_ErrorOccurred, |
| 149 int /* js_handle_id */, |
| 150 content::SpeechRecognitionError /* error */) |
| 151 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_Started, int /* js_handle_id */) |
| 152 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_AudioStarted, int /* js_handle_id */) |
| 153 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_SoundStarted, int /* js_handle_id */) |
| 154 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_SoundEnded, int /* js_handle_id */) |
| 155 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_AudioEnded, int /* js_handle_id */) |
| 156 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_Ended, int /* js_handle_id */) |
| OLD | NEW |