Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Side by Side Diff: chrome/browser/resources/chromeos/login/apps_menu.js

Issue 2001403003: kiosk: Fix AppsMenu.findAndRunAppForTesting js error (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 Kiosk apps menu implementation. 6 * @fileoverview Kiosk apps menu implementation.
7 */ 7 */
8 8
9 cr.define('login', function() { 9 cr.define('login', function() {
10 'use strict'; 10 'use strict';
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 * Invoked when apps menu becomes visible. 69 * Invoked when apps menu becomes visible.
70 */ 70 */
71 didShow: function() { 71 didShow: function() {
72 window.setTimeout(function() { 72 window.setTimeout(function() {
73 if (!$('apps-header-bar-item').hidden) 73 if (!$('apps-header-bar-item').hidden)
74 chrome.send('checkKioskAppLaunchError'); 74 chrome.send('checkKioskAppLaunchError');
75 }, 500); 75 }, 500);
76 }, 76 },
77 77
78 findAndRunAppForTesting: function(id, opt_diagnostic_mode) { 78 findAndRunAppForTesting: function(id, opt_diagnostic_mode) {
79 this.showMenu(true); 79 for (var i = 0; i < this.data.length; i++) {
80 for (var i = 0; i < this.menu.menuItems.length; i++) { 80 if (this.data[i].id == id) {
81 var menuNode = this.menu.menuItems[i]; 81 this.launchApp_(this.data[i], !!opt_diagnostic_mode);
82 if (menuNode.appId == id) {
83 var activationEvent = cr.doc.createEvent('Event');
84 activationEvent.initEvent('activate', true, true);
85
86 if (opt_diagnostic_mode) {
87 var fakeCtrlEnterEvent = cr.doc.createEvent('KeyboardEvent');
88 fakeCtrlEnterEvent.initKeyboardEvent('keypress', true, true, null,
89 'Enter', 0,
90 true, false, false, false);
91 activationEvent.originalEvent = fakeCtrlEnterEvent;
92 }
93
94 menuNode.dispatchEvent(activationEvent);
95 break; 82 break;
96 } 83 }
97 } 84 }
98 }, 85 },
99 86
100 /** 87 /**
101 * Launch the app. If |diagnosticMode| is true, ask user to confirm. 88 * Launch the app. If |diagnosticMode| is true, ask user to confirm.
102 * @param {Object} app App data. 89 * @param {Object} app App data.
103 * @param {boolean} diagnosticMode Whether to run the app in diagnostic 90 * @param {boolean} diagnosticMode Whether to run the app in diagnostic
104 * mode. 91 * mode.
(...skipping 22 matching lines...) Expand all
127 }, 114 },
128 115
129 /** 116 /**
130 * Adds an app to the menu. 117 * Adds an app to the menu.
131 * @param {Object} app An app info object. 118 * @param {Object} app An app info object.
132 * @private 119 * @private
133 */ 120 */
134 addItem_: function(app) { 121 addItem_: function(app) {
135 var menuItem = this.menu.addMenuItem(app); 122 var menuItem = this.menu.addMenuItem(app);
136 menuItem.classList.add('apps-menu-item'); 123 menuItem.classList.add('apps-menu-item');
137 menuItem.appId = app.id;
138 menuItem.addEventListener('activate', function(e) { 124 menuItem.addEventListener('activate', function(e) {
139 var diagnosticMode = e.originalEvent && e.originalEvent.ctrlKey; 125 var diagnosticMode = e.originalEvent && e.originalEvent.ctrlKey;
140 this.launchApp_(app, diagnosticMode); 126 this.launchApp_(app, diagnosticMode);
141 }.bind(this)); 127 }.bind(this));
142 } 128 }
143 }; 129 };
144 130
145 /** 131 /**
146 * Sets apps to be displayed in the apps menu. 132 * Sets apps to be displayed in the apps menu.
147 * @param {!Array<!Object>} apps An array of app info objects. 133 * @param {!Array<!Object>} apps An array of app info objects.
(...skipping 27 matching lines...) Expand all
175 * mode. Default is false. 161 * mode. Default is false.
176 */ 162 */
177 AppsMenuButton.runAppForTesting = function(id, opt_diagnostic_mode) { 163 AppsMenuButton.runAppForTesting = function(id, opt_diagnostic_mode) {
178 $('show-apps-button').findAndRunAppForTesting(id, opt_diagnostic_mode); 164 $('show-apps-button').findAndRunAppForTesting(id, opt_diagnostic_mode);
179 }; 165 };
180 166
181 return { 167 return {
182 AppsMenuButton: AppsMenuButton 168 AppsMenuButton: AppsMenuButton
183 }; 169 };
184 }); 170 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698