Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 /** | 5 /** |
| 6 * @fileoverview App launcher start page implementation. | 6 * @fileoverview App launcher start page implementation. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 <include src="speech_manager.js"> | 9 <include src="speech_manager.js"> |
|
calamity
2015/03/03 07:15:58
Delete this too?
Anand Mistry (off Chromium)
2015/03/03 07:23:10
Done.
| |
| 10 | 10 |
| 11 cr.define('appList.startPage', function() { | 11 cr.define('appList.startPage', function() { |
| 12 'use strict'; | 12 'use strict'; |
| 13 | 13 |
| 14 var speechManager = null; | |
| 15 | |
| 16 // The element containing the current Google Doodle. | 14 // The element containing the current Google Doodle. |
| 17 var doodle = null; | 15 var doodle = null; |
| 18 | 16 |
| 19 // TODO(calamity): This is used for manual inspection of the doodle data. | 17 // TODO(calamity): This is used for manual inspection of the doodle data. |
| 20 // Remove this once http://crbug.com/462082 is diagnosed. | 18 // Remove this once http://crbug.com/462082 is diagnosed. |
| 21 var doodleData = null; | 19 var doodleData = null; |
| 22 | 20 |
| 23 /** | 21 /** |
| 24 * Initialize the page. | 22 * Initialize the page. |
| 25 */ | 23 */ |
| 26 function initialize() { | 24 function initialize() { |
| 27 speechManager = new speech.SpeechManager(); | |
| 28 chrome.send('initialize'); | 25 chrome.send('initialize'); |
| 29 } | 26 } |
| 30 | 27 |
| 31 /** | 28 /** |
| 32 * Invoked when the hotword plugin availability is changed. | 29 * Invoked when the hotword plugin availability is changed. |
| 33 * | 30 * |
| 34 * @param {boolean} enabled Whether the plugin is enabled or not. | 31 * @param {boolean} enabled Whether the plugin is enabled or not. |
| 35 */ | 32 */ |
| 36 function setHotwordEnabled(enabled) { | 33 function setHotwordEnabled(enabled) { |
| 37 speechManager.setHotwordEnabled(enabled); | |
| 38 } | 34 } |
| 39 | 35 |
| 40 /** | 36 /** |
| 41 * Sets the architecture of NaCl module to be loaded for hotword. | 37 * Sets the architecture of NaCl module to be loaded for hotword. |
| 42 * @param {string} arch The architecture. | 38 * @param {string} arch The architecture. |
| 43 */ | 39 */ |
| 44 function setNaclArch(arch) { | 40 function setNaclArch(arch) { |
| 45 speechManager.setNaclArch(arch); | |
| 46 } | 41 } |
| 47 | 42 |
| 48 /** | 43 /** |
| 49 * Invoked when the app-list bubble is shown. | 44 * Invoked when the app-list bubble is shown. |
| 50 * | 45 * |
| 51 * @param {boolean} hotwordEnabled Whether the hotword is enabled or not. | 46 * @param {boolean} hotwordEnabled Whether the hotword is enabled or not. |
| 52 */ | 47 */ |
| 53 function onAppListShown(hotwordEnabled, legacySpeechEnabled) { | 48 function onAppListShown(hotwordEnabled, legacySpeechEnabled) { |
| 54 if (legacySpeechEnabled) | |
| 55 speechManager.onShown(hotwordEnabled); | |
| 56 | 49 |
| 57 chrome.send('appListShown', [this.doodle != null]); | 50 chrome.send('appListShown', [this.doodle != null]); |
| 58 } | 51 } |
| 59 | 52 |
| 60 /** | 53 /** |
| 61 * Sets the doodle's visibility, hiding or showing the default logo. | 54 * Sets the doodle's visibility, hiding or showing the default logo. |
| 62 * | 55 * |
| 63 * @param {boolean} visible Whether the doodle should be made visible. | 56 * @param {boolean} visible Whether the doodle should be made visible. |
| 64 */ | 57 */ |
| 65 function setDoodleVisible(visible) { | 58 function setDoodleVisible(visible) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 } else { | 121 } else { |
| 129 this.doodle.appendChild(doodleImage); | 122 this.doodle.appendChild(doodleImage); |
| 130 } | 123 } |
| 131 $('logo_container').appendChild(this.doodle); | 124 $('logo_container').appendChild(this.doodle); |
| 132 } | 125 } |
| 133 | 126 |
| 134 /** | 127 /** |
| 135 * Invoked when the app-list bubble is hidden. | 128 * Invoked when the app-list bubble is hidden. |
| 136 */ | 129 */ |
| 137 function onAppListHidden() { | 130 function onAppListHidden() { |
| 138 speechManager.onHidden(); | |
| 139 } | 131 } |
| 140 | 132 |
| 141 /** | 133 /** |
| 142 * Invoked when the user explicitly wants to toggle the speech recognition | 134 * Invoked when the user explicitly wants to toggle the speech recognition |
| 143 * state. | 135 * state. |
| 144 */ | 136 */ |
| 145 function toggleSpeechRecognition() { | 137 function toggleSpeechRecognition() { |
| 146 speechManager.toggleSpeechRecognition(); | |
| 147 } | 138 } |
| 148 | 139 |
| 149 return { | 140 return { |
| 150 initialize: initialize, | 141 initialize: initialize, |
| 151 setHotwordEnabled: setHotwordEnabled, | 142 setHotwordEnabled: setHotwordEnabled, |
| 152 setNaclArch: setNaclArch, | 143 setNaclArch: setNaclArch, |
| 153 onAppListDoodleUpdated: onAppListDoodleUpdated, | 144 onAppListDoodleUpdated: onAppListDoodleUpdated, |
| 154 onAppListShown: onAppListShown, | 145 onAppListShown: onAppListShown, |
| 155 onAppListHidden: onAppListHidden, | 146 onAppListHidden: onAppListHidden, |
| 156 toggleSpeechRecognition: toggleSpeechRecognition | 147 toggleSpeechRecognition: toggleSpeechRecognition |
| 157 }; | 148 }; |
| 158 }); | 149 }); |
| 159 | 150 |
| 160 // TODO(calamity): Suppress context the menu once http://crbug.com/462082 is | 151 // TODO(calamity): Suppress context the menu once http://crbug.com/462082 is |
| 161 // diagnosed. | 152 // diagnosed. |
| 162 document.addEventListener('DOMContentLoaded', appList.startPage.initialize); | 153 document.addEventListener('DOMContentLoaded', appList.startPage.initialize); |
| OLD | NEW |