| 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 var RepeatingButton = cr.ui.RepeatingButton; | 8 var RepeatingButton = cr.ui.RepeatingButton; |
| 9 | 9 |
| 10 // | 10 // |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 options.browser_options.ProfileList.decorate(profilesList); | 173 options.browser_options.ProfileList.decorate(profilesList); |
| 174 profilesList.autoExpands = true; | 174 profilesList.autoExpands = true; |
| 175 | 175 |
| 176 this.setProfilesInfo_(loadTimeData.getValue('profilesInfo')); | 176 this.setProfilesInfo_(loadTimeData.getValue('profilesInfo')); |
| 177 | 177 |
| 178 profilesList.addEventListener('change', | 178 profilesList.addEventListener('change', |
| 179 this.setProfileViewButtonsStatus_); | 179 this.setProfileViewButtonsStatus_); |
| 180 $('profiles-create').onclick = function(event) { | 180 $('profiles-create').onclick = function(event) { |
| 181 ManageProfileOverlay.showCreateDialog(); | 181 ManageProfileOverlay.showCreateDialog(); |
| 182 }; | 182 }; |
| 183 if (OptionsPage.isSettingsApp()) { |
| 184 $('profiles-app-list-switch').onclick = function(event) { |
| 185 var selectedProfile = self.getSelectedProfileItem_(); |
| 186 chrome.send('profilesAppListSwitch', [selectedProfile.filePath]); |
| 187 }; |
| 188 } |
| 183 $('profiles-manage').onclick = function(event) { | 189 $('profiles-manage').onclick = function(event) { |
| 184 ManageProfileOverlay.showManageDialog(); | 190 ManageProfileOverlay.showManageDialog(); |
| 185 }; | 191 }; |
| 186 $('profiles-delete').onclick = function(event) { | 192 $('profiles-delete').onclick = function(event) { |
| 187 var selectedProfile = self.getSelectedProfileItem_(); | 193 var selectedProfile = self.getSelectedProfileItem_(); |
| 188 if (selectedProfile) | 194 if (selectedProfile) |
| 189 ManageProfileOverlay.showDeleteDialog(selectedProfile); | 195 ManageProfileOverlay.showDeleteDialog(selectedProfile); |
| 190 }; | 196 }; |
| 191 } | 197 } |
| 192 | 198 |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 var selectedProfile = profilesList.selectedItem; | 907 var selectedProfile = profilesList.selectedItem; |
| 902 var hasSelection = selectedProfile != null; | 908 var hasSelection = selectedProfile != null; |
| 903 var hasSingleProfile = profilesList.dataModel.length == 1; | 909 var hasSingleProfile = profilesList.dataModel.length == 1; |
| 904 $('profiles-manage').disabled = !hasSelection || | 910 $('profiles-manage').disabled = !hasSelection || |
| 905 !selectedProfile.isCurrentProfile; | 911 !selectedProfile.isCurrentProfile; |
| 906 if (hasSelection && !selectedProfile.isCurrentProfile) | 912 if (hasSelection && !selectedProfile.isCurrentProfile) |
| 907 $('profiles-manage').title = loadTimeData.getString('currentUserOnly'); | 913 $('profiles-manage').title = loadTimeData.getString('currentUserOnly'); |
| 908 else | 914 else |
| 909 $('profiles-manage').title = ''; | 915 $('profiles-manage').title = ''; |
| 910 $('profiles-delete').disabled = !hasSelection && !hasSingleProfile; | 916 $('profiles-delete').disabled = !hasSelection && !hasSingleProfile; |
| 917 if (OptionsPage.isSettingsApp()) { |
| 918 $('profiles-app-list-switch').disabled = !hasSelection || |
| 919 selectedProfile.isCurrentProfile; |
| 920 } |
| 911 var importData = $('import-data'); | 921 var importData = $('import-data'); |
| 912 if (importData) { | 922 if (importData) { |
| 913 importData.disabled = $('import-data').disabled = hasSelection && | 923 importData.disabled = $('import-data').disabled = hasSelection && |
| 914 !selectedProfile.isCurrentProfile; | 924 !selectedProfile.isCurrentProfile; |
| 915 } | 925 } |
| 916 }, | 926 }, |
| 917 | 927 |
| 918 /** | 928 /** |
| 919 * Display the correct dialog layout, depending on how many profiles are | 929 * Display the correct dialog layout, depending on how many profiles are |
| 920 * available. | 930 * available. |
| 921 * @param {number} numProfiles The number of profiles to display. | 931 * @param {number} numProfiles The number of profiles to display. |
| 922 * @private | 932 * @private |
| 923 */ | 933 */ |
| 924 setProfileViewSingle_: function(numProfiles) { | 934 setProfileViewSingle_: function(numProfiles) { |
| 925 var hasSingleProfile = numProfiles == 1; | 935 var hasSingleProfile = numProfiles == 1; |
| 926 $('profiles-list').hidden = hasSingleProfile; | 936 $('profiles-list').hidden = hasSingleProfile; |
| 927 $('profiles-single-message').hidden = !hasSingleProfile; | 937 $('profiles-single-message').hidden = !hasSingleProfile; |
| 928 $('profiles-manage').hidden = hasSingleProfile; | 938 $('profiles-manage').hidden = hasSingleProfile; |
| 929 $('profiles-delete').textContent = hasSingleProfile ? | 939 $('profiles-delete').textContent = hasSingleProfile ? |
| 930 loadTimeData.getString('profilesDeleteSingle') : | 940 loadTimeData.getString('profilesDeleteSingle') : |
| 931 loadTimeData.getString('profilesDelete'); | 941 loadTimeData.getString('profilesDelete'); |
| 942 if (OptionsPage.isSettingsApp()) |
| 943 $('profiles-app-list-switch').hidden = hasSingleProfile; |
| 932 }, | 944 }, |
| 933 | 945 |
| 934 /** | 946 /** |
| 935 * Adds all |profiles| to the list. | 947 * Adds all |profiles| to the list. |
| 936 * @param {Array.<Object>} profiles An array of profile info objects. | 948 * @param {Array.<Object>} profiles An array of profile info objects. |
| 937 * each object is of the form: | 949 * each object is of the form: |
| 938 * profileInfo = { | 950 * profileInfo = { |
| 939 * name: "Profile Name", | 951 * name: "Profile Name", |
| 940 * iconURL: "chrome://path/to/icon/image", | 952 * iconURL: "chrome://path/to/icon/image", |
| 941 * filePath: "/path/to/profile/data/on/disk", | 953 * filePath: "/path/to/profile/data/on/disk", |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 BrowserOptions.getLoggedInUsername = function() { | 1367 BrowserOptions.getLoggedInUsername = function() { |
| 1356 return BrowserOptions.getInstance().username_; | 1368 return BrowserOptions.getInstance().username_; |
| 1357 }; | 1369 }; |
| 1358 } | 1370 } |
| 1359 | 1371 |
| 1360 // Export | 1372 // Export |
| 1361 return { | 1373 return { |
| 1362 BrowserOptions: BrowserOptions | 1374 BrowserOptions: BrowserOptions |
| 1363 }; | 1375 }; |
| 1364 }); | 1376 }); |
| OLD | NEW |