summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-14 17:41:16 +0000
committerrlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-14 17:41:16 +0000
commitf13b2ef4a3edc436988ac663d1ad49eb1adb7e8b (patch)
treebfcd0e14f8c1264998c5b4652bbfe63b3861267c
parenta3a5fe713b5de4e1970332f4a4902591903fc074 (diff)
downloadchromium_src-f13b2ef4a3edc436988ac663d1ad49eb1adb7e8b.zip
chromium_src-f13b2ef4a3edc436988ac663d1ad49eb1adb7e8b.tar.gz
chromium_src-f13b2ef4a3edc436988ac663d1ad49eb1adb7e8b.tar.bz2
Merge 260808 "[Hotword] Reset the hotword enabled preference to ..."
> [Hotword] Reset the hotword enabled preference to be disabled for those who had it previously set (either enabled or disabled). This means that folks who had it enabled will need to re-enable it. But anyone who might have had it enabled will no longer have it so. > > This CL also removes the unneeded functions to deal with a pref change signal since that is now handled entirely by the HotwordService that enables/disables the extension itself. > > Note: this code will probably be removed in M36. Tracking bug: crbug.com/358392 > > BUG=357845 > > Review URL: https://codereview.chromium.org/219573005 TBR=rlp@chromium.org Review URL: https://codereview.chromium.org/237363003 git-svn-id: svn://svn.chromium.org/chrome/branches/1916/src@263657 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/resources/hotword_helper/manager.js60
1 files changed, 27 insertions, 33 deletions
diff --git a/chrome/browser/resources/hotword_helper/manager.js b/chrome/browser/resources/hotword_helper/manager.js
index 07428fc..1685089 100644
--- a/chrome/browser/resources/hotword_helper/manager.js
+++ b/chrome/browser/resources/hotword_helper/manager.js
@@ -32,6 +32,12 @@ OptInManager.HOTWORD_EXTENSION_ID_ = 'bepbmhgboaologfdajaanbcjmnhjmhfn';
/**
+ * @const {string}
+ * @private
+ */
+OptInManager.RESET_HOTWORD_PREF_ = 'resetHotwordPref';
+
+/**
* Commands sent from this helper extension to the hotword extension.
* @enum {string}
*/
@@ -111,35 +117,6 @@ OptInManager.prototype.injectTab_ = function(tab, hotwordStatus) {
/**
- * Handles changes in the enabled state of the hotword feature in the
- * Chrome settings page.
- * @private
- */
-OptInManager.prototype.handleEnabledChange_ = function() {
- if (chrome.hotwordPrivate && chrome.hotwordPrivate.getStatus)
- chrome.hotwordPrivate.getStatus(this.updateEnabled_.bind(this));
-};
-
-
-/**
- * Sends a message to the hotword extension to update it about Chrome settings.
- * @param {HotwordStatus} hotwordStatus Status of the hotword extension.
- * @private
- */
-OptInManager.prototype.updateEnabled_ = function(hotwordStatus) {
- if (hotwordStatus.enabled) {
- chrome.runtime.sendMessage(
- OptInManager.HOTWORD_EXTENSION_ID_,
- {'cmd': OptInManager.CommandFromHelper.ENABLE});
- } else {
- chrome.runtime.sendMessage(
- OptInManager.HOTWORD_EXTENSION_ID_,
- {'cmd': OptInManager.CommandFromHelper.DISABLE});
- }
-};
-
-
-/**
* Handles messages from the helper content script.
* @param {*} request Message from the sender.
* @param {MessageSender} sender Information about the sender.
@@ -185,6 +162,23 @@ OptInManager.prototype.handleMessage_ = function(
/**
+ * Sets a flag to indicate that the hotword preference has been reset
+ * to disabled. See crbug.com/357845.
+ * @param {HotwordStatus} hotwordStatus Status of the hotword extension.
+ * @private
+ */
+OptInManager.prototype.resetHotwordPref_ = function(hotwordStatus) {
+ if (hotwordStatus.enabledSet &&
+ !localStorage.getItem(OptInManager.RESET_HOTWORD_PREF_) &&
+ chrome.hotwordPrivate && chrome.hotwordPrivate.setEnabled) {
+ chrome.hotwordPrivate.setEnabled(false);
+ }
+ localStorage.setItem(OptInManager.RESET_HOTWORD_PREF_, 'true');
+};
+
+
+
+/**
* Determines if a URL is eligible for hotwording. For now, the
* valid pages are the Google HP and SERP (this will include the NTP).
* @param {string} url Url to check.
@@ -224,10 +218,10 @@ OptInManager.prototype.initialize = function() {
chrome.tabs.onUpdated.addListener(this.handleUpdatedTab_.bind(this));
chrome.runtime.onMessage.addListener(this.handleMessage_.bind(this));
- if (chrome.hotwordPrivate && chrome.hotwordPrivate.onEnabledChanged) {
- chrome.hotwordPrivate.onEnabledChanged.addListener(
- this.handleEnabledChange_.bind(this));
- }
+ // Reset the preference to deal with crbug.com/357845.
+ // TODO(rlp): remove this reset once we hit M36. See crbug.com/358392.
+ if (chrome.hotwordPrivate && chrome.hotwordPrivate.getStatus)
+ chrome.hotwordPrivate.getStatus(this.resetHotwordPref_.bind(this));
};