OLD | NEW |
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 chrome.send('requestDefaultProfileIcons'); |
68 | 68 |
69 // Use the hash to specify the profile index. | 69 // Use the hash to specify the profile index. Note: the actual index |
70 var hash = location.hash; | 70 // is ignored. Only the current profile may be edited. |
71 if (hash) { | 71 if (window.location.hash.length > 1) |
72 $('manage-profile-overlay-manage').hidden = false; | 72 ManageProfileOverlay.getInstance().prepareForManageDialog_(); |
73 $('manage-profile-overlay-delete').hidden = true; | |
74 ManageProfileOverlay.getInstance().hideErrorBubble_(); | |
75 | |
76 chrome.send('requestProfileInfo', [parseInt(hash.slice(1), 10)]); | |
77 } | |
78 | 73 |
79 $('manage-profile-name').focus(); | 74 $('manage-profile-name').focus(); |
80 }, | 75 }, |
81 | 76 |
82 /** | 77 /** |
83 * Set the profile info used in the dialog. | 78 * Set the profile info used in the dialog. |
84 * @param {Object} profileInfo An object of the form: | 79 * @param {Object} profileInfo An object of the form: |
85 * profileInfo = { | 80 * profileInfo = { |
86 * name: "Profile Name", | 81 * name: "Profile Name", |
87 * iconURL: "chrome://path/to/icon/image", | 82 * iconURL: "chrome://path/to/icon/image", |
(...skipping 21 matching lines...) Expand all Loading... |
109 | 104 |
110 /** | 105 /** |
111 * Set an array of default icon URLs. These will be added to the grid that | 106 * 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. | 107 * the user will use to choose their profile icon. |
113 * @param {Array.<string>} iconURLs An array of icon URLs. | 108 * @param {Array.<string>} iconURLs An array of icon URLs. |
114 * @private | 109 * @private |
115 */ | 110 */ |
116 receiveDefaultProfileIcons_: function(iconURLs) { | 111 receiveDefaultProfileIcons_: function(iconURLs) { |
117 $('manage-profile-icon-grid').dataModel = new ArrayDataModel(iconURLs); | 112 $('manage-profile-icon-grid').dataModel = new ArrayDataModel(iconURLs); |
118 | 113 |
119 // Changing the dataModel resets the selectedItem. Re-select it, if there | |
120 // is one. | |
121 if (this.profileInfo_) | 114 if (this.profileInfo_) |
122 $('manage-profile-icon-grid').selectedItem = this.profileInfo_.iconURL; | 115 $('manage-profile-icon-grid').selectedItem = this.profileInfo_.iconURL; |
123 | 116 |
124 var grid = $('manage-profile-icon-grid'); | 117 var grid = $('manage-profile-icon-grid'); |
125 // Recalculate the measured item size. | 118 // Recalculate the measured item size. |
126 grid.measured_ = null; | 119 grid.measured_ = null; |
127 grid.columns = 0; | 120 grid.columns = 0; |
128 grid.redraw(); | 121 grid.redraw(); |
129 }, | 122 }, |
130 | 123 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 onIconGridSelectionChanged_: function() { | 192 onIconGridSelectionChanged_: function() { |
200 var iconURL = $('manage-profile-icon-grid').selectedItem; | 193 var iconURL = $('manage-profile-icon-grid').selectedItem; |
201 if (!iconURL || iconURL == this.iconGridSelectedURL_) | 194 if (!iconURL || iconURL == this.iconGridSelectedURL_) |
202 return; | 195 return; |
203 this.iconGridSelectedURL_ = iconURL; | 196 this.iconGridSelectedURL_ = iconURL; |
204 chrome.send('profileIconSelectionChanged', | 197 chrome.send('profileIconSelectionChanged', |
205 [this.profileInfo_.filePath, iconURL]); | 198 [this.profileInfo_.filePath, iconURL]); |
206 }, | 199 }, |
207 | 200 |
208 /** | 201 /** |
| 202 * Updates the contents of the "Manage Profile" section of the dialog, |
| 203 * and shows that section. |
| 204 * @private |
| 205 */ |
| 206 prepareForManageDialog_: function() { |
| 207 var profileInfo = BrowserOptions.getCurrentProfile(); |
| 208 ManageProfileOverlay.setProfileInfo(profileInfo); |
| 209 $('manage-profile-overlay-manage').hidden = false; |
| 210 $('manage-profile-overlay-delete').hidden = true; |
| 211 this.hideErrorBubble_(); |
| 212 }, |
| 213 |
| 214 /** |
209 * Display the "Manage Profile" dialog. | 215 * Display the "Manage Profile" dialog. |
210 * @param {Object} profileInfo The profile object of the profile to manage. | |
211 * @private | 216 * @private |
212 */ | 217 */ |
213 showManageDialog_: function(profileInfo) { | 218 showManageDialog_: function() { |
214 ManageProfileOverlay.setProfileInfo(profileInfo); | 219 this.prepareForManageDialog_(); |
215 $('manage-profile-overlay-manage').hidden = false; | |
216 $('manage-profile-overlay-delete').hidden = true; | |
217 ManageProfileOverlay.getInstance().hideErrorBubble_(); | |
218 | |
219 OptionsPage.navigateToPage('manageProfile'); | 220 OptionsPage.navigateToPage('manageProfile'); |
220 }, | 221 }, |
221 | 222 |
222 /** | 223 /** |
223 * Display the "Delete Profile" dialog. | 224 * Display the "Delete Profile" dialog. |
224 * @param {Object} profileInfo The profile object of the profile to delete. | 225 * @param {Object} profileInfo The profile object of the profile to delete. |
225 * @private | 226 * @private |
226 */ | 227 */ |
227 showDeleteDialog_: function(profileInfo) { | 228 showDeleteDialog_: function(profileInfo) { |
228 ManageProfileOverlay.setProfileInfo(profileInfo); | 229 ManageProfileOverlay.setProfileInfo(profileInfo); |
(...skipping 23 matching lines...) Expand all Loading... |
252 var instance = ManageProfileOverlay.getInstance(); | 253 var instance = ManageProfileOverlay.getInstance(); |
253 return instance[name + '_'].apply(instance, arguments); | 254 return instance[name + '_'].apply(instance, arguments); |
254 }; | 255 }; |
255 }); | 256 }); |
256 | 257 |
257 // Export | 258 // Export |
258 return { | 259 return { |
259 ManageProfileOverlay: ManageProfileOverlay | 260 ManageProfileOverlay: ManageProfileOverlay |
260 }; | 261 }; |
261 }); | 262 }); |
OLD | NEW |