diff options
author | rlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-28 18:08:54 +0000 |
---|---|---|
committer | rlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-28 18:08:54 +0000 |
commit | 1d9a47de84304d4d8733d5275ea861c531db9054 (patch) | |
tree | ea7cd2c27c3e7c9e2192159e91425c5cafe6cdfa | |
parent | d0d54f5a25932b3ac32976fc2ebb2ce76be2b645 (diff) | |
download | chromium_src-1d9a47de84304d4d8733d5275ea861c531db9054.zip chromium_src-1d9a47de84304d4d8733d5275ea861c531db9054.tar.gz chromium_src-1d9a47de84304d4d8733d5275ea861c531db9054.tar.bz2 |
[Hotword] Update helper extension to listen for change to audio logging preference.
Helper extension then notifies chrome and tells the extension to turn on/off.
BUG=345811
Review URL: https://codereview.chromium.org/212253003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260195 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/resources/hotword_helper/manager.js | 25 | ||||
-rw-r--r-- | chrome/browser/resources/hotword_helper/optin_client.js | 20 |
2 files changed, 32 insertions, 13 deletions
diff --git a/chrome/browser/resources/hotword_helper/manager.js b/chrome/browser/resources/hotword_helper/manager.js index ba0ee5c..07428fc 100644 --- a/chrome/browser/resources/hotword_helper/manager.js +++ b/chrome/browser/resources/hotword_helper/manager.js @@ -49,7 +49,11 @@ OptInManager.CommandFromPage = { // User has explicitly clicked 'no'. CLICKED_NO_OPTIN: 'hcno', // User has opted in. - CLICKED_OPTIN: 'hco' + CLICKED_OPTIN: 'hco', + // Audio logging is opted in. + AUDIO_LOGGING_ON: 'alon', + // Audio logging is opted out. + AUDIO_LOGGING_OFF: 'aloff', }; @@ -157,6 +161,25 @@ OptInManager.prototype.handleMessage_ = function( chrome.hotwordPrivate.setEnabled(false); } } + // Information regarding the audio logging preference was sent. + if (request.type === OptInManager.CommandFromPage.AUDIO_LOGGING_ON) { + if (chrome.hotwordPrivate && + chrome.hotwordPrivate.setAudioLoggingEnabled) { + chrome.hotwordPrivate.setAudioLoggingEnabled(true); + chrome.runtime.sendMessage( + OptInManager.HOTWORD_EXTENSION_ID_, + {'cmd': OptInManager.CommandFromHelper.AUDIO_LOGGING_ON}); + } + } + if (request.type === OptInManager.CommandFromPage.AUDIO_LOGGING_OFF) { + if (chrome.hotwordPrivate && + chrome.hotwordPrivate.setAudioLoggingEnabled) { + chrome.hotwordPrivate.setAudioLoggingEnabled(false); + chrome.runtime.sendMessage( + OptInManager.HOTWORD_EXTENSION_ID_, + {'cmd': OptInManager.CommandFromHelper.AUDIO_LOGGING_OFF}); + } + } } }; diff --git a/chrome/browser/resources/hotword_helper/optin_client.js b/chrome/browser/resources/hotword_helper/optin_client.js index a688df7..8ac22de 100644 --- a/chrome/browser/resources/hotword_helper/optin_client.js +++ b/chrome/browser/resources/hotword_helper/optin_client.js @@ -35,7 +35,11 @@ OptInClient.CommandFromPage = { // User has explicitly clicked 'no'. CLICKED_NO_OPTIN: 'hcno', // User has opted in. - CLICKED_OPTIN: 'hco' + CLICKED_OPTIN: 'hco', + // Audio logging is opted in. + AUDIO_LOGGING_ON: 'alon', + // Audio logging is opted out. + AUDIO_LOGGING_OFF: 'aloff', }; @@ -49,23 +53,15 @@ OptInClient.EXISTS_ = 'chwoihe'; /** * Handles the messages posted to the window, mainly listening for - * the optin and no optin clicks. + * the optin and no optin clicks. Also listening for preference on + * audio logging. * @param {!MessageEvent} messageEvent Message event from the window. * @private */ OptInClient.prototype.handleCommandFromPage_ = function(messageEvent) { if (messageEvent.source === window && messageEvent.data.type) { var command = messageEvent.data.type; - switch (command) { - case OptInClient.CommandFromPage.CLICKED_OPTIN: - chrome.runtime.sendMessage( - {'type': command}); - break; - case OptInClient.CommandFromPage.CLICKED_NO_OPTIN: - chrome.runtime.sendMessage( - {'type': command}); - break; - } + chrome.runtime.sendMessage({'type': command}); } }; |