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

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

Issue 1130763005: Don't start the hotword extension on Chrome startup if the user doesn't have hotwording enabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « chrome/browser/resources/hotword/manager.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/hotword/state_manager.js
diff --git a/chrome/browser/resources/hotword/state_manager.js b/chrome/browser/resources/hotword/state_manager.js
index ebe68355d80815250acd0df74ba2eaa7c479bb31..7c8e30a2c4e1d0bda7e1920058aa038e003cce20 100644
--- a/chrome/browser/resources/hotword/state_manager.js
+++ b/chrome/browser/resources/hotword/state_manager.js
@@ -101,6 +101,7 @@ cr.define('hotword', function() {
* @private
*/
this.idleStateChangedListener_ = this.handleIdleStateChanged_.bind(this);
+ this.startupListener_ = this.handleStartup_.bind(this);
/**
* Whether this user is locked.
@@ -141,6 +142,11 @@ cr.define('hotword', function() {
this.chime_.src = chrome.extension.getURL(
hotword.constants.SHARED_MODULE_ROOT + '/audio/chime.wav');
document.body.appendChild(this.chime_);
+
+ // In order to remove this listener, it must first be added. This handles
+ // the case on first Chrome startup where this event is never registered,
+ // so can't be removed when it's determined that hotwording is disabled.
+ chrome.runtime.onStartup.addListener(this.startupListener_);
Matt Giuca 2015/05/15 06:54:42 Why not just not remove it if it hasn't been added
Anand Mistry (off Chromium) 2015/05/15 07:08:36 Ah, undocumented and poorly understood behaviour o
Matt Giuca 2015/05/15 08:32:43 Gross :( Could you explain that a bit in the comm
Anand Mistry (off Chromium) 2015/05/18 01:24:22 Done.
}
/**
@@ -279,12 +285,18 @@ cr.define('hotword', function() {
chrome.idle.onStateChanged.addListener(
this.idleStateChangedListener_);
}
+ if (!chrome.runtime.onStartup.hasListener(this.startupListener_))
+ chrome.runtime.onStartup.addListener(this.startupListener_);
} else {
// Not enabled. Shut down if running.
this.shutdownDetector_();
chrome.idle.onStateChanged.removeListener(
this.idleStateChangedListener_);
+ // If hotwording isn't enabled, don't start this component extension on
+ // Chrome startup. If a user enables hotwording, the status change
+ // event will be fired and the onStartup event will be registered.
+ chrome.runtime.onStartup.removeListener(this.startupListener_);
}
},
@@ -602,6 +614,14 @@ cr.define('hotword', function() {
if (oldLocked != this.isLocked_)
this.updateStateFromStatus_();
+ },
+
+ /**
+ * Handles a chrome.runtime.onStartup event.
+ * @private
+ */
+ handleStartup_: function() {
+ updateStatus();
}
};
« no previous file with comments | « chrome/browser/resources/hotword/manager.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698