blob: a4489911c01e1e1b3b84b1af80ff0ce04df13dc6 [file] [log] [blame]
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_CLIENT_BROWSER_INTERFACE_H_
#define CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_CLIENT_BROWSER_INTERFACE_H_
#include "chrome/browser/accessibility/soda_installer.h"
#include "components/keyed_service/core/keyed_service.h"
#include "media/mojo/mojom/speech_recognition_service.mojom.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/remote_set.h"
class PrefChangeRegistrar;
class PrefService;
namespace content {
class BrowserContext;
} // namespace content
namespace speech {
class SpeechRecognitionClientBrowserInterface
: public KeyedService,
public media::mojom::SpeechRecognitionClientBrowserInterface,
public speech::SodaInstaller::Observer {
public:
explicit SpeechRecognitionClientBrowserInterface(
content::BrowserContext* context);
SpeechRecognitionClientBrowserInterface(
const SpeechRecognitionClientBrowserInterface&) = delete;
SpeechRecognitionClientBrowserInterface& operator=(
const SpeechRecognitionClientBrowserInterface&) = delete;
~SpeechRecognitionClientBrowserInterface() override;
void BindReceiver(
mojo::PendingReceiver<
media::mojom::SpeechRecognitionClientBrowserInterface> receiver);
// media::mojom::SpeechRecognitionClientBrowserInterface
void BindSpeechRecognitionAvailabilityObserver(
mojo::PendingRemote<media::mojom::SpeechRecognitionAvailabilityObserver>
pending_remote) override;
// SodaInstaller::Observer:
void OnSodaInstalled() override;
void OnSodaProgress(int progress) override {}
void OnSodaError() override {}
private:
void OnSpeechRecognitionAvailabilityChanged();
void NotifyObservers(bool enabled);
mojo::RemoteSet<media::mojom::SpeechRecognitionAvailabilityObserver>
speech_recognition_availibility_observers_;
mojo::ReceiverSet<media::mojom::SpeechRecognitionClientBrowserInterface>
speech_recognition_client_browser_interface_;
std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;
PrefService* profile_prefs_;
};
} // namespace speech
#endif // CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_CLIENT_BROWSER_INTERFACE_H_