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

Unified Diff: chrome/browser/resources/hotword/page_audio_manager.js

Issue 1047973003: Notify hotwording extension of microphone state change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 8 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/resources/hotword/page_audio_manager.js
diff --git a/chrome/browser/resources/hotword/page_audio_manager.js b/chrome/browser/resources/hotword/page_audio_manager.js
index a845828cbc1109859eb2cc09f9042e4e254de283..067ff4ec2358a418af2b86df0269523c094d134c 100644
--- a/chrome/browser/resources/hotword/page_audio_manager.js
+++ b/chrome/browser/resources/hotword/page_audio_manager.js
@@ -35,6 +35,8 @@ cr.define('hotword', function() {
this.tabCreatedListener_ = this.handleCreatedTab_.bind(this);
this.tabUpdatedListener_ = this.handleUpdatedTab_.bind(this);
this.tabActivatedListener_ = this.handleActivatedTab_.bind(this);
+ this.microphoneStateChangedListener_ =
+ this.handleMicrophoneStateChanged_.bind(this);
this.windowFocusChangedListener_ = this.handleChangedWindow_.bind(this);
this.messageListener_ = this.handleMessageFromPage_.bind(this);
@@ -237,6 +239,19 @@ cr.define('hotword', function() {
this.updateTabState_();
},
+ /**
+ * Handles the microphone state changing.
+ * @param {boolean} enabled Whether the microphone is now enabled.
+ * @private
+ */
+ handleMicrophoneStateChanged_: function(enabled) {
+ if (enabled) {
+ this.updateTabState_();
+ return;
+ }
+
+ this.stopHotwording_();
+ },
/**
* Handles a change in Chrome windows.
@@ -492,6 +507,8 @@ cr.define('hotword', function() {
chrome.tabs.onActivated.addListener(this.tabActivatedListener_);
chrome.windows.onFocusChanged.addListener(
this.windowFocusChangedListener_);
+ chrome.hotwordPrivate.onMicrophoneStateChanged.addListener(
+ this.microphoneStateChangedListener_);
if (chrome.runtime.onMessage.hasListener(this.messageListener_))
return;
chrome.runtime.onMessageExternal.addListener(
@@ -509,6 +526,8 @@ cr.define('hotword', function() {
chrome.tabs.onActivated.removeListener(this.tabActivatedListener_);
chrome.windows.onFocusChanged.removeListener(
this.windowFocusChangedListener_);
+ chrome.hotwordPrivate.onMicrophoneStateChanged.removeListener(
+ this.microphoneStateChangedListener_);
// Don't remove the Message listener, as we want them listening all
// the time,
},
« no previous file with comments | « chrome/browser/extensions/api/hotword_private/hotword_private_api.cc ('k') | chrome/browser/search/hotword_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698