Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: chrome/browser/resources/settings/people_page/manage_profile.js

Issue 2068713003: Refactors profile avatar selector into a Polymer element to use in md-settings & md-user-manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comment Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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], 13 behaviors: [WebUIListenerBehavior],
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 * The available icons for selection. 27 * The available icons for selection.
28 * @type {!Array<string>} 28 * @type {!Array<string>}
29 */ 29 */
30 availableIconUrls: { 30 availableIcons: {
31 type: Array, 31 type: Array,
32 value: function() { return []; }, 32 value: function() { return []; },
33 }, 33 },
34 34
35 /** 35 /**
36 * @private {!settings.ManageProfileBrowserProxyImpl} 36 * @private {!settings.ManageProfileBrowserProxyImpl}
37 */ 37 */
38 browserProxy_: { 38 browserProxy_: {
39 type: Object, 39 type: Object,
40 value: function() { 40 value: function() {
41 return settings.ManageProfileBrowserProxyImpl.getInstance(); 41 return settings.ManageProfileBrowserProxyImpl.getInstance();
42 }, 42 },
43 }, 43 },
44 }, 44 },
45 45
46 /** @override */ 46 /** @override */
47 attached: function() { 47 attached: function() {
48 var setIcons = function(iconUrls) { 48 var setIcons = function(icons) {
49 this.availableIconUrls = iconUrls; 49 this.availableIcons = icons;
50 }.bind(this); 50 }.bind(this);
51 51
52 this.addWebUIListener('available-icons-changed', setIcons); 52 this.addWebUIListener('available-icons-changed', setIcons);
53 this.browserProxy_.getAvailableIcons().then(setIcons); 53 this.browserProxy_.getAvailableIcons().then(setIcons);
54 }, 54 },
55 55
56 /** 56 /**
57 * Handler for when the profile name field is changed, then blurred. 57 * Handler for when the profile name field is changed, then blurred.
58 * @private 58 * @private
59 * @param {!Event} event 59 * @param {!Event} event
60 */ 60 */
61 onProfileNameChanged_: function(event) { 61 onProfileNameChanged_: function(event) {
62 if (event.target.invalid) 62 if (event.target.invalid)
63 return; 63 return;
64 64
65 this.browserProxy_.setProfileIconAndName(this.profileIconUrl, 65 this.browserProxy_.setProfileIconAndName(this.profileIconUrl,
66 event.target.value); 66 event.target.value);
67 }, 67 },
68 68
69 /** 69 /**
70 * Handler for when the an image is activated. 70 * Handler for when an avatar is activated.
71 * @param {!Event} event 71 * @param {!Event} event
72 * @private 72 * @private
73 */ 73 */
74 onIconActivate_: function(event) { 74 onIconActivate_: function(event) {
75 /** @type {{iconUrl: string}} */ 75 this.browserProxy_.setProfileIconAndName(event.detail.selected,
76 var buttonData = event.detail.item.dataset;
77 this.browserProxy_.setProfileIconAndName(buttonData.iconUrl,
78 this.profileName); 76 this.profileName);
79 }, 77 },
80 }); 78 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698