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