Changeset 64042 in webkit


Ignore:
Timestamp:
Jul 26, 2010 4:52:50 AM (14 years ago)
Author:
commit-queue@webkit.org
Message:

2010-07-26 Satish Sampath <satish@chromium.org>

Reviewed by Steve Block.

Add WebKit plumbing to connect speech requests and callbacks between WebCore and the embedder.
https://bugs.webkit.org/show_bug.cgi?id=42367

No new tests, the relevant LayoutTestController bindings will be added in the next patch.

  • page/SpeechInput.cpp: renamed a method.
  • page/SpeechInput.h: renamed a method.
  • page/SpeechInputClient.h: added an extra method to optionally let users stop recording once they have spoken.
  • page/SpeechInputClientListener.h: renamed a method.
  • page/SpeechInputListener.h: renamed a method.

2010-07-26 Satish Sampath <satish@chromium.org>

Reviewed by Steve Block.

Add WebKit plumbing to connect speech requests and callbacks between WebCore and the embedder.
https://bugs.webkit.org/show_bug.cgi?id=42367

No new tests, the relevant LayoutTestController bindings and tests will be added in the next patch.

  • public/WebSpeechInputController.h: Added new interface, implemented by embedder and called by WebKit (WebKit::WebSpeechInputController::~WebSpeechInputController):
  • public/WebSpeechInputListener.h: Added new interface, implemented by WebKit and called by embedder. (WebKit::WebSpeechInputListener::~WebSpeechInputListener):
  • public/WebViewClient.h: (WebKit::WebViewClient::createSpeechInputClient): New method to get the embedder's speech input client interface.
  • src/SpeechInputClientImpl.cpp: Added new class, implementation of a two way connector between WebCore and the embedder for requests and responses. (WebKit::SpeechInputClientImpl::SpeechInputClientImpl): (WebKit::SpeechInputClientImpl::~SpeechInputClientImpl): (WebKit::SpeechInputClientImpl::startRecognition): (WebKit::SpeechInputClientImpl::stopRecording): (WebKit::SpeechInputClientImpl::didCompleteRecording): (WebKit::SpeechInputClientImpl::setRecognitionResult): (WebKit::SpeechInputClientImpl::didCompleteRecognition):
  • src/SpeechInputClientImpl.h: Added.
  • src/WebViewImpl.cpp: (WebKit::WebViewImpl::WebViewImpl): Pass on the above mentioned speech input connector to WebCore.
  • src/WebViewImpl.h:
Location:
trunk
Files:
1 added
13 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r64041 r64042  
     12010-07-26  Satish Sampath  <satish@chromium.org>
     2
     3        Reviewed by Steve Block.
     4
     5        Add WebKit plumbing to connect speech requests and callbacks between WebCore and the embedder.
     6        https://bugs.webkit.org/show_bug.cgi?id=42367
     7
     8        No new tests, the relevant LayoutTestController bindings will be added in the next patch.
     9
     10        * page/SpeechInput.cpp: renamed a method.
     11        * page/SpeechInput.h: renamed a method.
     12        * page/SpeechInputClient.h: added an extra method to optionally let users stop recording once they have spoken.
     13        * page/SpeechInputClientListener.h: renamed a method.
     14        * page/SpeechInputListener.h: renamed a method.
     15
    1162010-07-26  Andreas Kling  <andreas.kling@nokia.com>
    217
  • trunk/WebCore/page/SpeechInput.cpp

    r63230 r64042  
    4646}
    4747
    48 void SpeechInput::recordingComplete()
     48void SpeechInput::didCompleteRecording()
    4949{
    50     m_listener->recordingComplete();
     50    m_listener->didCompleteRecording();
    5151}
    5252
  • trunk/WebCore/page/SpeechInput.h

    r63230 r64042  
    5555
    5656    // SpeechInputClient::Listener methods.
    57     virtual void recordingComplete();
     57    virtual void didCompleteRecording();
    5858    virtual void setRecognitionResult(const String&);
    5959
  • trunk/WebCore/page/SpeechInputClient.h

    r63230 r64042  
    4343    virtual bool startRecognition(SpeechInputClientListener* listener) = 0;
    4444
     45    // Stops audio recording and performs recognition with the audio recorded until now
     46    // (does not discard audio).
     47    virtual void stopRecording() = 0;
     48
    4549protected:
    4650    virtual ~SpeechInputClient() { }
  • trunk/WebCore/page/SpeechInputClientListener.h

    r63230 r64042  
    4141class SpeechInputClientListener {
    4242public:
    43     virtual void recordingComplete() = 0;
     43    // Informs that audio recording has completed and recognition is underway.
     44    virtual void didCompleteRecording() = 0;
     45
     46    // Gives results from speech recognition, either partial or the final results.
     47    // This method can potentially get called multiple times if there are partial results
     48    // available as the user keeps speaking. If the speech could not be recognized properly
     49    // or if there was any other errors in the process, this method may never be called.
    4450    virtual void setRecognitionResult(const String& result) = 0;
    4551
  • trunk/WebCore/page/SpeechInputListener.h

    r63230 r64042  
    4141class SpeechInputListener {
    4242public:
    43     virtual void recordingComplete() = 0;
     43    // Informs that audio recording has completed and recognition is underway.
     44    virtual void didCompleteRecording() = 0;
     45
     46    // Gives results from speech recognition, either partial or the final results.
     47    // This method can potentially get called multiple times if there are partial results
     48    // available as the user keeps speaking. If the speech could not be recognized properly
     49    // or if there was any other errors in the process, this method may never be called.
    4450    virtual void setRecognitionResult(const String& result) = 0;
    4551
  • trunk/WebCore/rendering/TextControlInnerElements.cpp

    r63929 r64042  
    398398}
    399399
    400 void InputFieldSpeechButtonElement::recordingComplete()
     400void InputFieldSpeechButtonElement::didCompleteRecording()
    401401{
    402402    // FIXME: Add UI feedback here to indicate that audio recording stopped and recognition is
  • trunk/WebCore/rendering/TextControlInnerElements.h

    r63582 r64042  
    125125
    126126    // SpeechInputListener methods.
    127     void recordingComplete();
     127    void didCompleteRecording();
    128128    void setRecognitionResult(const String& result);
    129129
  • trunk/WebKit/chromium/ChangeLog

    r64035 r64042  
     12010-07-26  Satish Sampath  <satish@chromium.org>
     2
     3        Reviewed by Steve Block.
     4
     5        Add WebKit plumbing to connect speech requests and callbacks between WebCore and the embedder.
     6        https://bugs.webkit.org/show_bug.cgi?id=42367
     7
     8        No new tests, the relevant LayoutTestController bindings and tests will be added in the next patch.
     9
     10        * public/WebSpeechInputController.h: Added new interface, implemented by embedder and called by WebKit
     11        (WebKit::WebSpeechInputController::~WebSpeechInputController):
     12        * public/WebSpeechInputListener.h: Added new interface, implemented by WebKit and called by embedder.
     13        (WebKit::WebSpeechInputListener::~WebSpeechInputListener):
     14        * public/WebViewClient.h:
     15        (WebKit::WebViewClient::createSpeechInputClient): New method to get the embedder's speech input client interface.
     16        * src/SpeechInputClientImpl.cpp: Added new class, implementation of a two way connector between WebCore
     17        and the embedder for requests and responses.
     18        (WebKit::SpeechInputClientImpl::SpeechInputClientImpl):
     19        (WebKit::SpeechInputClientImpl::~SpeechInputClientImpl):
     20        (WebKit::SpeechInputClientImpl::startRecognition):
     21        (WebKit::SpeechInputClientImpl::stopRecording):
     22        (WebKit::SpeechInputClientImpl::didCompleteRecording):
     23        (WebKit::SpeechInputClientImpl::setRecognitionResult):
     24        (WebKit::SpeechInputClientImpl::didCompleteRecognition):
     25        * src/SpeechInputClientImpl.h: Added.
     26        * src/WebViewImpl.cpp:
     27        (WebKit::WebViewImpl::WebViewImpl): Pass on the above mentioned speech input connector to WebCore.
     28        * src/WebViewImpl.h:
     29
    1302010-07-26  Ilya Tikhonovsky  <loislo@chromium.org>
    231
  • trunk/WebKit/chromium/WebKit.gyp

    r63874 r64042  
    235235                'public/WebSocketStreamHandle.h',
    236236                'public/WebSocketStreamHandleClient.h',
     237                'public/WebSpeechInputController.h',
     238                'public/WebSpeechInputListener.h',
    237239                'public/WebStorageArea.h',
    238240                'public/WebStorageEventDispatcher.h',
     
    340342                'src/SharedWorkerRepository.cpp',
    341343                'src/SocketStreamHandle.cpp',
     344                'src/SpeechInputClientImpl.cpp',
     345                'src/SpeechInputClientImpl.h',
    342346                'src/StorageAreaProxy.cpp',
    343347                'src/StorageAreaProxy.h',
  • trunk/WebKit/chromium/public/WebSpeechInputController.h

    r64041 r64042  
    2929 */
    3030
    31 #ifndef SpeechInputClientListener_h
    32 #define SpeechInputClientListener_h
     31#ifndef WebSpeechInputController_h
     32#define WebSpeechInputController_h
    3333
    34 #if ENABLE(INPUT_SPEECH)
     34#include "WebCommon.h"
    3535
    36 namespace WebCore {
     36namespace WebKit {
    3737
    38 class String;
     38// Provides an embedder API called by WebKit.
     39class WebSpeechInputController {
     40public:
     41    // Starts speech recognition. Speech will get recorded until the endpointer detects silence,
     42    // runs to the limit or stopRecording is called. Progress indications and the recognized
     43    // text are returned via the listener interface.
     44    virtual bool startRecognition()
     45    {
     46         WEBKIT_ASSERT_NOT_REACHED();
     47         return false;
     48    }
    3949
    40 // Provides an interface for the embedder to call into WebCore.
    41 class SpeechInputClientListener {
    42 public:
    43     virtual void recordingComplete() = 0;
    44     virtual void setRecognitionResult(const String& result) = 0;
     50    // Cancels an ongoing recognition and discards any audio recorded so far. No partial
     51    // recognition results are returned to the listener.
     52    virtual void cancelRecognition() { WEBKIT_ASSERT_NOT_REACHED(); }
     53
     54    // Stops audio recording and performs recognition with the audio recorded until now
     55    // (does not discard audio). This is an optional call and is typically invoked if the user
     56    // wants to stop recording audio as soon as they finished speaking. Otherwise, the speech
     57    // recording 'endpointer' should detect silence in the input and stop recording automatically.
     58    // Call startRecognition() to record audio and recognize speech again.
     59    virtual void stopRecording() { WEBKIT_ASSERT_NOT_REACHED(); }
    4560
    4661protected:
    47     virtual ~SpeechInputClientListener() { }
     62    virtual ~WebSpeechInputController() { }
    4863};
    4964
    50 } // namespace WebCore
     65} // namespace WebKit
    5166
    52 #endif // ENABLE(INPUT_SPEECH)
    53 
    54 #endif // SpeechInputClientListener_h
     67#endif // WebSpeechInputController_h
  • trunk/WebKit/chromium/public/WebViewClient.h

    r63379 r64042  
    5656class WebNotificationPresenter;
    5757class WebRange;
     58class WebSpeechInputController;
     59class WebSpeechInputListener;
    5860class WebStorageNamespace;
    5961class WebURL;
     
    332334
    333335    // Access the embedder API for geolocation services.
    334     virtual WebKit::WebGeolocationService* geolocationService() { return 0; }
     336    virtual WebGeolocationService* geolocationService() { return 0; }
     337
     338    // Speech --------------------------------------------------------------
     339
     340    // Access the embedder API for speech input services.
     341    virtual WebSpeechInputController* speechInputController(
     342        WebSpeechInputListener*) { return 0; }
    335343
    336344protected:
  • trunk/WebKit/chromium/src/SpeechInputClientImpl.cpp

    r64041 r64042  
    3030
    3131#include "config.h"
    32 #include "SpeechInput.h"
     32#include "SpeechInputClientImpl.h"
     33
     34#include "PlatformString.h"
     35#include "WebSpeechInputController.h"
     36#include "WebString.h"
     37#include "WebViewClient.h"
     38#include "page/SpeechInputClientListener.h"
    3339
    3440#if ENABLE(INPUT_SPEECH)
    3541
    36 #include "Frame.h"
    37 #include "SpeechInputClient.h"
    38 #include "SpeechInputListener.h"
     42namespace WebKit {
    3943
    40 namespace WebCore {
     44SpeechInputClientImpl::SpeechInputClientImpl(WebViewClient* web_view_client)
     45    : m_controller(web_view_client->speechInputController(this))
     46    , m_listener(0)
     47{
     48    ASSERT(m_controller);
     49}
    4150
    42 SpeechInput::SpeechInput(SpeechInputClient* client, SpeechInputListener* listener)
    43     : m_client(client)
    44     , m_listener(listener)
     51SpeechInputClientImpl::~SpeechInputClientImpl()
    4552{
    4653}
    4754
    48 void SpeechInput::recordingComplete()
     55bool SpeechInputClientImpl::startRecognition(WebCore::SpeechInputClientListener* listener)
    4956{
    50     m_listener->recordingComplete();
     57    // Cancel any ongoing recognition first. No callbacks will be issued to that listener.
     58    if (m_listener)
     59        m_controller->cancelRecognition();
     60
     61    m_listener = listener;
     62    return m_controller->startRecognition();
    5163}
    5264
    53 void SpeechInput::setRecognitionResult(const String& result)
     65void SpeechInputClientImpl::stopRecording()
    5466{
    55     m_listener->setRecognitionResult(result);
     67    ASSERT(m_listener);
     68    m_controller->stopRecording();
    5669}
    5770
    58 bool SpeechInput::startRecognition()
     71void SpeechInputClientImpl::didCompleteRecording()
    5972{
    60     if (m_client)
    61         return m_client->startRecognition(this);
    62     return false;
     73    ASSERT(m_listener);
     74    if (m_listener)
     75        m_listener->didCompleteRecording();
    6376}
    6477
    65 } // namespace WebCore
     78void SpeechInputClientImpl::didCompleteRecognition()
     79{
     80    ASSERT(m_listener);
     81    m_listener = 0;
     82}
     83
     84void SpeechInputClientImpl::setRecognitionResult(const WebString& result)
     85{
     86    ASSERT(m_listener);
     87    if (m_listener)
     88        m_listener->setRecognitionResult(result);
     89}
     90
     91} // namespace WebKit
    6692
    6793#endif // ENABLE(INPUT_SPEECH)
  • trunk/WebKit/chromium/src/SpeechInputClientImpl.h

    r64041 r64042  
    2929 */
    3030
    31 #ifndef SpeechInputClient_h
    32 #define SpeechInputClient_h
     31#ifndef SpeechInputClientImpl_h
     32#define SpeechInputClientImpl_h
    3333
    3434#if ENABLE(INPUT_SPEECH)
    3535
     36#include "WebSpeechInputListener.h"
     37#include "page/SpeechInputClient.h"
     38
    3639namespace WebCore {
     40class SpeechInputClientListener;
     41}
    3742
    38 class SpeechInputClientListener;
     43namespace WebKit {
    3944
    40 // Provides an interface for SpeechInput to call into the embedder.
    41 class SpeechInputClient {
     45class WebSpeechInputController;
     46class WebViewClient;
     47
     48class SpeechInputClientImpl
     49    : public WebCore::SpeechInputClient,
     50      public WebSpeechInputListener {
    4251public:
    43     virtual bool startRecognition(SpeechInputClientListener* listener) = 0;
     52    SpeechInputClientImpl(WebViewClient*);
     53    virtual ~SpeechInputClientImpl();
    4454
    45 protected:
    46     virtual ~SpeechInputClient() { }
     55    // SpeechInputClient methods.
     56    bool startRecognition(WebCore::SpeechInputClientListener*);
     57    void stopRecording();
     58
     59    // WebSpeechInputListener methods.
     60    void didCompleteRecording();
     61    void setRecognitionResult(const WebString&);
     62    void didCompleteRecognition();
     63
     64private:
     65    WebSpeechInputController* m_controller; // To call into the embedder.
     66    WebCore::SpeechInputClientListener* m_listener; // Valid when recognition is in progress.
    4767};
    4868
    49 } // namespace WebCore
     69} // namespace WebKit
    5070
    5171#endif // ENABLE(INPUT_SPEECH)
    5272
    53 #endif // SpeechInputClient_h
     73#endif // SpeechInputClientImpl_h
  • trunk/WebKit/chromium/src/WebViewImpl.cpp

    r63905 r64042  
    259259    , m_isAcceleratedCompositingActive(false)
    260260#endif
     261#if ENABLE(INPUT_SPEECH)
     262    , m_speechInputClient(client)
     263#endif
    261264    , m_gles2Context(0)
    262265{
     
    279282    m_page->backForwardList()->setClient(&m_backForwardListClientImpl);
    280283    m_page->setGroupName(pageGroupName);
     284#if ENABLE(INPUT_SPEECH)
     285    m_page->setSpeechInputClient(&m_speechInputClient);
     286#endif
    281287
    282288    m_inspectorSettingsMap.set(new SettingsMap);
  • trunk/WebKit/chromium/src/WebViewImpl.h

    r63905 r64042  
    4848#include "LayerRendererChromium.h"
    4949#include "NotificationPresenterImpl.h"
     50#include "SpeechInputClientImpl.h"
    5051#include <wtf/OwnPtr.h>
    5152#include <wtf/RefCounted.h>
     
    512513    static const WebInputEvent* m_currentInputEvent;
    513514
     515#if ENABLE(INPUT_SPEECH)
     516    SpeechInputClientImpl m_speechInputClient;
     517#endif
     518
    514519    OwnPtr<WebGLES2Context> m_gles2Context;
    515520};
Note: See TracChangeset for help on using the changeset viewer.