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
3 // found in the LICENSE file.
6 * @fileoverview App launcher start page implementation.
9 <include src
="recommended_apps.js"/>
10 <include src
="speech_manager.js"/>
12 cr
.define('appList.startPage', function() {
15 var speechManager
= null;
18 * Creates a StartPage object.
20 * @extends {HTMLDivElement}
22 var StartPage
= cr
.ui
.define('div');
24 StartPage
.prototype = {
25 __proto__
: HTMLDivElement
.prototype,
28 * Instance of the recommended apps card.
29 * @type {appsList.startPage.RecommendedApps}
32 recommendedApps_
: null,
35 decorate: function() {
36 this.recommendedApps_
= new appList
.startPage
.RecommendedApps();
37 this.appendChild(this.recommendedApps_
);
41 * Sets the recommended apps.
42 * @param {!Array.<!{appId: string,
44 * textTitle: string}>} apps An array of app info
45 * dictionary to be displayed in the AppItemView.
47 setRecommendedApps: function(apps
) {
48 this.recommendedApps_
.setApps(apps
);
53 * Initialize the page.
55 function initialize() {
56 StartPage
.decorate($('start-page'));
57 speechManager
= new speech
.SpeechManager();
58 chrome
.send('initialize');
62 * Sets the recommended apps.
63 * @param {Array.<Object>} apps An array of app info dictionary.
65 function setRecommendedApps(apps
) {
66 $('start-page').setRecommendedApps(apps
);
70 * Invoked when the hotword plugin availability is changed.
72 * @param {boolean} enabled Whether the plugin is enabled or not.
74 function setHotwordEnabled(enabled
) {
75 speechManager
.setHotwordEnabled(enabled
);
79 * Sets the architecture of NaCl module to be loaded for hotword.
80 * @param {string} arch The architecture.
82 function setNaclArch(arch
) {
83 speechManager
.setNaclArch(arch
);
87 * Invoked when the app-list bubble is shown.
89 * @param {boolean} hotwordEnabled Whether the hotword is enabled or not.
91 function onAppListShown(hotwordEnabled
) {
92 speechManager
.onShown(hotwordEnabled
);
96 * Invoked when the app-list bubble is hidden.
98 function onAppListHidden() {
99 speechManager
.onHidden();
103 * Invoked when the user explicitly wants to toggle the speech recognition
106 function toggleSpeechRecognition() {
107 speechManager
.toggleSpeechRecognition();
111 initialize
: initialize
,
112 setRecommendedApps
: setRecommendedApps
,
113 setHotwordEnabled
: setHotwordEnabled
,
114 setNaclArch
: setNaclArch
,
115 onAppListShown
: onAppListShown
,
116 onAppListHidden
: onAppListHidden
,
117 toggleSpeechRecognition
: toggleSpeechRecognition
121 document
.addEventListener('contextmenu', function(e
) { e
.preventDefault(); });
122 document
.addEventListener('DOMContentLoaded', appList
.startPage
.initialize
);