[sql] Remove _HAS_EXCEPTIONS=0 from build info.
[chromium-blink-merge.git] / chrome / browser / resources / print_preview / data / user_info.js
blob0d7ade2238d1b97127e710c703eff293b71d984c
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
3 // found in the LICENSE file.
5 cr.define('print_preview', function() {
6 'use strict';
8 /**
9 * Repository which stores information about the user. Events are dispatched
10 * when the information changes.
11 * @constructor
12 * @extends {cr.EventTarget}
14 function UserInfo() {
15 cr.EventTarget.call(this);
17 /**
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.
20 * @private {?string}
22 this.activeUser_ = null;
24 /**
25 * Email addresses of the logged in users or empty array if no user is
26 * logged in. {@code null} if not known yet.
27 * @private {?Array<string>}
29 this.users_ = null;
32 /**
33 * Enumeration of event types dispatched by the user info.
34 * @enum {string}
36 UserInfo.EventType = {
37 ACTIVE_USER_CHANGED: 'print_preview.UserInfo.ACTIVE_USER_CHANGED',
38 USERS_CHANGED: 'print_preview.UserInfo.USERS_CHANGED'
41 UserInfo.prototype = {
42 __proto__: cr.EventTarget.prototype,
44 /** @return {boolean} Whether user accounts are already retrieved. */
45 get initialized() {
46 return this.users_ != null;
49 /** @return {boolean} Whether user is logged in or not. */
50 get loggedIn() {
51 return !!this.activeUser;
54 /**
55 * @return {?string} Email address of the logged in user or {@code null} if
56 * no user is logged.
58 get activeUser() {
59 return this.activeUser_;
62 /** Changes active user. */
63 set activeUser(activeUser) {
64 if (this.activeUser_ != activeUser) {
65 this.activeUser_ = activeUser;
66 cr.dispatchSimpleEvent(this, UserInfo.EventType.ACTIVE_USER_CHANGED);
70 /**
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.
74 get users() {
75 return this.users_;
78 /**
79 * Sets logged in user accounts info.
80 * @param {string} activeUser Active user account (email).
81 * @param {!Array<string>} users List of currently logged in accounts.
83 setUsers: function(activeUser, users) {
84 this.activeUser_ = activeUser;
85 this.users_ = users || [];
86 cr.dispatchSimpleEvent(this, UserInfo.EventType.USERS_CHANGED);
90 return {
91 UserInfo: UserInfo
93 });