| 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('switchAppListProfile', [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 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 var selectedProfile = profilesList.selectedItem; | 918 var selectedProfile = profilesList.selectedItem; |
| 913 var hasSelection = selectedProfile != null; | 919 var hasSelection = selectedProfile != null; |
| 914 var hasSingleProfile = profilesList.dataModel.length == 1; | 920 var hasSingleProfile = profilesList.dataModel.length == 1; |
| 915 $('profiles-manage').disabled = !hasSelection || | 921 $('profiles-manage').disabled = !hasSelection || |
| 916 !selectedProfile.isCurrentProfile; | 922 !selectedProfile.isCurrentProfile; |
| 917 if (hasSelection && !selectedProfile.isCurrentProfile) | 923 if (hasSelection && !selectedProfile.isCurrentProfile) |
| 918 $('profiles-manage').title = loadTimeData.getString('currentUserOnly'); | 924 $('profiles-manage').title = loadTimeData.getString('currentUserOnly'); |
| 919 else | 925 else |
| 920 $('profiles-manage').title = ''; | 926 $('profiles-manage').title = ''; |
| 921 $('profiles-delete').disabled = !hasSelection && !hasSingleProfile; | 927 $('profiles-delete').disabled = !hasSelection && !hasSingleProfile; |
| 928 if (OptionsPage.isSettingsApp()) { |
| 929 $('profiles-app-list-switch').disabled = !hasSelection || |
| 930 selectedProfile.isCurrentProfile; |
| 931 } |
| 922 var importData = $('import-data'); | 932 var importData = $('import-data'); |
| 923 if (importData) { | 933 if (importData) { |
| 924 importData.disabled = $('import-data').disabled = hasSelection && | 934 importData.disabled = $('import-data').disabled = hasSelection && |
| 925 !selectedProfile.isCurrentProfile; | 935 !selectedProfile.isCurrentProfile; |
| 926 } | 936 } |
| 927 }, | 937 }, |
| 928 | 938 |
| 929 /** | 939 /** |
| 930 * Display the correct dialog layout, depending on how many profiles are | 940 * Display the correct dialog layout, depending on how many profiles are |
| 931 * available. | 941 * available. |
| 932 * @param {number} numProfiles The number of profiles to display. | 942 * @param {number} numProfiles The number of profiles to display. |
| 933 * @private | 943 * @private |
| 934 */ | 944 */ |
| 935 setProfileViewSingle_: function(numProfiles) { | 945 setProfileViewSingle_: function(numProfiles) { |
| 936 var hasSingleProfile = numProfiles == 1; | 946 var hasSingleProfile = numProfiles == 1; |
| 937 $('profiles-list').hidden = hasSingleProfile; | 947 $('profiles-list').hidden = hasSingleProfile; |
| 938 $('profiles-single-message').hidden = !hasSingleProfile; | 948 $('profiles-single-message').hidden = !hasSingleProfile; |
| 939 $('profiles-manage').hidden = hasSingleProfile; | 949 $('profiles-manage').hidden = hasSingleProfile; |
| 940 $('profiles-delete').textContent = hasSingleProfile ? | 950 $('profiles-delete').textContent = hasSingleProfile ? |
| 941 loadTimeData.getString('profilesDeleteSingle') : | 951 loadTimeData.getString('profilesDeleteSingle') : |
| 942 loadTimeData.getString('profilesDelete'); | 952 loadTimeData.getString('profilesDelete'); |
| 953 if (OptionsPage.isSettingsApp()) |
| 954 $('profiles-app-list-switch').hidden = hasSingleProfile; |
| 943 }, | 955 }, |
| 944 | 956 |
| 945 /** | 957 /** |
| 946 * Adds all |profiles| to the list. | 958 * Adds all |profiles| to the list. |
| 947 * @param {Array.<Object>} profiles An array of profile info objects. | 959 * @param {Array.<Object>} profiles An array of profile info objects. |
| 948 * each object is of the form: | 960 * each object is of the form: |
| 949 * profileInfo = { | 961 * profileInfo = { |
| 950 * name: "Profile Name", | 962 * name: "Profile Name", |
| 951 * iconURL: "chrome://path/to/icon/image", | 963 * iconURL: "chrome://path/to/icon/image", |
| 952 * filePath: "/path/to/profile/data/on/disk", | 964 * filePath: "/path/to/profile/data/on/disk", |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 BrowserOptions.getLoggedInUsername = function() { | 1378 BrowserOptions.getLoggedInUsername = function() { |
| 1367 return BrowserOptions.getInstance().username_; | 1379 return BrowserOptions.getInstance().username_; |
| 1368 }; | 1380 }; |
| 1369 } | 1381 } |
| 1370 | 1382 |
| 1371 // Export | 1383 // Export |
| 1372 return { | 1384 return { |
| 1373 BrowserOptions: BrowserOptions | 1385 BrowserOptions: BrowserOptions |
| 1374 }; | 1386 }; |
| 1375 }); | 1387 }); |
| OLD | NEW |