Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 | 6 * @fileoverview |
| 7 * 'settings-manage-profile' is the settings subpage containing controls to | 7 * 'settings-manage-profile' is the settings subpage containing controls to |
| 8 * edit a profile's name, icon, and desktop shortcut. | 8 * edit a profile's name, icon, and desktop shortcut. |
| 9 */ | 9 */ |
| 10 Polymer({ | 10 Polymer({ |
| 11 is: 'settings-manage-profile', | 11 is: 'settings-manage-profile', |
| 12 | 12 |
| 13 behaviors: [WebUIListenerBehavior, settings.RouteObserverBehavior], | 13 behaviors: [WebUIListenerBehavior, settings.RouteObserverBehavior], |
| 14 | 14 |
| 15 properties: { | 15 properties: { |
| 16 /** | 16 /** |
| 17 * The currently selected profile icon URL. May be a data URL. | 17 * The newly selected avatar. Populated only if the user manually changes |
| 18 * the avatar selection. The observer ensures that the changes are | |
| 19 * propagated to the C++. | |
| 18 */ | 20 */ |
| 19 profileIconUrl: String, | 21 profileAvatar: { |
|
tommycli
2017/06/22 21:45:31
Since this property is no longer changed externall
dpapad
2017/06/22 23:22:48
Done.
| |
| 22 type: Object, | |
| 23 observer: 'profileAvatarChanged_', | |
| 24 }, | |
| 20 | 25 |
| 21 /** | 26 /** |
| 22 * The current profile name. | 27 * The current profile name. |
| 23 */ | 28 */ |
| 24 profileName: String, | 29 profileName: String, |
| 25 | 30 |
| 26 /** | 31 /** |
| 27 * True if the current profile has a shortcut. | 32 * True if the current profile has a shortcut. |
| 28 */ | 33 */ |
| 29 hasProfileShortcut_: Boolean, | 34 hasProfileShortcut_: Boolean, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 * @private | 112 * @private |
| 108 */ | 113 */ |
| 109 onProfileNameKeydown_: function(event) { | 114 onProfileNameKeydown_: function(event) { |
| 110 if (event.key == 'Escape') { | 115 if (event.key == 'Escape') { |
| 111 event.target.value = this.profileName; | 116 event.target.value = this.profileName; |
| 112 event.target.blur(); | 117 event.target.blur(); |
| 113 } | 118 } |
| 114 }, | 119 }, |
| 115 | 120 |
| 116 /** | 121 /** |
| 117 * Handler for when an avatar is activated. | 122 * Handler for when the profile avatar is changed by the user. |
| 118 * @param {!Event} event | |
| 119 * @private | 123 * @private |
| 120 */ | 124 */ |
| 121 onIconActivate_: function(event) { | 125 profileAvatarChanged_: function() { |
| 122 // Explicitly test against undefined, because even when an element has the | 126 if (this.profileAvatar.isGaiaAvatar) |
| 123 // data-is-gaia-avatar attribute, dataset.isGaiaAvatar returns an empty | |
| 124 // string, which is falsy. | |
| 125 var isGaiaAvatar = event.detail.item.dataset.isGaiaAvatar !== undefined; | |
| 126 | |
| 127 if (isGaiaAvatar) | |
| 128 this.browserProxy_.setProfileIconToGaiaAvatar(); | 127 this.browserProxy_.setProfileIconToGaiaAvatar(); |
| 129 else | 128 else |
| 130 this.browserProxy_.setProfileIconToDefaultAvatar(event.detail.selected); | 129 this.browserProxy_.setProfileIconToDefaultAvatar(this.profileAvatar.url); |
| 131 }, | 130 }, |
| 132 | 131 |
| 133 /** | 132 /** |
| 134 * @param {?settings.SyncStatus} syncStatus | 133 * @param {?settings.SyncStatus} syncStatus |
| 135 * @return {boolean} Whether the profile name field is disabled. | 134 * @return {boolean} Whether the profile name field is disabled. |
| 136 * @private | 135 * @private |
| 137 */ | 136 */ |
| 138 isProfileNameDisabled_: function(syncStatus) { | 137 isProfileNameDisabled_: function(syncStatus) { |
| 139 return !!syncStatus.supervisedUser && !syncStatus.childUser; | 138 return !!syncStatus.supervisedUser && !syncStatus.childUser; |
| 140 }, | 139 }, |
| 141 | 140 |
| 142 /** | 141 /** |
| 143 * Handler for when the profile shortcut toggle is changed. | 142 * Handler for when the profile shortcut toggle is changed. |
| 144 * @param {!Event} event | 143 * @param {!Event} event |
| 145 * @private | 144 * @private |
| 146 */ | 145 */ |
| 147 onHasProfileShortcutChange_: function(event) { | 146 onHasProfileShortcutChange_: function(event) { |
| 148 if (this.hasProfileShortcut_) { | 147 if (this.hasProfileShortcut_) { |
| 149 this.browserProxy_.addProfileShortcut(); | 148 this.browserProxy_.addProfileShortcut(); |
| 150 } else { | 149 } else { |
| 151 this.browserProxy_.removeProfileShortcut(); | 150 this.browserProxy_.removeProfileShortcut(); |
| 152 } | 151 } |
| 153 } | 152 } |
| 154 }); | 153 }); |
| OLD | NEW |