summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Giuca <mgiuca@chromium.org>2015-10-06 14:19:38 +1100
committerMatt Giuca <mgiuca@chromium.org>2015-10-06 03:22:33 +0000
commit83cc9ef7beaf1b1905faf0432cc0ce52ce374897 (patch)
tree6f9e53405d3ce23d4abe6f6dbcff2de46143bd91
parentedfcd0fe451d9365379c9ade6fc60afdd3394555 (diff)
downloadchromium_src-83cc9ef7beaf1b1905faf0432cc0ce52ce374897.zip
chromium_src-83cc9ef7beaf1b1905faf0432cc0ce52ce374897.tar.gz
chromium_src-83cc9ef7beaf1b1905faf0432cc0ce52ce374897.tar.bz2
Fix hotword promo and microphone click for GWS.
BUG=537945 Review URL: https://codereview.chromium.org/1385553002 Cr-Commit-Position: refs/heads/master@{#351963} (cherry picked from commit c1533f682276f3bb990dac938848c814e3f5e7b6) TBR=kcarattini@chromium.org Review URL: https://codereview.chromium.org/1384683003 . Cr-Commit-Position: refs/branch-heads/2490@{#500} Cr-Branched-From: 7790a3535f2a81a03685eca31a32cf69ae0c114f-refs/heads/master@{#344925}
-rw-r--r--chrome/browser/resources/hotword/page_audio_manager.js45
1 files changed, 30 insertions, 15 deletions
diff --git a/chrome/browser/resources/hotword/page_audio_manager.js b/chrome/browser/resources/hotword/page_audio_manager.js
index 067ff4e..71efbeb 100644
--- a/chrome/browser/resources/hotword/page_audio_manager.js
+++ b/chrome/browser/resources/hotword/page_audio_manager.js
@@ -68,7 +68,8 @@ cr.define('hotword', function() {
url.indexOf(base + '/?') == 0 ||
url.indexOf(base + '/#') == 0 ||
url.indexOf(base + '/webhp') == 0 ||
- url.indexOf(base + '/search') == 0) {
+ url.indexOf(base + '/search') == 0 ||
+ url.indexOf(base + '/imghp') == 0) {
return true;
}
return false;
@@ -447,6 +448,9 @@ cr.define('hotword', function() {
sendResponse));
return true;
}
+
+ // Do not show the opt-in promo for ineligible urls.
+ this.sendResponse_({'doNotShowOptinMessage': true}, sendResponse);
break;
case CommandFromPage.CLICKED_OPTIN:
chrome.hotwordPrivate.setEnabled(true);
@@ -460,6 +464,30 @@ cr.define('hotword', function() {
},
/**
+ * Sends a message directly to the sending page.
+ * @param {!HotwordStatus} response The response to send to the sender.
+ * @param {!function(HotwordStatus)} sendResponse Callback to respond
+ * to sender.
+ * @private
+ */
+ sendResponse_: function(response, sendResponse) {
+ try {
+ sendResponse(response);
+ } catch (err) {
+ // Suppress the exception thrown by sendResponse() when the page doesn't
+ // specify a response callback in the call to
+ // chrome.runtime.sendMessage().
+ // Unfortunately, there doesn't appear to be a way to detect one-way
+ // messages without explicitly saying in the message itself. This
+ // message is defined as a constant in
+ // extensions/renderer/messaging_bindings.cc
+ if (err.message == 'Attempting to use a disconnected port object')
+ return;
+ throw err;
+ }
+ },
+
+ /**
* Sends the response to the tab.
* @param {Tab} tab The tab that the request was sent from.
* @param {function(HotwordStatus)} sendResponse Callback function to
@@ -477,20 +505,7 @@ cr.define('hotword', function() {
response = hotwordStatus;
}
- try {
- sendResponse(response);
- } catch (err) {
- // Suppress the exception thrown by sendResponse() when the page doesn't
- // specify a response callback in the call to
- // chrome.runtime.sendMessage().
- // Unfortunately, there doesn't appear to be a way to detect one-way
- // messages without explicitly saying in the message itself. This
- // message is defined as a constant in
- // extensions/renderer/messaging_bindings.cc
- if (err.message == 'Attempting to use a disconnected port object')
- return;
- throw err;
- }
+ this.sendResponse_(response, sendResponse);
},
/**