| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 const localStrings = new LocalStrings(); | 9 const localStrings = new LocalStrings(); |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 self.submitManageChanges_(); | 54 self.submitManageChanges_(); |
| 55 }; | 55 }; |
| 56 $('delete-profile-ok').onclick = function(event) { | 56 $('delete-profile-ok').onclick = function(event) { |
| 57 OptionsPage.closeOverlay(); | 57 OptionsPage.closeOverlay(); |
| 58 chrome.send('deleteProfile', [self.profileInfo_.filePath]); | 58 chrome.send('deleteProfile', [self.profileInfo_.filePath]); |
| 59 }; | 59 }; |
| 60 }, | 60 }, |
| 61 | 61 |
| 62 /** @inheritDoc */ | 62 /** @inheritDoc */ |
| 63 didShowPage: function() { | 63 didShowPage: function() { |
| 64 var grid = $('manage-profile-icon-grid'); | 64 chrome.send('requestDefaultProfileIcons'); |
| 65 // Recalculate the measured item size. | 65 |
| 66 grid.measured_ = null; | 66 // Use the hash to specify the profile index. |
| 67 grid.columns = 0; | 67 var hash = location.hash; |
| 68 grid.redraw(); | 68 if (hash) { |
| 69 $('manage-profile-overlay-manage').hidden = false; |
| 70 $('manage-profile-overlay-delete').hidden = true; |
| 71 ManageProfileOverlay.getInstance().hideErrorBubble_(); |
| 72 |
| 73 chrome.send('requestProfileInfo', [parseInt(hash.slice(1), 10)]); |
| 74 } |
| 69 | 75 |
| 70 $('manage-profile-name').focus(); | 76 $('manage-profile-name').focus(); |
| 71 }, | 77 }, |
| 72 | 78 |
| 73 /** | 79 /** |
| 74 * Set the profile info used in the dialog. | 80 * Set the profile info used in the dialog. |
| 75 * @param {Object} profileInfo An object of the form: | 81 * @param {Object} profileInfo An object of the form: |
| 76 * profileInfo = { | 82 * profileInfo = { |
| 77 * name: "Profile Name", | 83 * name: "Profile Name", |
| 78 * iconURL: "chrome://path/to/icon/image", | 84 * iconURL: "chrome://path/to/icon/image", |
| 79 * filePath: "/path/to/profile/data/on/disk" | 85 * filePath: "/path/to/profile/data/on/disk" |
| 80 * isCurrentProfile: false, | 86 * isCurrentProfile: false, |
| 81 * }; | 87 * }; |
| 82 * @private | 88 * @private |
| 83 */ | 89 */ |
| 84 setProfileInfo_: function(profileInfo) { | 90 setProfileInfo_: function(profileInfo) { |
| 85 this.profileInfo_ = profileInfo; | 91 this.profileInfo_ = profileInfo; |
| 86 $('manage-profile-name').value = profileInfo.name; | 92 $('manage-profile-name').value = profileInfo.name; |
| 87 $('manage-profile-icon-grid').selectedItem = profileInfo.iconURL; | 93 $('manage-profile-icon-grid').selectedItem = profileInfo.iconURL; |
| 88 }, | 94 }, |
| 89 | 95 |
| 90 /** | 96 /** |
| 91 * Set an array of default icon URLs. These will be added to the grid that | 97 * Set an array of default icon URLs. These will be added to the grid that |
| 92 * the user will use to choose their profile icon. | 98 * the user will use to choose their profile icon. |
| 93 * @param {Array.<string>} iconURLs An array of icon URLs. | 99 * @param {Array.<string>} iconURLs An array of icon URLs. |
| 94 * @private | 100 * @private |
| 95 */ | 101 */ |
| 96 receiveDefaultProfileIcons_: function(iconURLs) { | 102 receiveDefaultProfileIcons_: function(iconURLs) { |
| 97 $('manage-profile-icon-grid').dataModel = new ArrayDataModel(iconURLs); | 103 $('manage-profile-icon-grid').dataModel = new ArrayDataModel(iconURLs); |
| 104 |
| 105 var grid = $('manage-profile-icon-grid'); |
| 106 // Recalculate the measured item size. |
| 107 grid.measured_ = null; |
| 108 grid.columns = 0; |
| 109 grid.redraw(); |
| 98 }, | 110 }, |
| 99 | 111 |
| 100 /** | 112 /** |
| 101 * Set a dictionary of all profile names. These are used to prevent the | 113 * Set a dictionary of all profile names. These are used to prevent the |
| 102 * user from naming two profiles the same. | 114 * user from naming two profiles the same. |
| 103 * @param {Object} profileNames A dictionary of profile names. | 115 * @param {Object} profileNames A dictionary of profile names. |
| 104 * @private | 116 * @private |
| 105 */ | 117 */ |
| 106 receiveProfileNames_: function(profileNames) { | 118 receiveProfileNames_: function(profileNames) { |
| 107 this.profileNames_ = profileNames; | 119 this.profileNames_ = profileNames; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 ManageProfileOverlay[name] = function(value) { | 218 ManageProfileOverlay[name] = function(value) { |
| 207 ManageProfileOverlay.getInstance()[name + '_'](value); | 219 ManageProfileOverlay.getInstance()[name + '_'](value); |
| 208 }; | 220 }; |
| 209 }); | 221 }); |
| 210 | 222 |
| 211 // Export | 223 // Export |
| 212 return { | 224 return { |
| 213 ManageProfileOverlay: ManageProfileOverlay | 225 ManageProfileOverlay: ManageProfileOverlay |
| 214 }; | 226 }; |
| 215 }); | 227 }); |
| OLD | NEW |