15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Multiply-included message file, hence no include guard. 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string> 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/common/speech_recognition_error.h" 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/common/speech_recognition_grammar.h" 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/common/speech_recognition_result.h" 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ipc/ipc_message_macros.h" 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ipc/ipc_param_traits.h" 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/rect.h" 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define IPC_MESSAGE_START SpeechRecognitionMsgStart 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)IPC_ENUM_TRAITS_MAX_VALUE(content::SpeechAudioErrorDetails, 195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) content::SPEECH_AUDIO_ERROR_DETAILS_LAST) 205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)IPC_ENUM_TRAITS_MAX_VALUE(content::SpeechRecognitionErrorCode, 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) content::SPEECH_RECOGNITION_ERROR_LAST) 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_STRUCT_TRAITS_BEGIN(content::SpeechRecognitionError) 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) IPC_STRUCT_TRAITS_MEMBER(code) 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) IPC_STRUCT_TRAITS_MEMBER(details) 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_STRUCT_TRAITS_END() 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_STRUCT_TRAITS_BEGIN(content::SpeechRecognitionHypothesis) 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) IPC_STRUCT_TRAITS_MEMBER(utterance) 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) IPC_STRUCT_TRAITS_MEMBER(confidence) 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_STRUCT_TRAITS_END() 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_STRUCT_TRAITS_BEGIN(content::SpeechRecognitionResult) 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) IPC_STRUCT_TRAITS_MEMBER(is_provisional) 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) IPC_STRUCT_TRAITS_MEMBER(hypotheses) 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_STRUCT_TRAITS_END() 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_STRUCT_TRAITS_BEGIN(content::SpeechRecognitionGrammar) 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) IPC_STRUCT_TRAITS_MEMBER(url) 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) IPC_STRUCT_TRAITS_MEMBER(weight) 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_STRUCT_TRAITS_END() 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// ------- Messages for Speech JS APIs (SpeechRecognitionDispatcher) ---------- 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Renderer -> Browser messages. 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Used to start a speech recognition session. 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_STRUCT_BEGIN(SpeechRecognitionHostMsg_StartRequest_Params) 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The render view requesting speech recognition. 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) IPC_STRUCT_MEMBER(int, render_view_id) 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Unique ID associated with the JS object making the calls. 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) IPC_STRUCT_MEMBER(int, request_id) 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Language to use for speech recognition. 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) IPC_STRUCT_MEMBER(std::string, language) 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Speech grammars to use. 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) IPC_STRUCT_MEMBER(content::SpeechRecognitionGrammarArray, grammars) 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // URL of the page (or iframe if applicable). 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) IPC_STRUCT_MEMBER(std::string, origin_url) 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Maximum number of hypotheses allowed for each results. 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) IPC_STRUCT_MEMBER(uint32, max_hypotheses) 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Whether the user requested continuous recognition or not. 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) IPC_STRUCT_MEMBER(bool, continuous) 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Whether the user requested interim results or not. 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) IPC_STRUCT_MEMBER(bool, interim_results) 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_STRUCT_END() 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Requests the speech recognition service to start speech recognition. 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_CONTROL1(SpeechRecognitionHostMsg_StartRequest, 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SpeechRecognitionHostMsg_StartRequest_Params) 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Requests the speech recognition service to abort speech recognition on 735f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// behalf of the given |render_view_id| and |request_id|. If there are no 745f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// sessions associated with the |request_id| in the render view, this call 755f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// does nothing. 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_CONTROL2(SpeechRecognitionHostMsg_AbortRequest, 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int /* render_view_id */, 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int /* request_id */) 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 805f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// Requests the speech recognition service to abort all speech recognitions on 815f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// behalf of the given |render_view_id|. If speech recognition is not happening 825f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// or is happening on behalf of some other render view, this call does nothing. 835f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)IPC_MESSAGE_CONTROL1(SpeechRecognitionHostMsg_AbortAllRequests, 845f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) int /* render_view_id */) 855f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Requests the speech recognition service to stop audio capture on behalf of 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// the given |render_view_id|. Any audio recorded so far will be fed to the 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// speech recognizer. If speech recognition is not happening nor or is 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// happening on behalf of some other render view, this call does nothing. 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_CONTROL2(SpeechRecognitionHostMsg_StopCaptureRequest, 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int /* render_view_id */, 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int /* request_id */) 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Browser -> Renderer messages. 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The messages below follow exactly the same semantic of the corresponding 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// events defined in content/public/browser/speech_recognition_event_listener.h. 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_ROUTED2(SpeechRecognitionMsg_ResultRetrieved, 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int /* request_id */, 1002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) content::SpeechRecognitionResults /* results */) 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_ROUTED2(SpeechRecognitionMsg_ErrorOccurred, 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int /* request_id */, 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content::SpeechRecognitionError /* error */) 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_Started, int /* request_id */) 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_AudioStarted, int /* request_id */) 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_SoundStarted, int /* request_id */) 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_SoundEnded, int /* request_id */) 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_AudioEnded, int /* request_id */) 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_Ended, int /* request_id */) 117