• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 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 CEF_LIBCEF_BROWSER_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_
6 #define CEF_LIBCEF_BROWSER_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_
7 
8 #include "base/compiler_specific.h"
9 #include "base/memory/ref_counted.h"
10 #include "content/public/browser/speech_recognition_event_listener.h"
11 #include "content/public/browser/speech_recognition_manager_delegate.h"
12 
13 // This is CEF's implementation of the SpeechRecognitionManagerDelegate
14 // interface. Based on chrome/browser/speech/
15 // chrome_speech_recognition_manager_delegate.[cc|h]
16 class CefSpeechRecognitionManagerDelegate
17     : public content::SpeechRecognitionManagerDelegate,
18       public content::SpeechRecognitionEventListener {
19  public:
20   CefSpeechRecognitionManagerDelegate();
21 
22   CefSpeechRecognitionManagerDelegate(
23       const CefSpeechRecognitionManagerDelegate&) = delete;
24   CefSpeechRecognitionManagerDelegate& operator=(
25       const CefSpeechRecognitionManagerDelegate&) = delete;
26 
27   ~CefSpeechRecognitionManagerDelegate() override;
28 
29  protected:
30   // SpeechRecognitionEventListener methods.
31   void OnRecognitionStart(int session_id) override;
32   void OnAudioStart(int session_id) override;
33   void OnEnvironmentEstimationComplete(int session_id) override;
34   void OnSoundStart(int session_id) override;
35   void OnSoundEnd(int session_id) override;
36   void OnAudioEnd(int session_id) override;
37   void OnRecognitionEnd(int session_id) override;
38   void OnRecognitionResults(
39       int session_id,
40       const std::vector<blink::mojom::SpeechRecognitionResultPtr>& result)
41       override;
42   void OnRecognitionError(
43       int session_id,
44       const blink::mojom::SpeechRecognitionError& error) override;
45   void OnAudioLevelsChange(int session_id,
46                            float volume,
47                            float noise_volume) override;
48 
49   // SpeechRecognitionManagerDelegate methods.
50   void CheckRecognitionIsAllowed(
51       int session_id,
52       base::OnceCallback<void(bool ask_user, bool is_allowed)> callback)
53       override;
54   content::SpeechRecognitionEventListener* GetEventListener() override;
55   bool FilterProfanities(int render_process_id) override;
56 
57  private:
58   bool filter_profanities_;
59 };
60 
61 #endif  // CEF_LIBCEF_BROWSER_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_
62