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

Unified Diff: chrome/browser/resources/user_chooser/user_chooser.js

Issue 16104008: First try at a user management screen for the desktop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clean up JS code Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/user_chooser/user_chooser.js
diff --git a/chrome/browser/resources/user_chooser/user_chooser.js b/chrome/browser/resources/user_chooser/user_chooser.js
new file mode 100644
index 0000000000000000000000000000000000000000..33b8090ef4515124d170321a0549313cb454bb97
--- /dev/null
+++ b/chrome/browser/resources/user_chooser/user_chooser.js
@@ -0,0 +1,59 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
Nikita (slow) 2013/06/11 18:43:28 nit: 2013
noms 2013/06/12 20:41:54 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+<include src="user_chooser_common.js"></include>
Nikita (slow) 2013/06/11 18:43:28 Please move this include to html.
+
+cr.define('UserChooser', function() {
+ 'use strict';
+
+ /**
+ * Setups given "select" element using the list and adds callback.
+ * @param {!Element} select Select object to be updated.
+ * @param {!Object} list List of the options to be added.
+ * @param {string} callback Callback name which should be send to Chrome or
+ * an empty string if the event listener shouldn't be added.
+ */
+ function setupSelect(select, list, callback) {
Nikita (slow) 2013/06/11 18:43:28 Where is setupSelect used? That looks like dead co
noms 2013/06/12 20:41:54 Done.
+ select.options.length = 0;
+ for (var i = 0; i < list.length; ++i) {
+ var item = list[i];
+ var option =
+ new Option(item.title, item.value, item.selected, item.selected);
+ select.appendChild(option);
+ }
+ if (callback) {
+ var sendCallback = function() {
+ chrome.send(callback, [select.options[select.selectedIndex].value]);
+ };
+ select.addEventListener('blur', sendCallback);
+ select.addEventListener('click', sendCallback);
+ select.addEventListener('keyup', function(event) {
+ var keycodeInterested = [
+ 9, // Tab
+ 13, // Enter
+ 27, // Escape
+ ];
+ if (keycodeInterested.indexOf(event.keyCode) >= 0)
+ sendCallback();
+ });
+ }
+ }
+
+ function initialize() {
+ login.AccountPickerScreen.register();
+ login.GaiaSigninScreen.register();
Nikita (slow) 2013/06/11 18:43:28 Are you planning on using the same GaiaSigninScree
noms 2013/06/12 20:41:54 Probably not. There's still discussions on what we
+
+ cr.ui.Bubble.decorate($('bubble'));
+ login.HeaderBar.decorate($('login-header-bar'));
+
+ chrome.send('userChooserInitialize');
+ }
+
+ // Return an object with all of the exports.
+ return {
+ initialize: initialize,
+ setupSelect: setupSelect
+ };
+});
+
+document.addEventListener('DOMContentLoaded', UserChooser.initialize);

Powered by Google App Engine
This is Rietveld 408576698