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="recommended_apps.js"> | |
10 <include src="speech_manager.js"> | 9 <include src="speech_manager.js"> |
11 | 10 |
12 cr.define('appList.startPage', function() { | 11 cr.define('appList.startPage', function() { |
13 'use strict'; | 12 'use strict'; |
14 | 13 |
15 var speechManager = null; | 14 var speechManager = null; |
16 | 15 |
17 /** | 16 /** |
18 * Creates a StartPage object. | |
19 * @constructor | |
20 * @extends {HTMLDivElement} | |
21 */ | |
22 var StartPage = cr.ui.define('div'); | |
23 | |
24 StartPage.prototype = { | |
25 __proto__: HTMLDivElement.prototype, | |
26 | |
27 /** | |
28 * Instance of the recommended apps card. | |
29 * @type {appsList.startPage.RecommendedApps} | |
30 * @private | |
31 */ | |
32 recommendedApps_: null, | |
33 | |
34 /** @override */ | |
35 decorate: function() { | |
36 this.recommendedApps_ = new appList.startPage.RecommendedApps(); | |
37 this.appendChild(this.recommendedApps_); | |
38 }, | |
39 | |
40 /** | |
41 * Sets the recommended apps. | |
42 * @param {!Array.<!{appId: string, | |
43 * iconUrl: string, | |
44 * textTitle: string}>} apps An array of app info | |
45 * dictionary to be displayed in the AppItemView. | |
46 */ | |
47 setRecommendedApps: function(apps) { | |
48 this.recommendedApps_.setApps(apps); | |
49 } | |
50 }; | |
51 | |
52 /** | |
53 * Initialize the page. | 17 * Initialize the page. |
54 */ | 18 */ |
55 function initialize() { | 19 function initialize() { |
56 StartPage.decorate($('start-page')); | |
57 speechManager = new speech.SpeechManager(); | 20 speechManager = new speech.SpeechManager(); |
58 chrome.send('initialize'); | 21 chrome.send('initialize'); |
59 } | 22 } |
60 | 23 |
61 /** | 24 /** |
62 * Sets the recommended apps. | |
63 * @param {Array.<Object>} apps An array of app info dictionary. | |
64 */ | |
65 function setRecommendedApps(apps) { | |
66 $('start-page').setRecommendedApps(apps); | |
67 } | |
68 | |
69 /** | |
70 * Invoked when the hotword plugin availability is changed. | 25 * Invoked when the hotword plugin availability is changed. |
71 * | 26 * |
72 * @param {boolean} enabled Whether the plugin is enabled or not. | 27 * @param {boolean} enabled Whether the plugin is enabled or not. |
73 */ | 28 */ |
74 function setHotwordEnabled(enabled) { | 29 function setHotwordEnabled(enabled) { |
75 speechManager.setHotwordEnabled(enabled); | 30 speechManager.setHotwordEnabled(enabled); |
76 } | 31 } |
77 | 32 |
78 /** | 33 /** |
79 * Sets the architecture of NaCl module to be loaded for hotword. | 34 * Sets the architecture of NaCl module to be loaded for hotword. |
(...skipping 22 matching lines...) Expand all Loading... |
102 /** | 57 /** |
103 * Invoked when the user explicitly wants to toggle the speech recognition | 58 * Invoked when the user explicitly wants to toggle the speech recognition |
104 * state. | 59 * state. |
105 */ | 60 */ |
106 function toggleSpeechRecognition() { | 61 function toggleSpeechRecognition() { |
107 speechManager.toggleSpeechRecognition(); | 62 speechManager.toggleSpeechRecognition(); |
108 } | 63 } |
109 | 64 |
110 return { | 65 return { |
111 initialize: initialize, | 66 initialize: initialize, |
112 setRecommendedApps: setRecommendedApps, | |
113 setHotwordEnabled: setHotwordEnabled, | 67 setHotwordEnabled: setHotwordEnabled, |
114 setNaclArch: setNaclArch, | 68 setNaclArch: setNaclArch, |
115 onAppListShown: onAppListShown, | 69 onAppListShown: onAppListShown, |
116 onAppListHidden: onAppListHidden, | 70 onAppListHidden: onAppListHidden, |
117 toggleSpeechRecognition: toggleSpeechRecognition | 71 toggleSpeechRecognition: toggleSpeechRecognition |
118 }; | 72 }; |
119 }); | 73 }); |
120 | 74 |
121 document.addEventListener('contextmenu', function(e) { e.preventDefault(); }); | |
122 document.addEventListener('DOMContentLoaded', appList.startPage.initialize); | 75 document.addEventListener('DOMContentLoaded', appList.startPage.initialize); |
OLD | NEW |