OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_SPEECH_SPEECH_INPUT_EXTENSION_API_H_ | |
6 #define CHROME_BROWSER_SPEECH_SPEECH_INPUT_EXTENSION_API_H_ | |
7 #pragma once | |
8 | |
9 #include "chrome/browser/extensions/extension_function.h" | |
10 #include "content/public/browser/notification_observer.h" | |
11 | |
12 class SpeechInputExtensionManager; | |
13 | |
14 // Handles asynchronous operations such as starting or stopping speech | |
15 // recognition in the framework of the extension API state machine. | |
16 class SpeechInputAsyncFunction : public AsyncExtensionFunction, | |
17 public content::NotificationObserver { | |
18 protected: | |
19 SpeechInputAsyncFunction(int start_state, int transition_state, | |
20 int end_state, int transition_notification); | |
21 virtual ~SpeechInputAsyncFunction(); | |
22 | |
23 virtual void Run() OVERRIDE; | |
24 virtual bool RunImpl() = 0; | |
25 | |
26 private: | |
27 // content::NotificationObserver. | |
28 virtual void Observe(int type, | |
29 const content::NotificationSource& source, | |
30 const content::NotificationDetails& details) OVERRIDE; | |
31 | |
32 // To be defined on construction by derived classes. | |
33 int start_state_; | |
34 int transition_state_; | |
35 int end_state_; | |
36 int transition_notification_; | |
37 | |
38 content::NotificationRegistrar registrar_; | |
39 bool expecting_transition_; | |
40 bool failed_; | |
41 }; | |
42 | |
43 // Implements experimental.speechInput.start. | |
44 class StartSpeechInputFunction : public SpeechInputAsyncFunction { | |
45 public: | |
46 StartSpeechInputFunction(); | |
47 virtual ~StartSpeechInputFunction() {} | |
48 | |
49 protected: | |
50 virtual bool RunImpl() OVERRIDE; | |
51 DECLARE_EXTENSION_FUNCTION_NAME("experimental.speechInput.start"); | |
52 }; | |
53 | |
54 // Implements experimental.speechInput.stop. | |
55 class StopSpeechInputFunction : public SpeechInputAsyncFunction { | |
56 public: | |
57 StopSpeechInputFunction(); | |
58 virtual ~StopSpeechInputFunction() {} | |
59 | |
60 protected: | |
61 virtual bool RunImpl() OVERRIDE; | |
62 DECLARE_EXTENSION_FUNCTION_NAME("experimental.speechInput.stop"); | |
63 }; | |
64 | |
65 // Implements experimental.speechInput.isRecording. | |
66 class IsRecordingSpeechInputFunction : public SyncExtensionFunction { | |
67 protected: | |
68 virtual bool RunImpl() OVERRIDE; | |
69 DECLARE_EXTENSION_FUNCTION_NAME("experimental.speechInput.isRecording"); | |
70 }; | |
71 | |
72 #endif // CHROME_BROWSER_SPEECH_SPEECH_INPUT_EXTENSION_API_H_ | |
OLD | NEW |