Home | History | Annotate | Download | only in common
      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 // ------- Messages for Speech JS APIs (SpeechRecognitionDispatcher) ----------
     44 
     45 // Renderer -> Browser messages.
     46 
     47 // Used to start a speech recognition session.
     48 IPC_STRUCT_BEGIN(SpeechRecognitionHostMsg_StartRequest_Params)
     49   // The render view requesting speech recognition.
     50   IPC_STRUCT_MEMBER(int, render_view_id)
     51   // Unique ID associated with the JS object making the calls.
     52   IPC_STRUCT_MEMBER(int, request_id)
     53   // Language to use for speech recognition.
     54   IPC_STRUCT_MEMBER(std::string, language)
     55   // Speech grammars to use.
     56   IPC_STRUCT_MEMBER(content::SpeechRecognitionGrammarArray, grammars)
     57   // URL of the page (or iframe if applicable).
     58   IPC_STRUCT_MEMBER(std::string, origin_url)
     59   // Maximum number of hypotheses allowed for each results.
     60   IPC_STRUCT_MEMBER(uint32, max_hypotheses)
     61   // Whether the user requested continuous recognition or not.
     62   IPC_STRUCT_MEMBER(bool, continuous)
     63   // Whether the user requested interim results or not.
     64   IPC_STRUCT_MEMBER(bool, interim_results)
     65 IPC_STRUCT_END()
     66 
     67 
     68 // Requests the speech recognition service to start speech recognition.
     69 IPC_MESSAGE_CONTROL1(SpeechRecognitionHostMsg_StartRequest,
     70                      SpeechRecognitionHostMsg_StartRequest_Params)
     71 
     72 // Requests the speech recognition service to abort speech recognition on
     73 // behalf of the given |render_view_id| and |request_id|. If there are no
     74 // sessions associated with the |request_id| in the render view, this call
     75 // does nothing.
     76 IPC_MESSAGE_CONTROL2(SpeechRecognitionHostMsg_AbortRequest,
     77                      int /* render_view_id */,
     78                      int /* request_id */)
     79 
     80 // Requests the speech recognition service to abort all speech recognitions on
     81 // behalf of the given |render_view_id|. If speech recognition is not happening
     82 // or is happening on behalf of some other render view, this call does nothing.
     83 IPC_MESSAGE_CONTROL1(SpeechRecognitionHostMsg_AbortAllRequests,
     84                      int /* render_view_id */)
     85 
     86 // Requests the speech recognition service to stop audio capture on behalf of
     87 // the given |render_view_id|. Any audio recorded so far will be fed to the
     88 // speech recognizer. If speech recognition is not happening nor or is
     89 // happening on behalf of some other render view, this call does nothing.
     90 IPC_MESSAGE_CONTROL2(SpeechRecognitionHostMsg_StopCaptureRequest,
     91                      int /* render_view_id */,
     92                      int /* request_id */)
     93 
     94 // Browser -> Renderer messages.
     95 
     96 // The messages below follow exactly the same semantic of the corresponding
     97 // events defined in content/public/browser/speech_recognition_event_listener.h.
     98 IPC_MESSAGE_ROUTED2(SpeechRecognitionMsg_ResultRetrieved,
     99                     int /* request_id */,
    100                     content::SpeechRecognitionResults /* results */)
    101 
    102 IPC_MESSAGE_ROUTED2(SpeechRecognitionMsg_ErrorOccurred,
    103                     int /* request_id */,
    104                     content::SpeechRecognitionError /* error */)
    105 
    106 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_Started, int /* request_id */)
    107 
    108 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_AudioStarted, int /* request_id */)
    109 
    110 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_SoundStarted, int /* request_id */)
    111 
    112 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_SoundEnded, int /* request_id */)
    113 
    114 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_AudioEnded, int /* request_id */)
    115 
    116 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_Ended, int /* request_id */)
    117