| 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 'create-profile' is a page that contains controls for creating | 6 * @fileoverview 'create-profile' is a page that contains controls for creating |
| 7 * a (optionally supervised) profile, including choosing a name, and an avatar. | 7 * a (optionally supervised) profile, including choosing a name, and an avatar. |
| 8 */ | 8 */ |
| 9 (function() { | 9 (function() { |
| 10 /** | 10 /** |
| 11 * It means the sentinel menu item is selected. | 11 * Sentinel signed-in user's index value. |
| 12 * @const {number} | 12 * @const {number} |
| 13 */ | 13 */ |
| 14 var NO_USER_SELECTED = -1; | 14 var NO_USER_SELECTED = -1; |
| 15 | 15 |
| 16 Polymer({ | 16 Polymer({ |
| 17 is: 'create-profile', | 17 is: 'create-profile', |
| 18 | 18 |
| 19 behaviors: [ | 19 behaviors: [ |
| 20 I18nBehavior, | 20 I18nBehavior, |
| 21 WebUIListenerBehavior | 21 WebUIListenerBehavior |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 /** | 88 /** |
| 89 * Index of the selected signed-in user. | 89 * Index of the selected signed-in user. |
| 90 * @private {number} | 90 * @private {number} |
| 91 */ | 91 */ |
| 92 signedInUserIndex_: { | 92 signedInUserIndex_: { |
| 93 type: Number, | 93 type: Number, |
| 94 value: NO_USER_SELECTED | 94 value: NO_USER_SELECTED |
| 95 }, | 95 }, |
| 96 | 96 |
| 97 /** |
| 98 * Sentinel signed-in user's index value. |
| 99 * @private {number} |
| 100 */ |
| 101 sentinelSignedInUserIndex_: { |
| 102 type: Number, |
| 103 value: NO_USER_SELECTED, |
| 104 readOnly: true |
| 105 }, |
| 106 |
| 97 /** @private {!signin.ProfileBrowserProxy} */ | 107 /** @private {!signin.ProfileBrowserProxy} */ |
| 98 browserProxy_: Object | 108 browserProxy_: Object |
| 99 }, | 109 }, |
| 100 | 110 |
| 101 listeners: { | 111 listeners: { |
| 102 'tap': 'onTap_', | 112 'tap': 'onTap_', |
| 103 'importUserPopup.import': 'onImportUserPopupImport_' | 113 'importUserPopup.import': 'onImportUserPopupImport_' |
| 104 }, | 114 }, |
| 105 | 115 |
| 106 /** @override */ | 116 /** @override */ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 118 'create-profile-error', this.handleMessage_.bind(this)); | 128 'create-profile-error', this.handleMessage_.bind(this)); |
| 119 this.addWebUIListener( | 129 this.addWebUIListener( |
| 120 'profile-icons-received', this.handleProfileIcons_.bind(this)); | 130 'profile-icons-received', this.handleProfileIcons_.bind(this)); |
| 121 this.addWebUIListener( | 131 this.addWebUIListener( |
| 122 'profile-defaults-received', this.handleProfileDefaults_.bind(this)); | 132 'profile-defaults-received', this.handleProfileDefaults_.bind(this)); |
| 123 this.addWebUIListener( | 133 this.addWebUIListener( |
| 124 'signedin-users-received', this.handleSignedInUsers_.bind(this)); | 134 'signedin-users-received', this.handleSignedInUsers_.bind(this)); |
| 125 | 135 |
| 126 this.browserProxy_.getAvailableIcons(); | 136 this.browserProxy_.getAvailableIcons(); |
| 127 this.browserProxy_.getSignedInUsers(); | 137 this.browserProxy_.getSignedInUsers(); |
| 128 | |
| 129 // Alias on 'this' to use in html. | |
| 130 this.NO_USER_SELECTED = NO_USER_SELECTED; | |
| 131 }, | 138 }, |
| 132 | 139 |
| 133 /** | 140 /** |
| 134 * Handles tap events from dynamically created links in warning/error messages | 141 * Handles tap events from: |
| 135 * pushed by the browser. | 142 * - links within dynamic warning/error messages pushed from the browser. |
| 143 * - the 'noSignedInUserMessage' i18n string. |
| 136 * @param {!Event} event | 144 * @param {!Event} event |
| 137 * @private | 145 * @private |
| 138 */ | 146 */ |
| 139 onTap_: function(event) { | 147 onTap_: function(event) { |
| 140 var element = Polymer.dom(event).rootTarget; | 148 var element = Polymer.dom(event).rootTarget; |
| 141 | 149 |
| 142 if (element.id == 'supervised-user-import-existing') { | 150 if (element.id == 'supervised-user-import-existing') { |
| 143 this.onImportUserTap_(event); | 151 this.onImportUserTap_(event); |
| 144 event.preventDefault(); | 152 event.preventDefault(); |
| 153 } else if (element.id == 'sign-in-to-chrome') { |
| 154 this.browserProxy_.openUrlInLastActiveProfileBrowser(element.href); |
| 155 event.preventDefault(); |
| 145 } | 156 } |
| 146 // TODO(mahmadi): handle tap event on '#reauth' to re-auth the custodian. | 157 // TODO(mahmadi): handle tap event on '#reauth' to re-auth the custodian. |
| 147 }, | 158 }, |
| 148 | 159 |
| 149 /** | 160 /** |
| 150 * Handler for when the profile icons are pushed from the browser. | 161 * Handler for when the profile icons are pushed from the browser. |
| 151 * @param {!Array<string>} iconUrls | 162 * @param {!Array<string>} iconUrls |
| 152 * @private | 163 * @private |
| 153 */ | 164 */ |
| 154 handleProfileIcons_: function(iconUrls) { | 165 handleProfileIcons_: function(iconUrls) { |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 * Computed binding that returns True if there are any signed-in users. | 423 * Computed binding that returns True if there are any signed-in users. |
| 413 * @param {!Array<!SignedInUser>} signedInUsers signed-in users. | 424 * @param {!Array<!SignedInUser>} signedInUsers signed-in users. |
| 414 * @return {boolean} | 425 * @return {boolean} |
| 415 * @private | 426 * @private |
| 416 */ | 427 */ |
| 417 isSignedIn_: function(signedInUsers) { | 428 isSignedIn_: function(signedInUsers) { |
| 418 return signedInUsers.length > 0; | 429 return signedInUsers.length > 0; |
| 419 } | 430 } |
| 420 }); | 431 }); |
| 421 }()); | 432 }()); |
| OLD | NEW |