| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SPEECH_INPUT_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_SPEECH_INPUT_EXTENSION_SPEECH_INPUT_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SPEECH_INPUT_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_SPEECH_INPUT_EXTENSION_SPEECH_INPUT_API_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "chrome/browser/extensions/extension_function.h" | 9 #include "chrome/browser/extensions/extension_function.h" |
| 10 #include "content/common/notification_service.h" | 10 #include "content/common/notification_service.h" |
| 11 | 11 |
| 12 class ExtensionSpeechInputManager; | 12 class ExtensionSpeechInputManager; |
| 13 | 13 |
| 14 // Handles asynchronous operations such as starting or stopping speech | 14 // Handles asynchronous operations such as starting or stopping speech |
| 15 // recognition in the framework of the extension API state machine. | 15 // recognition in the framework of the extension API state machine. |
| 16 class SpeechInputAsyncFunction : public AsyncExtensionFunction, | 16 class SpeechInputAsyncFunction : public AsyncExtensionFunction, |
| 17 public NotificationObserver { | 17 public NotificationObserver { |
| 18 protected: | 18 protected: |
| 19 SpeechInputAsyncFunction(); | 19 SpeechInputAsyncFunction(int start_state, int transition_state, |
| 20 int end_state, int transition_notification); |
| 21 virtual ~SpeechInputAsyncFunction(); |
| 20 | 22 |
| 21 virtual void Run() OVERRIDE; | 23 virtual void Run() OVERRIDE; |
| 22 virtual bool RunImpl() = 0; | 24 virtual bool RunImpl() = 0; |
| 23 | 25 |
| 24 private: | 26 private: |
| 25 // NotificationObserver. | 27 // NotificationObserver. |
| 26 virtual void Observe(int type, | 28 virtual void Observe(int type, |
| 27 const NotificationSource& source, | 29 const NotificationSource& source, |
| 28 const NotificationDetails& details) OVERRIDE; | 30 const NotificationDetails& details) OVERRIDE; |
| 29 | 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 |
| 30 NotificationRegistrar registrar_; | 38 NotificationRegistrar registrar_; |
| 39 bool expecting_transition_; |
| 40 bool failed_; |
| 31 }; | 41 }; |
| 32 | 42 |
| 33 // Implements experimental.speechInput.start. | 43 // Implements experimental.speechInput.start. |
| 34 class StartSpeechInputFunction : public SpeechInputAsyncFunction { | 44 class StartSpeechInputFunction : public SpeechInputAsyncFunction { |
| 45 public: |
| 46 StartSpeechInputFunction(); |
| 47 virtual ~StartSpeechInputFunction() {} |
| 48 |
| 35 protected: | 49 protected: |
| 36 virtual bool RunImpl() OVERRIDE; | 50 virtual bool RunImpl() OVERRIDE; |
| 37 DECLARE_EXTENSION_FUNCTION_NAME("experimental.speechInput.start"); | 51 DECLARE_EXTENSION_FUNCTION_NAME("experimental.speechInput.start"); |
| 38 }; | 52 }; |
| 39 | 53 |
| 40 // Implements experimental.speechInput.stop. | 54 // Implements experimental.speechInput.stop. |
| 41 class StopSpeechInputFunction : public SpeechInputAsyncFunction { | 55 class StopSpeechInputFunction : public SpeechInputAsyncFunction { |
| 56 public: |
| 57 StopSpeechInputFunction(); |
| 58 virtual ~StopSpeechInputFunction() {} |
| 59 |
| 42 protected: | 60 protected: |
| 43 virtual bool RunImpl() OVERRIDE; | 61 virtual bool RunImpl() OVERRIDE; |
| 44 DECLARE_EXTENSION_FUNCTION_NAME("experimental.speechInput.stop"); | 62 DECLARE_EXTENSION_FUNCTION_NAME("experimental.speechInput.stop"); |
| 45 }; | 63 }; |
| 46 | 64 |
| 47 // Implements experimental.speechInput.isRecording. | 65 // Implements experimental.speechInput.isRecording. |
| 48 class IsRecordingSpeechInputFunction : public SyncIOThreadExtensionFunction { | 66 class IsRecordingSpeechInputFunction : public SyncExtensionFunction { |
| 49 protected: | 67 protected: |
| 50 virtual bool RunImpl() OVERRIDE; | 68 virtual bool RunImpl() OVERRIDE; |
| 51 DECLARE_EXTENSION_FUNCTION_NAME("experimental.speechInput.isRecording"); | 69 DECLARE_EXTENSION_FUNCTION_NAME("experimental.speechInput.isRecording"); |
| 52 }; | 70 }; |
| 53 | 71 |
| 54 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SPEECH_INPUT_API_H_ | 72 #endif // CHROME_BROWSER_EXTENSIONS_SPEECH_INPUT_EXTENSION_SPEECH_INPUT_API_H_ |
| OLD | NEW |