| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 'control-bar' is the horizontal bar at the bottom of the user | 6 * @fileoverview 'control-bar' is the horizontal bar at the bottom of the user |
| 7 * manager screen. | 7 * manager screen. |
| 8 */ | 8 */ |
| 9 Polymer({ | 9 Polymer({ |
| 10 is: 'control-bar', | 10 is: 'control-bar', |
| 11 | 11 |
| 12 behaviors: [ | 12 behaviors: [ |
| 13 I18nBehavior, | 13 I18nBehavior, |
| 14 ], | 14 ], |
| 15 | 15 |
| 16 properties: { | 16 properties: { |
| 17 /** | 17 /** |
| 18 * True if 'Browse as Guest' button is displayed. | 18 * True if 'Browse as Guest' button is displayed. |
| 19 * @type {boolean} | 19 * @type {boolean} |
| 20 */ | 20 */ |
| 21 showGuest: { | 21 showGuest: {type: Boolean, value: false}, |
| 22 type: Boolean, | |
| 23 value: false | |
| 24 }, | |
| 25 | 22 |
| 26 /** | 23 /** |
| 27 * True if 'Add Person' button is displayed. | 24 * True if 'Add Person' button is displayed. |
| 28 * @type {boolean} | 25 * @type {boolean} |
| 29 */ | 26 */ |
| 30 showAddPerson: { | 27 showAddPerson: {type: Boolean, value: false}, |
| 31 type: Boolean, | |
| 32 value: false | |
| 33 }, | |
| 34 | 28 |
| 35 /** @private {!signin.ProfileBrowserProxy} */ | 29 /** @private {!signin.ProfileBrowserProxy} */ |
| 36 browserProxy_: Object, | 30 browserProxy_: Object, |
| 37 | 31 |
| 38 /** | 32 /** |
| 39 * True if the force sign in policy is enabled. | 33 * True if the force sign in policy is enabled. |
| 40 * @private {boolean} | 34 * @private {boolean} |
| 41 */ | 35 */ |
| 42 isForceSigninEnabled_: { | 36 isForceSigninEnabled_: { |
| 43 type: Boolean, | 37 type: Boolean, |
| 44 value: function() { | 38 value: function() { |
| 45 return loadTimeData.getBoolean('isForceSigninEnabled'); | 39 return loadTimeData.getBoolean('isForceSigninEnabled'); |
| 46 }, | 40 }, |
| 47 } | 41 } |
| 48 }, | 42 }, |
| 49 | 43 |
| 50 /** @override */ | 44 /** @override */ |
| 51 created: function() { | 45 created: function() { |
| 52 this.browserProxy_ = signin.ProfileBrowserProxyImpl.getInstance(); | 46 this.browserProxy_ = signin.ProfileBrowserProxyImpl.getInstance(); |
| 53 }, | 47 }, |
| 54 | 48 |
| 55 /** | 49 /** |
| 56 * Handler for 'Browse as Guest' button click event. | 50 * Handler for 'Browse as Guest' button click event. |
| 57 * @param {!Event} event | 51 * @param {!Event} event |
| 58 * @private | 52 * @private |
| 59 */ | 53 */ |
| 60 onLaunchGuestTap_: function(event) { | 54 onLaunchGuestTap_: function(event) { |
| 61 this.browserProxy_.areAllProfilesLocked().then( | 55 this.browserProxy_.areAllProfilesLocked().then(function(allProfilesLocked) { |
| 62 function(allProfilesLocked) { | 56 if (!allProfilesLocked || this.isForceSigninEnabled_) { |
| 63 if (!allProfilesLocked || this.isForceSigninEnabled_) { | 57 this.browserProxy_.launchGuestUser(); |
| 64 this.browserProxy_.launchGuestUser(); | 58 } else { |
| 65 } else { | 59 document.querySelector('error-dialog') |
| 66 document.querySelector('error-dialog').show( | 60 .show(this.i18n('browseAsGuestAllProfilesLockedError')); |
| 67 this.i18n('browseAsGuestAllProfilesLockedError')); | 61 } |
| 68 } | 62 }.bind(this)); |
| 69 }.bind(this)); | |
| 70 }, | 63 }, |
| 71 | 64 |
| 72 /** | 65 /** |
| 73 * Handler for 'Add Person' button click event. | 66 * Handler for 'Add Person' button click event. |
| 74 * @param {!Event} event | 67 * @param {!Event} event |
| 75 * @private | 68 * @private |
| 76 */ | 69 */ |
| 77 onAddUserTap_: function(event) { | 70 onAddUserTap_: function(event) { |
| 78 this.browserProxy_.areAllProfilesLocked().then( | 71 this.browserProxy_.areAllProfilesLocked().then(function(allProfilesLocked) { |
| 79 function(allProfilesLocked) { | 72 if (!allProfilesLocked || this.isForceSigninEnabled_) { |
| 80 if (!allProfilesLocked || this.isForceSigninEnabled_) { | 73 // Event is caught by user-manager-pages. |
| 81 // Event is caught by user-manager-pages. | 74 this.fire('change-page', {page: 'create-user-page'}); |
| 82 this.fire('change-page', {page: 'create-user-page'}); | 75 } else { |
| 83 } else { | 76 document.querySelector('error-dialog') |
| 84 document.querySelector('error-dialog').show( | 77 .show(this.i18n('addProfileAllProfilesLockedError')); |
| 85 this.i18n('addProfileAllProfilesLockedError')); | 78 } |
| 86 } | 79 }.bind(this)); |
| 87 }.bind(this)); | |
| 88 } | 80 } |
| 89 }); | 81 }); |
| OLD | NEW |