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

Side by Side Diff: chrome/browser/resources/options2/manage_profile_overlay.js

Issue 10579026: Fix edit profile link in NTP (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: docs Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 cr.define('options', function() { 5 cr.define('options', function() {
6 var OptionsPage = options.OptionsPage; 6 var OptionsPage = options.OptionsPage;
7 var ArrayDataModel = cr.ui.ArrayDataModel; 7 var ArrayDataModel = cr.ui.ArrayDataModel;
8 8
9 /** 9 /**
10 * ManageProfileOverlay class 10 * ManageProfileOverlay class
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 self.submitManageChanges_(); 57 self.submitManageChanges_();
58 }; 58 };
59 $('delete-profile-ok').onclick = function(event) { 59 $('delete-profile-ok').onclick = function(event) {
60 OptionsPage.closeOverlay(); 60 OptionsPage.closeOverlay();
61 chrome.send('deleteProfile', [self.profileInfo_.filePath]); 61 chrome.send('deleteProfile', [self.profileInfo_.filePath]);
62 }; 62 };
63 }, 63 },
64 64
65 /** @inheritDoc */ 65 /** @inheritDoc */
66 didShowPage: function() { 66 didShowPage: function() {
67 chrome.send('requestDefaultProfileIcons'); 67 if (!$('manage-profile-icon-grid').dataModel)
68 chrome.send('requestDefaultProfileIcons');
68 69
69 // Use the hash to specify the profile index. 70 // Use the hash to specify the profile index. Note: the actual index
70 var hash = location.hash; 71 // is ignored. Only the current profile may be edited.
71 if (hash) { 72 if (location.hash)
Dan Beam 2012/06/19 23:44:25 window.location.hash.length > 1, IMO, unless you w
Evan Stade 2012/06/20 02:04:31 done
Dan Beam 2012/06/20 02:22:07 we tend to prefix with window (even when it's shad
Evan Stade 2012/06/20 02:24:55 Done.
72 $('manage-profile-overlay-manage').hidden = false; 73 ManageProfileOverlay.getInstance().populateManageDialog_();
73 $('manage-profile-overlay-delete').hidden = true;
74 ManageProfileOverlay.getInstance().hideErrorBubble_();
75
76 chrome.send('requestProfileInfo', [parseInt(hash.slice(1), 10)]);
77 }
78 74
79 $('manage-profile-name').focus(); 75 $('manage-profile-name').focus();
80 }, 76 },
81 77
82 /** 78 /**
83 * Set the profile info used in the dialog. 79 * Set the profile info used in the dialog.
84 * @param {Object} profileInfo An object of the form: 80 * @param {Object} profileInfo An object of the form:
85 * profileInfo = { 81 * profileInfo = {
86 * name: "Profile Name", 82 * name: "Profile Name",
87 * iconURL: "chrome://path/to/icon/image", 83 * iconURL: "chrome://path/to/icon/image",
(...skipping 21 matching lines...) Expand all
109 105
110 /** 106 /**
111 * Set an array of default icon URLs. These will be added to the grid that 107 * Set an array of default icon URLs. These will be added to the grid that
112 * the user will use to choose their profile icon. 108 * the user will use to choose their profile icon.
113 * @param {Array.<string>} iconURLs An array of icon URLs. 109 * @param {Array.<string>} iconURLs An array of icon URLs.
114 * @private 110 * @private
115 */ 111 */
116 receiveDefaultProfileIcons_: function(iconURLs) { 112 receiveDefaultProfileIcons_: function(iconURLs) {
117 $('manage-profile-icon-grid').dataModel = new ArrayDataModel(iconURLs); 113 $('manage-profile-icon-grid').dataModel = new ArrayDataModel(iconURLs);
118 114
119 // Changing the dataModel resets the selectedItem. Re-select it, if there
120 // is one.
121 if (this.profileInfo_) 115 if (this.profileInfo_)
122 $('manage-profile-icon-grid').selectedItem = this.profileInfo_.iconURL; 116 $('manage-profile-icon-grid').selectedItem = this.profileInfo_.iconURL;
123 117
124 var grid = $('manage-profile-icon-grid'); 118 var grid = $('manage-profile-icon-grid');
125 // Recalculate the measured item size. 119 // Recalculate the measured item size.
126 grid.measured_ = null; 120 grid.measured_ = null;
127 grid.columns = 0; 121 grid.columns = 0;
128 grid.redraw(); 122 grid.redraw();
129 }, 123 },
130 124
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 onIconGridSelectionChanged_: function() { 193 onIconGridSelectionChanged_: function() {
200 var iconURL = $('manage-profile-icon-grid').selectedItem; 194 var iconURL = $('manage-profile-icon-grid').selectedItem;
201 if (!iconURL || iconURL == this.iconGridSelectedURL_) 195 if (!iconURL || iconURL == this.iconGridSelectedURL_)
202 return; 196 return;
203 this.iconGridSelectedURL_ = iconURL; 197 this.iconGridSelectedURL_ = iconURL;
204 chrome.send('profileIconSelectionChanged', 198 chrome.send('profileIconSelectionChanged',
205 [this.profileInfo_.filePath, iconURL]); 199 [this.profileInfo_.filePath, iconURL]);
206 }, 200 },
207 201
208 /** 202 /**
203 * Updates the contents of the "Manage Profile" section of the dialog,
204 * and shows that section.
205 * @private
206 */
207 populateManageDialog_: function() {
208 var profileInfo = BrowserOptions.getCurrentProfile();
209 ManageProfileOverlay.setProfileInfo(profileInfo);
210 $('manage-profile-overlay-manage').hidden = false;
211 $('manage-profile-overlay-delete').hidden = true;
Dan Beam 2012/06/19 23:44:25 it would seem that these belong back in the "showi
Evan Stade 2012/06/20 02:04:31 well, it has to be here to work correctly. Would y
Dan Beam 2012/06/20 02:22:07 sure, change to prepareManageDialog_()
Evan Stade 2012/06/20 02:24:55 Done.
212 this.hideErrorBubble_();
213 },
214
215 /**
209 * Display the "Manage Profile" dialog. 216 * Display the "Manage Profile" dialog.
210 * @param {Object} profileInfo The profile object of the profile to manage.
211 * @private 217 * @private
212 */ 218 */
213 showManageDialog_: function(profileInfo) { 219 showManageDialog_: function() {
214 ManageProfileOverlay.setProfileInfo(profileInfo); 220 this.populateManageDialog_();
215 $('manage-profile-overlay-manage').hidden = false;
216 $('manage-profile-overlay-delete').hidden = true;
217 ManageProfileOverlay.getInstance().hideErrorBubble_();
218
219 OptionsPage.navigateToPage('manageProfile'); 221 OptionsPage.navigateToPage('manageProfile');
220 }, 222 },
221 223
222 /** 224 /**
223 * Display the "Delete Profile" dialog. 225 * Display the "Delete Profile" dialog.
224 * @param {Object} profileInfo The profile object of the profile to delete. 226 * @param {Object} profileInfo The profile object of the profile to delete.
225 * @private 227 * @private
226 */ 228 */
227 showDeleteDialog_: function(profileInfo) { 229 showDeleteDialog_: function(profileInfo) {
228 ManageProfileOverlay.setProfileInfo(profileInfo); 230 ManageProfileOverlay.setProfileInfo(profileInfo);
(...skipping 23 matching lines...) Expand all
252 var instance = ManageProfileOverlay.getInstance(); 254 var instance = ManageProfileOverlay.getInstance();
253 return instance[name + '_'].apply(instance, arguments); 255 return instance[name + '_'].apply(instance, arguments);
254 }; 256 };
255 }); 257 });
256 258
257 // Export 259 // Export
258 return { 260 return {
259 ManageProfileOverlay: ManageProfileOverlay 261 ManageProfileOverlay: ManageProfileOverlay
260 }; 262 };
261 }); 263 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698