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 currently selected profile icon URL. May be a data URL. |
| 18 */ | 18 */ |
| 19 profileIconUrl: String, | 19 profileIconUrl: String, |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * The current profile name. | 22 * The current profile name. |
| 23 */ | 23 */ |
| 24 profileName: String, | 24 profileName: String, |
| 25 | 25 |
| 26 /** | 26 /** |
| 27 * True if the current profile has a shortcut. | |
| 28 */ | |
| 29 hasProfileShortcut_: Boolean, | |
| 30 | |
| 31 /** | |
| 27 * The available icons for selection. | 32 * The available icons for selection. |
| 28 * @type {!Array<string>} | 33 * @type {!Array<string>} |
| 29 */ | 34 */ |
| 30 availableIcons: { | 35 availableIcons: { |
| 31 type: Array, | 36 type: Array, |
| 32 value: function() { return []; }, | 37 value: function() { return []; }, |
| 33 }, | 38 }, |
| 34 | 39 |
| 35 /** | 40 /** |
| 36 * The current sync status. | 41 * The current sync status. |
| 37 * @type {?settings.SyncStatus} | 42 * @type {?settings.SyncStatus} |
| 38 */ | 43 */ |
| 39 syncStatus: Object, | 44 syncStatus: Object, |
| 40 | 45 |
| 41 /** | 46 /** |
| 42 * @private {!settings.ManageProfileBrowserProxy} | 47 * @private {!settings.ManageProfileBrowserProxy} |
| 43 */ | 48 */ |
| 44 browserProxy_: { | 49 browserProxy_: { |
| 45 type: Object, | 50 type: Object, |
| 46 value: function() { | 51 value: function() { |
| 47 return settings.ManageProfileBrowserProxyImpl.getInstance(); | 52 return settings.ManageProfileBrowserProxyImpl.getInstance(); |
| 48 }, | 53 }, |
| 49 }, | 54 }, |
| 55 | |
| 56 /** | |
| 57 * True if the profile shortcuts feature is enabled. | |
| 58 * @private | |
| 59 */ | |
| 60 isProfileShortcutsEnabled_: { | |
| 61 type: Boolean, | |
| 62 value: function() { | |
| 63 return loadTimeData.getBoolean('profileShortcutsEnabled'); | |
| 64 }, | |
| 65 readOnly: true, | |
| 66 }, | |
| 50 }, | 67 }, |
| 51 | 68 |
| 52 /** @override */ | 69 /** @override */ |
| 53 attached: function() { | 70 attached: function() { |
| 54 var setIcons = function(icons) { | 71 var setIcons = function(icons) { |
| 55 this.availableIcons = icons; | 72 this.availableIcons = icons; |
| 56 }.bind(this); | 73 }.bind(this); |
| 57 | 74 |
| 58 this.addWebUIListener('available-icons-changed', setIcons); | 75 this.addWebUIListener('available-icons-changed', setIcons); |
| 59 this.browserProxy_.getAvailableIcons().then(setIcons); | 76 this.browserProxy_.getAvailableIcons().then(setIcons); |
| 60 }, | 77 }, |
| 61 | 78 |
| 62 /** @protected */ | 79 /** @protected */ |
| 63 currentRouteChanged: function() { | 80 currentRouteChanged: function() { |
| 64 if (settings.getCurrentRoute() == settings.Route.MANAGE_PROFILE) | 81 if (settings.getCurrentRoute() == settings.Route.MANAGE_PROFILE) { |
| 65 this.$.name.value = this.profileName; | 82 this.$.name.value = this.profileName; |
| 83 | |
| 84 if (this.isProfileShortcutsEnabled_) { | |
| 85 var setHasProfileShortcut = function(hasProfileShortcut) { | |
| 86 this.hasProfileShortcut_ = hasProfileShortcut; | |
| 87 }.bind(this); | |
| 88 this.browserProxy_.hasProfileShortcut().then(setHasProfileShortcut); | |
| 89 } | |
| 90 } | |
|
tommycli
2016/11/15 01:59:50
It looks like the UI state won't be synchronized a
Moe
2016/11/15 16:03:10
I doesn't seem to be synced in the old settings pa
tommycli
2016/11/15 16:18:37
We're "good". hehe. That being said, I think it's
| |
| 66 }, | 91 }, |
| 67 | 92 |
| 68 /** | 93 /** |
| 69 * Handler for when the profile name field is changed, then blurred. | 94 * Handler for when the profile name field is changed, then blurred. |
| 70 * @private | 95 * @private |
| 71 * @param {!Event} event | 96 * @param {!Event} event |
| 72 */ | 97 */ |
| 73 onProfileNameChanged_: function(event) { | 98 onProfileNameChanged_: function(event) { |
| 74 if (event.target.invalid) | 99 if (event.target.invalid) |
| 75 return; | 100 return; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 89 }, | 114 }, |
| 90 | 115 |
| 91 /** | 116 /** |
| 92 * @param {?settings.SyncStatus} syncStatus | 117 * @param {?settings.SyncStatus} syncStatus |
| 93 * @return {boolean} Whether the profile name field is disabled. | 118 * @return {boolean} Whether the profile name field is disabled. |
| 94 * @private | 119 * @private |
| 95 */ | 120 */ |
| 96 isProfileNameDisabled_: function(syncStatus) { | 121 isProfileNameDisabled_: function(syncStatus) { |
| 97 return !!syncStatus.supervisedUser && !syncStatus.childUser; | 122 return !!syncStatus.supervisedUser && !syncStatus.childUser; |
| 98 }, | 123 }, |
| 124 | |
| 125 /** | |
| 126 * Handler for when the profile shortcut toggle is changed. | |
| 127 * @param {!Event} event | |
| 128 * @private | |
| 129 */ | |
| 130 onHasProfileShortcutChange_: function(event) { | |
| 131 if (this.hasProfileShortcut_) { | |
| 132 this.browserProxy_.addProfileShortcut(); | |
| 133 } else { | |
| 134 this.browserProxy_.removeProfileShortcut(); | |
| 135 } | |
| 136 } | |
| 99 }); | 137 }); |
| OLD | NEW |