| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 cr.define('print_preview', function() { | 5 cr.define('print_preview', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Repository which stores information about the user. Events are dispatched | 9 * Repository which stores information about the user. Events are dispatched |
| 10 * when the information changes. | 10 * when the information changes. |
| 11 * @constructor | 11 * @constructor |
| 12 * @extends {cr.EventTarget} | 12 * @extends {cr.EventTarget} |
| 13 */ | 13 */ |
| 14 function UserInfo() { | 14 function UserInfo() { |
| 15 cr.EventTarget.call(this); | 15 cr.EventTarget.call(this); |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * Email address of the logged in user or {@code null} if no user is logged | 18 * Email address of the logged in user or {@code null} if no user is logged |
| 19 * in. In case of Google multilogin, can be changed by the user. | 19 * in. In case of Google multilogin, can be changed by the user. |
| 20 * @private {?string} | 20 * @private {?string} |
| 21 */ | 21 */ |
| 22 this.activeUser_ = null; | 22 this.activeUser_ = null; |
| 23 | 23 |
| 24 /** | 24 /** |
| 25 * Email addresses of the logged in users or empty array if no user is | 25 * Email addresses of the logged in users or empty array if no user is |
| 26 * logged in. {@code null} if not known yet. | 26 * logged in. {@code null} if not known yet. |
| 27 * @private {?Array.<string>} | 27 * @private {?Array<string>} |
| 28 */ | 28 */ |
| 29 this.users_ = null; | 29 this.users_ = null; |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 /** | 32 /** |
| 33 * Enumeration of event types dispatched by the user info. | 33 * Enumeration of event types dispatched by the user info. |
| 34 * @enum {string} | 34 * @enum {string} |
| 35 */ | 35 */ |
| 36 UserInfo.EventType = { | 36 UserInfo.EventType = { |
| 37 ACTIVE_USER_CHANGED: 'print_preview.UserInfo.ACTIVE_USER_CHANGED', | 37 ACTIVE_USER_CHANGED: 'print_preview.UserInfo.ACTIVE_USER_CHANGED', |
| (...skipping 23 matching lines...) Expand all Loading... |
| 61 | 61 |
| 62 /** Changes active user. */ | 62 /** Changes active user. */ |
| 63 set activeUser(activeUser) { | 63 set activeUser(activeUser) { |
| 64 if (this.activeUser_ != activeUser) { | 64 if (this.activeUser_ != activeUser) { |
| 65 this.activeUser_ = activeUser; | 65 this.activeUser_ = activeUser; |
| 66 cr.dispatchSimpleEvent(this, UserInfo.EventType.ACTIVE_USER_CHANGED); | 66 cr.dispatchSimpleEvent(this, UserInfo.EventType.ACTIVE_USER_CHANGED); |
| 67 } | 67 } |
| 68 }, | 68 }, |
| 69 | 69 |
| 70 /** | 70 /** |
| 71 * @return {?Array.<string>} Email addresses of the logged in users or | 71 * @return {?Array<string>} Email addresses of the logged in users or |
| 72 * empty array if no user is logged in. {@code null} if not known yet. | 72 * empty array if no user is logged in. {@code null} if not known yet. |
| 73 */ | 73 */ |
| 74 get users() { | 74 get users() { |
| 75 return this.users_; | 75 return this.users_; |
| 76 }, | 76 }, |
| 77 | 77 |
| 78 /** | 78 /** |
| 79 * Sets logged in user accounts info. | 79 * Sets logged in user accounts info. |
| 80 * @param {string} activeUser Active user account (email). | 80 * @param {string} activeUser Active user account (email). |
| 81 * @param {!Array.<string>} users List of currently logged in accounts. | 81 * @param {!Array<string>} users List of currently logged in accounts. |
| 82 */ | 82 */ |
| 83 setUsers: function(activeUser, users) { | 83 setUsers: function(activeUser, users) { |
| 84 this.activeUser_ = activeUser; | 84 this.activeUser_ = activeUser; |
| 85 this.users_ = users || []; | 85 this.users_ = users || []; |
| 86 cr.dispatchSimpleEvent(this, UserInfo.EventType.USERS_CHANGED); | 86 cr.dispatchSimpleEvent(this, UserInfo.EventType.USERS_CHANGED); |
| 87 }, | 87 }, |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 return { | 90 return { |
| 91 UserInfo: UserInfo | 91 UserInfo: UserInfo |
| 92 }; | 92 }; |
| 93 }); | 93 }); |
| OLD | NEW |