Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1940)

Unified Diff: chrome/browser/search/hotword_service.h

Issue 1047973003: Notify hotwording extension of microphone state change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/search/hotword_service.h
diff --git a/chrome/browser/search/hotword_service.h b/chrome/browser/search/hotword_service.h
index 9b22c84310ec015e1eeac5b8d5dba5f5ba2c10ae..2d2394a38b1597de9d2323b4fd60fa80cdc67dff 100644
--- a/chrome/browser/search/hotword_service.h
+++ b/chrome/browser/search/hotword_service.h
@@ -12,6 +12,7 @@
#include "base/prefs/pref_change_registrar.h"
#include "base/scoped_observer.h"
#include "chrome/browser/extensions/webstore_startup_installer.h"
+#include "chrome/browser/media/media_capture_devices_dispatcher.h"
#include "chrome/common/extensions/webstore_install_result.h"
#include "components/keyed_service/core/keyed_service.h"
#include "content/public/browser/notification_observer.h"
@@ -38,7 +39,8 @@ extern const char kHotwordTrainingEnabled[];
// Provides an interface for the Hotword component that does voice triggered
// search.
-class HotwordService : public extensions::ExtensionRegistryObserver,
+class HotwordService : public MediaCaptureDevicesDispatcher::Observer,
+ public extensions::ExtensionRegistryObserver,
public KeyedService {
public:
// A simple subclass to allow for aborting an install during shutdown.
@@ -125,6 +127,8 @@ class HotwordService : public extensions::ExtensionRegistryObserver,
// no error.
int error_message() { return error_message_; }
+ bool microphone_available() { return microphone_available_; }
+
// These methods are for launching, and getting and setting the launch mode of
// the Hotword Audio Verification App.
//
@@ -174,6 +178,10 @@ class HotwordService : public extensions::ExtensionRegistryObserver,
// Turn off the currently enabled version of hotwording if one exists.
void DisableHotwordPreferences();
+ // Overridden from MediaCaptureDevicesDispatcher::Observer
+ void OnUpdateAudioDevices(
+ const content::MediaStreamDevices& devices) override;
+
protected:
// Used in test subclasses.
scoped_refptr<HotwordWebstoreInstaller> installer_;
@@ -181,6 +189,10 @@ class HotwordService : public extensions::ExtensionRegistryObserver,
private:
class HotwordUserSessionStateObserver;
+ // Must be called from the UI thread since the instance of
+ // MediaCaptureDevicesDispatcher can only be accessed on the UI thread.
+ void InitializeMicrophoneObserver();
+
// Callback for webstore extension installer.
void InstalledFromWebstoreCallback(
int num_tries,
@@ -207,6 +219,13 @@ class HotwordService : public extensions::ExtensionRegistryObserver,
scoped_ptr<HotwordAudioHistoryHandler> audio_history_handler_;
+ bool microphone_available_;
+
+ // Indicates if the check for audio devices has been run such that it can be
+ // included in the error checking. Audio checking is not done immediately
+ // upon start up because of the negative impact on performance.
+ bool audio_device_state_updated_;
+
HotwordClient* client_;
int error_message_;
bool reinstall_pending_;

Powered by Google App Engine
This is Rietveld 408576698