Commit 1d9a47de authored by rlp@chromium.org's avatar rlp@chromium.org

[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
parent d0d54f5a
...@@ -49,7 +49,11 @@ OptInManager.CommandFromPage = { ...@@ -49,7 +49,11 @@ OptInManager.CommandFromPage = {
// User has explicitly clicked 'no'. // User has explicitly clicked 'no'.
CLICKED_NO_OPTIN: 'hcno', CLICKED_NO_OPTIN: 'hcno',
// User has opted in. // 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( ...@@ -157,6 +161,25 @@ OptInManager.prototype.handleMessage_ = function(
chrome.hotwordPrivate.setEnabled(false); 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});
}
}
} }
}; };
......
...@@ -35,7 +35,11 @@ OptInClient.CommandFromPage = { ...@@ -35,7 +35,11 @@ OptInClient.CommandFromPage = {
// User has explicitly clicked 'no'. // User has explicitly clicked 'no'.
CLICKED_NO_OPTIN: 'hcno', CLICKED_NO_OPTIN: 'hcno',
// User has opted in. // 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'; ...@@ -49,23 +53,15 @@ OptInClient.EXISTS_ = 'chwoihe';
/** /**
* Handles the messages posted to the window, mainly listening for * 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. * @param {!MessageEvent} messageEvent Message event from the window.
* @private * @private
*/ */
OptInClient.prototype.handleCommandFromPage_ = function(messageEvent) { OptInClient.prototype.handleCommandFromPage_ = function(messageEvent) {
if (messageEvent.source === window && messageEvent.data.type) { if (messageEvent.source === window && messageEvent.data.type) {
var command = messageEvent.data.type; var command = messageEvent.data.type;
switch (command) { chrome.runtime.sendMessage({'type': command});
case OptInClient.CommandFromPage.CLICKED_OPTIN:
chrome.runtime.sendMessage(
{'type': command});
break;
case OptInClient.CommandFromPage.CLICKED_NO_OPTIN:
chrome.runtime.sendMessage(
{'type': command});
break;
}
} }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment