1967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch/*
2967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * Copyright (C) 2010 Google Inc. All rights reserved.
3967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch *
4967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * Redistribution and use in source and binary forms, with or without
5967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * modification, are permitted provided that the following conditions are
6967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * met:
7967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch *
8967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch *     * Redistributions of source code must retain the above copyright
9967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * notice, this list of conditions and the following disclaimer.
10967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch *     * Redistributions in binary form must reproduce the above
11967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * copyright notice, this list of conditions and the following disclaimer
12967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * in the documentation and/or other materials provided with the
13967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * distribution.
14967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch *     * Neither the name of Google Inc. nor the names of its
15967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * contributors may be used to endorse or promote products derived from
16967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * this software without specific prior written permission.
17967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch *
18967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch */
30967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
310617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen#ifndef WebSpeechInputController_h
320617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen#define WebSpeechInputController_h
33967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
340617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen#include "WebCommon.h"
35967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
360617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsennamespace WebKit {
37967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
38e8b154fd68f9b33be40a3590e58347f353835f5cSteve Blockstruct WebRect;
39ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdochclass WebSecurityOrigin;
40e14391e94c850b8bd03680c23b38978db68687a8John Reckclass WebString;
41e8b154fd68f9b33be40a3590e58347f353835f5cSteve Block
420617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen// Provides an embedder API called by WebKit.
430617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsenclass WebSpeechInputController {
44967717af5423377c967781471ee106e2bb4e11c8Ben Murdochpublic:
450617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen    // Starts speech recognition. Speech will get recorded until the endpointer detects silence,
460617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen    // runs to the limit or stopRecording is called. Progress indications and the recognized
470617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen    // text are returned via the listener interface.
48ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch    virtual bool startRecognition(int requestId, const WebRect& elementRect, const WebString& language, const WebString& grammar, const WebSecurityOrigin& origin)
49ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch    {
50f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick        WEBKIT_ASSERT_NOT_REACHED();
51f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick        return false;
520617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen    }
530617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen
540617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen    // Cancels an ongoing recognition and discards any audio recorded so far. No partial
550617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen    // recognition results are returned to the listener.
56e8b154fd68f9b33be40a3590e58347f353835f5cSteve Block    virtual void cancelRecognition(int) { WEBKIT_ASSERT_NOT_REACHED(); }
570617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen
580617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen    // Stops audio recording and performs recognition with the audio recorded until now
590617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen    // (does not discard audio). This is an optional call and is typically invoked if the user
600617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen    // wants to stop recording audio as soon as they finished speaking. Otherwise, the speech
610617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen    // recording 'endpointer' should detect silence in the input and stop recording automatically.
620617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen    // Call startRecognition() to record audio and recognize speech again.
63e8b154fd68f9b33be40a3590e58347f353835f5cSteve Block    virtual void stopRecording(int) { WEBKIT_ASSERT_NOT_REACHED(); }
64967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
65967717af5423377c967781471ee106e2bb4e11c8Ben Murdochprotected:
660617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen    virtual ~WebSpeechInputController() { }
67967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch};
68967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
690617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen} // namespace WebKit
70967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
710617145a89917ae7735fe1c9538688ab9a577df5Kristian Monsen#endif // WebSpeechInputController_h
72