blob: 1286634ec5c733a57c5df2a8c1ce36b73875fe5d (
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
59
60
61
62
63
64
65
66
67
68
69
|
// Copyright (c) 2011 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 CONTENT_BROWSER_SPEECH_SPEECH_INPUT_DISPATCHER_HOST_H_
#define CONTENT_BROWSER_SPEECH_SPEECH_INPUT_DISPATCHER_HOST_H_
#include "base/memory/scoped_ptr.h"
#include "content/browser/browser_message_filter.h"
#include "content/browser/speech/speech_input_manager.h"
#include "content/common/content_export.h"
#include "net/url_request/url_request_context_getter.h"
struct SpeechInputHostMsg_StartRecognition_Params;
namespace speech_input {
// SpeechInputDispatcherHost is a delegate for Speech API messages used by
// RenderMessageFilter.
// It's the complement of SpeechInputDispatcher (owned by RenderView).
class SpeechInputDispatcherHost : public BrowserMessageFilter,
public SpeechInputManager::Delegate {
public:
class SpeechInputCallers;
SpeechInputDispatcherHost(
int render_process_id,
net::URLRequestContextGetter* context_getter,
SpeechInputPreferences* speech_input_preferences);
// SpeechInputManager::Delegate methods.
virtual void SetRecognitionResult(int caller_id,
const SpeechInputResult& result);
virtual void DidCompleteRecording(int caller_id);
virtual void DidCompleteRecognition(int caller_id);
// BrowserMessageFilter implementation.
virtual bool OnMessageReceived(const IPC::Message& message,
bool* message_was_ok);
// Singleton manager setter useful for tests.
CONTENT_EXPORT static void set_manager(SpeechInputManager* manager);
private:
virtual ~SpeechInputDispatcherHost();
void OnStartRecognition(
const SpeechInputHostMsg_StartRecognition_Params ¶ms);
void OnCancelRecognition(int render_view_id, int request_id);
void OnStopRecording(int render_view_id, int request_id);
// Returns the speech input manager to forward events to, creating one if
// needed.
SpeechInputManager* manager();
int render_process_id_;
bool may_have_pending_requests_; // Set if we received any speech IPC request
scoped_refptr<net::URLRequestContextGetter> context_getter_;
scoped_refptr<SpeechInputPreferences> speech_input_preferences_;
static SpeechInputManager* manager_;
DISALLOW_COPY_AND_ASSIGN(SpeechInputDispatcherHost);
};
} // namespace speech_input
#endif // CONTENT_BROWSER_SPEECH_SPEECH_INPUT_DISPATCHER_HOST_H_
|