blob: 787cbdde47e6282a7a3db3fd68d042842a588be8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_
#define CHROME_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_
#include "base/basictypes.h"
#include "chrome/browser/speech/speech_recognizer.h"
#include "ipc/ipc_message.h"
namespace speech_input {
// This is the gatekeeper for speech recognition in the browser process. It
// handles requests received from various render views and makes sure only one
// of them can use speech recognition at a time. It also sends recognition
// results and status events to the render views when required.
// This class is a singleton and accessed via the Get method.
class SpeechInputManager {
public:
// Implemented by the dispatcher host to relay events to the render views.
class Delegate {
public:
virtual void SetRecognitionResult(int caller_id, const string16& value) = 0;
virtual void DidCompleteRecording(int caller_id) = 0;
virtual void DidCompleteRecognition(int caller_id) = 0;
protected:
virtual ~Delegate() {}
};
// Factory method to access the singleton. We have this method here instead of
// using Singleton<> directly in the calling code to aid tests in injection
// mocks.
static SpeechInputManager* Get();
// Factory method definition useful for tests.
typedef SpeechInputManager* (AccessorMethod)();
virtual ~SpeechInputManager() {}
// Handlers for requests from render views.
// |delegate| is a weak pointer and should remain valid until
// its |DidCompleteRecognition| method is called or recognition is cancelled.
virtual void StartRecognition(Delegate* delegate, int caller_id) = 0;
virtual void CancelRecognition(int caller_id) = 0;
virtual void StopRecording(int caller_id) = 0;
};
// This typedef is to workaround the issue with certain versions of
// Visual Studio where it gets confused between multiple Delegate
// classes and gives a C2500 error. (I saw this error on the try bots -
// the workaround was not needed for my machine).
typedef SpeechInputManager::Delegate SpeechInputManagerDelegate;
} // namespace speech_input
#endif // CHROME_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_
|