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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 var name = $('create-profile-name').value; | 78 var name = $('create-profile-name').value; |
79 var icon_url = createIconGrid.selectedItem; | 79 var icon_url = createIconGrid.selectedItem; |
80 chrome.send('createProfile', [name, icon_url]); | 80 chrome.send('createProfile', [name, icon_url]); |
81 }; | 81 }; |
82 }, | 82 }, |
83 | 83 |
84 /** @inheritDoc */ | 84 /** @inheritDoc */ |
85 didShowPage: function() { | 85 didShowPage: function() { |
86 chrome.send('requestDefaultProfileIcons'); | 86 chrome.send('requestDefaultProfileIcons'); |
87 | 87 |
88 if (window.location.pathname == '/manageProfile') | 88 // Use the hash to specify the profile index. Note: the actual index |
| 89 // is ignored. Only the current profile may be edited. |
| 90 if (window.location.hash.length > 1) |
89 ManageProfileOverlay.getInstance().prepareForManageDialog_(); | 91 ManageProfileOverlay.getInstance().prepareForManageDialog_(); |
90 | 92 |
91 $('manage-profile-name').focus(); | 93 $('manage-profile-name').focus(); |
92 $('create-profile-name').focus(); | 94 $('create-profile-name').focus(); |
93 }, | 95 }, |
94 | 96 |
95 /** | 97 /** |
96 * Set the profile info used in the dialog. | 98 * Set the profile info used in the dialog. |
97 * @param {Object} profileInfo An object of the form: | 99 * @param {Object} profileInfo An object of the form: |
98 * profileInfo = { | 100 * profileInfo = { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 */ | 283 */ |
282 showCreateDialog_: function(profileInfo) { | 284 showCreateDialog_: function(profileInfo) { |
283 ManageProfileOverlay.setProfileInfo(profileInfo, 'create'); | 285 ManageProfileOverlay.setProfileInfo(profileInfo, 'create'); |
284 $('manage-profile-overlay-create').hidden = false; | 286 $('manage-profile-overlay-create').hidden = false; |
285 $('manage-profile-overlay-manage').hidden = true; | 287 $('manage-profile-overlay-manage').hidden = true; |
286 $('manage-profile-overlay-delete').hidden = true; | 288 $('manage-profile-overlay-delete').hidden = true; |
287 $('create-profile-instructions').textContent = | 289 $('create-profile-instructions').textContent = |
288 loadTimeData.getStringF('createProfileInstructions'); | 290 loadTimeData.getStringF('createProfileInstructions'); |
289 ManageProfileOverlay.getInstance().hideErrorBubble_('create'); | 291 ManageProfileOverlay.getInstance().hideErrorBubble_('create'); |
290 | 292 |
291 OptionsPage.showPageByName('manageProfile', false); | 293 OptionsPage.navigateToPage('manageProfile'); |
292 }, | 294 }, |
293 | 295 |
294 }; | 296 }; |
295 | 297 |
296 // Forward public APIs to private implementations. | 298 // Forward public APIs to private implementations. |
297 [ | 299 [ |
298 'receiveDefaultProfileIcons', | 300 'receiveDefaultProfileIcons', |
299 'receiveProfileNames', | 301 'receiveProfileNames', |
300 'setProfileInfo', | 302 'setProfileInfo', |
301 'setProfileName', | 303 'setProfileName', |
302 'showManageDialog', | 304 'showManageDialog', |
303 'showDeleteDialog', | 305 'showDeleteDialog', |
304 'showCreateDialog', | 306 'showCreateDialog', |
305 ].forEach(function(name) { | 307 ].forEach(function(name) { |
306 ManageProfileOverlay[name] = function() { | 308 ManageProfileOverlay[name] = function() { |
307 var instance = ManageProfileOverlay.getInstance(); | 309 var instance = ManageProfileOverlay.getInstance(); |
308 return instance[name + '_'].apply(instance, arguments); | 310 return instance[name + '_'].apply(instance, arguments); |
309 }; | 311 }; |
310 }); | 312 }); |
311 | 313 |
312 // Export | 314 // Export |
313 return { | 315 return { |
314 ManageProfileOverlay: ManageProfileOverlay | 316 ManageProfileOverlay: ManageProfileOverlay |
315 }; | 317 }; |
316 }); | 318 }); |
OLD | NEW |