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