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

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

Issue 1536593004: Settings People Revamp: Implement Chrome Profile name/icon selection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix gn build Created 4 years, 12 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
(Empty)
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
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview
7 * 'settings-manage-profile' is the settings subpage containing controls to
8 * edit a profile's name, icon, and desktop shortcut.
9 *
10 * @group Chrome Settings Elements
11 * @element settings-manage-profile
12 */
13 Polymer({
14 is: 'settings-manage-profile',
15
16 properties: {
17 /**
18 * The currently selected profile icon URL. May be a data URL.
19 */
20 profileIconUrl: String,
21
22 /**
23 * The current profile name.
24 */
25 profileName: String,
26
27 /**
28 * The available icons for selection. Populated by SyncPrivateApi.
29 * @type {!Array<!string>}
30 */
31 availableIconUrls: {
32 type: Array,
33 value: function() { return []; },
34 },
35 },
36
37 /** @override */
38 created: function() {
39 settings.SyncPrivateApi.getAvailableIcons(
40 this.handleAvailableIcons_.bind(this));
41 },
42
43 /**
44 * Handler for when the available icons are pushed from SyncPrivateApi.
dschuyler 2015/12/22 18:47:48 @param
tommycli 2015/12/22 21:58:32 Done.
45 * @private
46 */
47 handleAvailableIcons_: function(iconUrls) {
48 this.availableIconUrls = iconUrls;
49 },
50
51 /**
52 * Handler for when the profile name field is changed, then blurred.
dschuyler 2015/12/22 18:47:48 @param
tommycli 2015/12/22 21:58:32 Done.
53 * @private
54 */
55 onProfileNameChanged_: function(event) {
56 settings.SyncPrivateApi.setProfileIconAndName(this.profileIconUrl,
57 event.target.value);
58 },
59
60 /**
61 * Handler for when the user clicks a new profile icon.
dschuyler 2015/12/22 18:47:48 @param
tommycli 2015/12/22 21:58:32 Done.
62 * @private
dschuyler 2015/12/22 18:47:48 @return {boolean}
tommycli 2015/12/22 21:58:32 Done.
63 */
64 onIconTap_: function(event) {
65 var element = Polymer.dom(event).rootTarget;
66 var newIconURL = element.nodeName == 'IMG' ? element.src :
67 element.dataset.iconUrl;
68
69 settings.SyncPrivateApi.setProfileIconAndName(newIconURL, this.profileName);
70
71 // Button toggle state is controlled by the selected icon URL. Prevent
72 // tap events from changing the toggle state.
73 return false;
74 },
75
76 /**
77 * Computed binding determining which profile icon button is toggled on.
dschuyler 2015/12/22 18:47:48 @param, @param
tommycli 2015/12/22 21:58:33 Done.
78 * @private
dschuyler 2015/12/22 18:47:48 return type
tommycli 2015/12/22 21:58:33 Done.
79 */
80 isActiveIcon_: function(iconURL, profileIconUrl) {
81 return iconURL == profileIconUrl;
82 },
83 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698