OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 cr.define('hotword', function() { | 5 cr.define('hotword', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 /** | 8 /** |
9 * Class used to manage the interaction between hotwording and the | 9 * Class used to manage the interaction between hotwording and the |
10 * NTP/google.com. Injects a content script to interact with NTP/google.com | 10 * NTP/google.com. Injects a content script to interact with NTP/google.com |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 * Sends the response to the tab. | 447 * Sends the response to the tab. |
448 * @param {Tab} tab The tab that the request was sent from. | 448 * @param {Tab} tab The tab that the request was sent from. |
449 * @param {function(HotwordStatus)} sendResponse Callback function to | 449 * @param {function(HotwordStatus)} sendResponse Callback function to |
450 * respond to sender. | 450 * respond to sender. |
451 * @param {HotwordStatus} hotwordStatus Status of the hotword extension. | 451 * @param {HotwordStatus} hotwordStatus Status of the hotword extension. |
452 * @private | 452 * @private |
453 */ | 453 */ |
454 statusDone_: function(tab, sendResponse, hotwordStatus) { | 454 statusDone_: function(tab, sendResponse, hotwordStatus) { |
455 var response = {'doNotShowOptinMessage': true}; | 455 var response = {'doNotShowOptinMessage': true}; |
456 | 456 |
| 457 // If always-on is available, then we do not show the promo, as the promo |
| 458 // only works with the sometimes-on pref. |
457 if (!tab.incognito && hotwordStatus.available && | 459 if (!tab.incognito && hotwordStatus.available && |
458 !hotwordStatus.enabledSet) { | 460 !hotwordStatus.enabledSet && !hotwordStatus.alwaysOnAvailable) { |
459 response = hotwordStatus; | 461 response = hotwordStatus; |
460 } | 462 } |
461 | 463 |
462 try { | 464 try { |
463 sendResponse(response); | 465 sendResponse(response); |
464 } catch (err) { | 466 } catch (err) { |
465 // Suppress the exception thrown by sendResponse() when the page doesn't | 467 // Suppress the exception thrown by sendResponse() when the page doesn't |
466 // specify a response callback in the call to | 468 // specify a response callback in the call to |
467 // chrome.runtime.sendMessage(). | 469 // chrome.runtime.sendMessage(). |
468 // Unfortunately, there doesn't appear to be a way to detect one-way | 470 // Unfortunately, there doesn't appear to be a way to detect one-way |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 this.stopHotwording_(); | 524 this.stopHotwording_(); |
523 this.disconnectAllClients_(); | 525 this.disconnectAllClients_(); |
524 } | 526 } |
525 } | 527 } |
526 }; | 528 }; |
527 | 529 |
528 return { | 530 return { |
529 PageAudioManager: PageAudioManager | 531 PageAudioManager: PageAudioManager |
530 }; | 532 }; |
531 }); | 533 }); |
OLD | NEW |