electron_speech_recognition_manager_delegate.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright (c) 2014 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ELECTRON_SHELL_BROWSER_ELECTRON_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_
  5. #define ELECTRON_SHELL_BROWSER_ELECTRON_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_
  6. #include <vector>
  7. #include "content/public/browser/speech_recognition_event_listener.h"
  8. #include "content/public/browser/speech_recognition_manager_delegate.h"
  9. namespace electron {
  10. class ElectronSpeechRecognitionManagerDelegate
  11. : public content::SpeechRecognitionManagerDelegate,
  12. public content::SpeechRecognitionEventListener {
  13. public:
  14. ElectronSpeechRecognitionManagerDelegate();
  15. ~ElectronSpeechRecognitionManagerDelegate() override;
  16. // disable copy
  17. ElectronSpeechRecognitionManagerDelegate(
  18. const ElectronSpeechRecognitionManagerDelegate&) = delete;
  19. ElectronSpeechRecognitionManagerDelegate& operator=(
  20. const ElectronSpeechRecognitionManagerDelegate&) = delete;
  21. // content::SpeechRecognitionEventListener:
  22. void OnRecognitionStart(int session_id) override;
  23. void OnAudioStart(int session_id) override;
  24. void OnEnvironmentEstimationComplete(int session_id) override;
  25. void OnSoundStart(int session_id) override;
  26. void OnSoundEnd(int session_id) override;
  27. void OnAudioEnd(int session_id) override;
  28. void OnRecognitionEnd(int session_id) override;
  29. void OnRecognitionResults(
  30. int session_id,
  31. const std::vector<blink::mojom::SpeechRecognitionResultPtr>&) override;
  32. void OnRecognitionError(
  33. int session_id,
  34. const blink::mojom::SpeechRecognitionError& error) override;
  35. void OnAudioLevelsChange(int session_id,
  36. float volume,
  37. float noise_volume) override;
  38. // content::SpeechRecognitionManagerDelegate:
  39. void CheckRecognitionIsAllowed(
  40. int session_id,
  41. base::OnceCallback<void(bool ask_user, bool is_allowed)> callback)
  42. override;
  43. content::SpeechRecognitionEventListener* GetEventListener() override;
  44. bool FilterProfanities(int render_process_id) override;
  45. };
  46. } // namespace electron
  47. #endif // ELECTRON_SHELL_BROWSER_ELECTRON_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_