From f9d94211bb2ad2f96ed1c4fe8c457f3c5b4c4817 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 10 Jul 2024 08:32:50 -0500 Subject: [PATCH] refactor: do not subclass ElectronSpeechRecognitionManagerDelegate from SpeechRecognitionEventListener (#42806) All the listener functions are empty stubs (and have been since d4e3c39) so it doesn't seem like we need a listener? SpeechRecognitionManagerDelegate declares this method: > // Checks whether the delegate is interested (returning a non nullptr > // ptr) or not (returning nullptr) in receiving a copy of all sessions > // events. This is called on the IO thread. > virtual SpeechRecognitionEventListener* GetEventListener() = 0; This PR has ElectronSpeechRecognitionManagerDelegate stop subclassing from the Listener and changes GetEventListener() to return nullptr. --- ...ron_speech_recognition_manager_delegate.cc | 29 +------------------ ...tron_speech_recognition_manager_delegate.h | 22 +------------- 2 files changed, 2 insertions(+), 49 deletions(-) diff --git a/shell/browser/electron_speech_recognition_manager_delegate.cc b/shell/browser/electron_speech_recognition_manager_delegate.cc index c01ad44b0e55..3adc360eb237 100644 --- a/shell/browser/electron_speech_recognition_manager_delegate.cc +++ b/shell/browser/electron_speech_recognition_manager_delegate.cc @@ -16,33 +16,6 @@ ElectronSpeechRecognitionManagerDelegate:: ElectronSpeechRecognitionManagerDelegate:: ~ElectronSpeechRecognitionManagerDelegate() = default; -void ElectronSpeechRecognitionManagerDelegate::OnRecognitionStart( - int session_id) {} - -void ElectronSpeechRecognitionManagerDelegate::OnAudioStart(int session_id) {} - -void ElectronSpeechRecognitionManagerDelegate::OnSoundStart(int session_id) {} - -void ElectronSpeechRecognitionManagerDelegate::OnSoundEnd(int session_id) {} - -void ElectronSpeechRecognitionManagerDelegate::OnAudioEnd(int session_id) {} - -void ElectronSpeechRecognitionManagerDelegate::OnRecognitionEnd( - int session_id) {} - -void ElectronSpeechRecognitionManagerDelegate::OnRecognitionResults( - int session_id, - const std::vector& results) {} - -void ElectronSpeechRecognitionManagerDelegate::OnRecognitionError( - int session_id, - const media::mojom::SpeechRecognitionError& error) {} - -void ElectronSpeechRecognitionManagerDelegate::OnAudioLevelsChange( - int session_id, - float volume, - float noise_volume) {} - void ElectronSpeechRecognitionManagerDelegate::CheckRecognitionIsAllowed( int session_id, base::OnceCallback callback) { @@ -51,7 +24,7 @@ void ElectronSpeechRecognitionManagerDelegate::CheckRecognitionIsAllowed( content::SpeechRecognitionEventListener* ElectronSpeechRecognitionManagerDelegate::GetEventListener() { - return this; + return nullptr; } void ElectronSpeechRecognitionManagerDelegate::BindSpeechRecognitionContext( diff --git a/shell/browser/electron_speech_recognition_manager_delegate.h b/shell/browser/electron_speech_recognition_manager_delegate.h index 442fed55f1eb..f428521620ea 100644 --- a/shell/browser/electron_speech_recognition_manager_delegate.h +++ b/shell/browser/electron_speech_recognition_manager_delegate.h @@ -5,16 +5,13 @@ #ifndef ELECTRON_SHELL_BROWSER_ELECTRON_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_ #define ELECTRON_SHELL_BROWSER_ELECTRON_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_ -#include - #include "content/public/browser/speech_recognition_event_listener.h" #include "content/public/browser/speech_recognition_manager_delegate.h" namespace electron { class ElectronSpeechRecognitionManagerDelegate - : public content::SpeechRecognitionManagerDelegate, - public content::SpeechRecognitionEventListener { + : public content::SpeechRecognitionManagerDelegate { public: ElectronSpeechRecognitionManagerDelegate(); ~ElectronSpeechRecognitionManagerDelegate() override; @@ -25,23 +22,6 @@ class ElectronSpeechRecognitionManagerDelegate ElectronSpeechRecognitionManagerDelegate& operator=( const ElectronSpeechRecognitionManagerDelegate&) = delete; - // content::SpeechRecognitionEventListener: - void OnRecognitionStart(int session_id) override; - void OnAudioStart(int session_id) override; - void OnSoundStart(int session_id) override; - void OnSoundEnd(int session_id) override; - void OnAudioEnd(int session_id) override; - void OnRecognitionEnd(int session_id) override; - void OnRecognitionResults( - int session_id, - const std::vector&) override; - void OnRecognitionError( - int session_id, - const media::mojom::SpeechRecognitionError& error) override; - void OnAudioLevelsChange(int session_id, - float volume, - float noise_volume) override; - // content::SpeechRecognitionManagerDelegate: void CheckRecognitionIsAllowed( int session_id,