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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 profilesList.autoExpands = true; | 230 profilesList.autoExpands = true; |
231 | 231 |
232 this.setProfilesInfo_(loadTimeData.getValue('profilesInfo')); | 232 this.setProfilesInfo_(loadTimeData.getValue('profilesInfo')); |
233 | 233 |
234 profilesList.addEventListener('change', | 234 profilesList.addEventListener('change', |
235 this.setProfileViewButtonsStatus_); | 235 this.setProfileViewButtonsStatus_); |
236 $('profiles-create').onclick = function(event) { | 236 $('profiles-create').onclick = function(event) { |
237 chrome.send('createProfile'); | 237 chrome.send('createProfile'); |
238 }; | 238 }; |
239 $('profiles-manage').onclick = function(event) { | 239 $('profiles-manage').onclick = function(event) { |
240 var selectedProfile = self.getSelectedProfileItem_(); | 240 ManageProfileOverlay.showManageDialog(); |
241 if (selectedProfile) | |
242 ManageProfileOverlay.showManageDialog(selectedProfile); | |
243 }; | 241 }; |
244 $('profiles-delete').onclick = function(event) { | 242 $('profiles-delete').onclick = function(event) { |
245 var selectedProfile = self.getSelectedProfileItem_(); | 243 var selectedProfile = self.getSelectedProfileItem_(); |
246 if (selectedProfile) | 244 if (selectedProfile) |
247 ManageProfileOverlay.showDeleteDialog(selectedProfile); | 245 ManageProfileOverlay.showDeleteDialog(selectedProfile); |
248 }; | 246 }; |
249 } | 247 } |
250 | 248 |
251 if (cr.isChromeOS) { | 249 if (cr.isChromeOS) { |
252 if (!UIAccountTweaks.loggedInAsGuest()) { | 250 if (!UIAccountTweaks.loggedInAsGuest()) { |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
996 * @param {Array.<Object>} profiles An array of profile info objects. | 994 * @param {Array.<Object>} profiles An array of profile info objects. |
997 * each object is of the form: | 995 * each object is of the form: |
998 * profileInfo = { | 996 * profileInfo = { |
999 * name: "Profile Name", | 997 * name: "Profile Name", |
1000 * iconURL: "chrome://path/to/icon/image", | 998 * iconURL: "chrome://path/to/icon/image", |
1001 * filePath: "/path/to/profile/data/on/disk", | 999 * filePath: "/path/to/profile/data/on/disk", |
1002 * isCurrentProfile: false | 1000 * isCurrentProfile: false |
1003 * }; | 1001 * }; |
1004 * @private | 1002 * @private |
1005 */ | 1003 */ |
1006 setProfilesInfo_: function(profiles) { | 1004 setProfilesInfo_: function(profiles) { |
Dan Beam
2012/06/19 23:44:25
if |profiles| can be null, handle this
Evan Stade
2012/06/20 02:04:31
shouldn't be possible.
| |
1007 this.setProfileViewSingle_(profiles.length); | 1005 this.setProfileViewSingle_(profiles.length); |
1008 // add it to the list, even if the list is hidden so we can access it | 1006 // add it to the list, even if the list is hidden so we can access it |
1009 // later. | 1007 // later. |
1010 $('profiles-list').dataModel = new ArrayDataModel(profiles); | 1008 $('profiles-list').dataModel = new ArrayDataModel(profiles); |
1011 // We got new data, close the open overlay if it's open. | 1009 |
1012 ManageProfileOverlay.getInstance().visible = false; | 1010 // We got new data. If we are showing the "manage" overlay, keep it up to |
Dan Beam
2012/06/19 23:44:25
we use "we" three times, here. are we going to cha
Evan Stade
2012/06/20 02:04:31
Done.
| |
1011 // date. If we are showing the "delete" overlay, close it. | |
1012 if (ManageProfileOverlay.getInstance().visible && | |
1013 !$('manage-profile-overlay-manage').hidden) { | |
1014 ManageProfileOverlay.showManageDialog(); | |
1015 } else { | |
1016 ManageProfileOverlay.getInstance().visible = false; | |
1017 } | |
1018 | |
1013 this.setProfileViewButtonsStatus_(); | 1019 this.setProfileViewButtonsStatus_(); |
1014 }, | 1020 }, |
1015 | 1021 |
1022 /** | |
1023 * Returns the currently active profile for this browser window. | |
1024 * @return {Object} A profile info object. | |
Dan Beam
2012/06/19 23:44:25
{?Object} unless you really can't return null.
| |
1025 * @private | |
1026 */ | |
1027 getCurrentProfile_: function() { | |
1028 for (var i = 0; i < $('profiles-list').dataModel.length; i++) { | |
1029 if ($('profiles-list').dataModel.item(i).isCurrentProfile) | |
Dan Beam
2012/06/19 23:44:25
var profile = $('profiles-list').dataModel.item(i)
Evan Stade
2012/06/20 02:04:31
Done.
| |
1030 return $('profiles-list').dataModel.item(i); | |
1031 } | |
1032 | |
1033 return null; | |
Dan Beam
2012/06/19 23:44:25
assert(false, "couldn't find a default profile");
Evan Stade
2012/06/20 02:04:31
it's not default, it's current.
done.
Dan Beam
2012/06/20 02:22:07
sorry, yeah, one was right, :)
| |
1034 }, | |
1035 | |
1016 setGtkThemeButtonEnabled_: function(enabled) { | 1036 setGtkThemeButtonEnabled_: function(enabled) { |
1017 if (!cr.isChromeOS && navigator.platform.match(/linux|BSD/i)) | 1037 if (!cr.isChromeOS && navigator.platform.match(/linux|BSD/i)) |
1018 $('themes-GTK-button').disabled = !enabled; | 1038 $('themes-GTK-button').disabled = !enabled; |
1019 }, | 1039 }, |
1020 | 1040 |
1021 setThemesResetButtonEnabled_: function(enabled) { | 1041 setThemesResetButtonEnabled_: function(enabled) { |
1022 $('themes-reset').disabled = !enabled; | 1042 $('themes-reset').disabled = !enabled; |
1023 }, | 1043 }, |
1024 | 1044 |
1025 /** | 1045 /** |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1352 setContentFilterSettingsValue_: function(dict) { | 1372 setContentFilterSettingsValue_: function(dict) { |
1353 if ('cookies' in dict && 'value' in dict['cookies']) | 1373 if ('cookies' in dict && 'value' in dict['cookies']) |
1354 this.sessionOnlyCookies_ = dict['cookies']['value'] == 'session'; | 1374 this.sessionOnlyCookies_ = dict['cookies']['value'] == 'session'; |
1355 } | 1375 } |
1356 | 1376 |
1357 }; | 1377 }; |
1358 | 1378 |
1359 //Forward public APIs to private implementations. | 1379 //Forward public APIs to private implementations. |
1360 [ | 1380 [ |
1361 'addBluetoothDevice', | 1381 'addBluetoothDevice', |
1382 'getCurrentProfile', | |
1362 'getStartStopSyncButton', | 1383 'getStartStopSyncButton', |
1363 'hideBluetoothSettings', | 1384 'hideBluetoothSettings', |
1364 'removeCloudPrintConnectorSection', | 1385 'removeCloudPrintConnectorSection', |
1365 'removeBluetoothDevice', | 1386 'removeBluetoothDevice', |
1366 'setAutoOpenFileTypesDisplayed', | 1387 'setAutoOpenFileTypesDisplayed', |
1367 'setBackgroundModeCheckboxState', | 1388 'setBackgroundModeCheckboxState', |
1368 'setBluetoothState', | 1389 'setBluetoothState', |
1369 'setCheckRevocationCheckboxState', | 1390 'setCheckRevocationCheckboxState', |
1370 'setContentFilterSettingsValue', | 1391 'setContentFilterSettingsValue', |
1371 'setFontSize', | 1392 'setFontSize', |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1408 BrowserOptions.getLoggedInUsername = function() { | 1429 BrowserOptions.getLoggedInUsername = function() { |
1409 return BrowserOptions.getInstance().username_; | 1430 return BrowserOptions.getInstance().username_; |
1410 }; | 1431 }; |
1411 } | 1432 } |
1412 | 1433 |
1413 // Export | 1434 // Export |
1414 return { | 1435 return { |
1415 BrowserOptions: BrowserOptions | 1436 BrowserOptions: BrowserOptions |
1416 }; | 1437 }; |
1417 }); | 1438 }); |
OLD | NEW |