Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Side by Side Diff: chrome/browser/resources/options2/browser_options.js

Issue 10391044: retry 136193 - convert localStrings to loadTimeData for options page (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: plugins, ui_account_tweaks fixes Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 //
11 // BrowserOptions class 11 // BrowserOptions class
12 // Encapsulated handling of browser options page. 12 // Encapsulated handling of browser options page.
13 // 13 //
14 function BrowserOptions() { 14 function BrowserOptions() {
15 OptionsPage.call(this, 'settings', templateData.settingsTitle, 15 OptionsPage.call(this, 'settings', loadTimeData.getString('settingsTitle'),
16 'settings'); 16 'settings');
17 } 17 }
18 18
19 cr.addSingletonGetter(BrowserOptions); 19 cr.addSingletonGetter(BrowserOptions);
20 20
21 BrowserOptions.prototype = { 21 BrowserOptions.prototype = {
22 __proto__: options.OptionsPage.prototype, 22 __proto__: options.OptionsPage.prototype,
23 23
24 // State variables. 24 // State variables.
25 syncSetupCompleted: false, 25 syncSetupCompleted: false,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 $('advanced-settings'), 78 $('advanced-settings'),
79 $('advanced-settings-container')); 79 $('advanced-settings-container'));
80 } 80 }
81 $('advanced-settings').addEventListener('webkitTransitionEnd', 81 $('advanced-settings').addEventListener('webkitTransitionEnd',
82 this.updateAdvancedSettingsExpander_.bind(this)); 82 this.updateAdvancedSettingsExpander_.bind(this));
83 83
84 if (cr.isChromeOS) 84 if (cr.isChromeOS)
85 UIAccountTweaks.applyGuestModeVisibility(document); 85 UIAccountTweaks.applyGuestModeVisibility(document);
86 86
87 // Sync (Sign in) section. 87 // Sync (Sign in) section.
88 this.updateSyncState_(templateData.syncData); 88 this.updateSyncState_(loadTimeData.getValue('syncData'));
89 89
90 $('sync-action-link').onclick = function(event) { 90 $('sync-action-link').onclick = function(event) {
91 SyncSetupOverlay.showErrorUI(); 91 SyncSetupOverlay.showErrorUI();
92 }; 92 };
93 $('start-stop-sync').onclick = function(event) { 93 $('start-stop-sync').onclick = function(event) {
94 if (self.syncSetupCompleted) 94 if (self.syncSetupCompleted)
95 SyncSetupOverlay.showStopSyncingUI(); 95 SyncSetupOverlay.showStopSyncingUI();
96 else 96 else
97 SyncSetupOverlay.showSetupUI(); 97 SyncSetupOverlay.showSetupUI();
98 }; 98 };
(...skipping 12 matching lines...) Expand all
111 111
112 $('startup-set-pages').onclick = function() { 112 $('startup-set-pages').onclick = function() {
113 OptionsPage.navigateToPage('startup'); 113 OptionsPage.navigateToPage('startup');
114 }; 114 };
115 115
116 // Session restore. 116 // Session restore.
117 // TODO(marja): clean up the options UI after the decision on the session 117 // TODO(marja): clean up the options UI after the decision on the session
118 // restore changes has stabilized. For now, only the startup option is 118 // restore changes has stabilized. For now, only the startup option is
119 // renamed to "continue where I left off", but the session related content 119 // renamed to "continue where I left off", but the session related content
120 // settings are not disabled or overridden (because 120 // settings are not disabled or overridden (because
121 // templateData.enable_restore_session_state is forced to false). 121 // 'enable_restore_session_state' is forced to false).
122 this.sessionRestoreEnabled_ = templateData.enable_restore_session_state; 122 this.sessionRestoreEnabled_ =
123 loadTimeData.getBoolean('enable_restore_session_state');
123 if (this.sessionRestoreEnabled_) { 124 if (this.sessionRestoreEnabled_) {
124 $('startup-restore-session').onclick = function(event) { 125 $('startup-restore-session').onclick = function(event) {
125 if (!event.currentTarget.checked) 126 if (!event.currentTarget.checked)
126 return; 127 return;
127 128
128 if (!BrowserOptions.getInstance().maybeShowSessionRestoreDialog_()) { 129 if (!BrowserOptions.getInstance().maybeShowSessionRestoreDialog_()) {
129 // The dialog is not shown; handle the event normally. 130 // The dialog is not shown; handle the event normally.
130 event.currentTarget.savePrefState(); 131 event.currentTarget.savePrefState();
131 } 132 }
132 }; 133 };
(...skipping 12 matching lines...) Expand all
145 OptionsPage.navigateToPage('homePageOverlay'); 146 OptionsPage.navigateToPage('homePageOverlay');
146 }; 147 };
147 148
148 if ($('set-wallpaper')) { 149 if ($('set-wallpaper')) {
149 $('set-wallpaper').onclick = function(event) { 150 $('set-wallpaper').onclick = function(event) {
150 OptionsPage.navigateToPage('setWallpaper'); 151 OptionsPage.navigateToPage('setWallpaper');
151 }; 152 };
152 } 153 }
153 154
154 $('themes-gallery').onclick = function(event) { 155 $('themes-gallery').onclick = function(event) {
155 window.open(localStrings.getString('themesGalleryURL')); 156 window.open(loadTimeData.getString('themesGalleryURL'));
156 }; 157 };
157 $('themes-reset').onclick = function(event) { 158 $('themes-reset').onclick = function(event) {
158 chrome.send('themesReset'); 159 chrome.send('themesReset');
159 }; 160 };
160 161
161 // Device section (ChromeOS only). 162 // Device section (ChromeOS only).
162 if (cr.isChromeOS) { 163 if (cr.isChromeOS) {
163 $('keyboard-settings-button').onclick = function(evt) { 164 $('keyboard-settings-button').onclick = function(evt) {
164 OptionsPage.navigateToPage('keyboard-overlay'); 165 OptionsPage.navigateToPage('keyboard-overlay');
165 }; 166 };
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 var self = this; 202 var self = this;
202 Preferences.getInstance().addEventListener( 203 Preferences.getInstance().addEventListener(
203 'profile.clear_site_data_on_exit', 204 'profile.clear_site_data_on_exit',
204 function(event) { 205 function(event) {
205 if (event.value && typeof event.value['value'] != 'undefined') { 206 if (event.value && typeof event.value['value'] != 'undefined') {
206 self.clearCookiesOnExit_ = event.value['value'] == true; 207 self.clearCookiesOnExit_ = event.value['value'] == true;
207 } 208 }
208 }); 209 });
209 210
210 // Users section. 211 // Users section.
211 if (typeof templateData.profilesInfo != 'undefined') { 212 if (loadTimeData.valueExists('profilesInfo')) {
212 $('profiles-section').hidden = false; 213 $('profiles-section').hidden = false;
213 214
214 var profilesList = $('profiles-list'); 215 var profilesList = $('profiles-list');
215 options.browser_options.ProfileList.decorate(profilesList); 216 options.browser_options.ProfileList.decorate(profilesList);
216 profilesList.autoExpands = true; 217 profilesList.autoExpands = true;
217 218
218 this.setProfilesInfo_(templateData.profilesInfo); 219 this.setProfilesInfo_(loadTimeData.getValue('profilesInfo'));
219 220
220 profilesList.addEventListener('change', 221 profilesList.addEventListener('change',
221 this.setProfileViewButtonsStatus_); 222 this.setProfileViewButtonsStatus_);
222 $('profiles-create').onclick = function(event) { 223 $('profiles-create').onclick = function(event) {
223 chrome.send('createProfile'); 224 chrome.send('createProfile');
224 }; 225 };
225 $('profiles-manage').onclick = function(event) { 226 $('profiles-manage').onclick = function(event) {
226 var selectedProfile = self.getSelectedProfileItem_(); 227 var selectedProfile = self.getSelectedProfileItem_();
227 if (selectedProfile) 228 if (selectedProfile)
228 ManageProfileOverlay.showManageDialog(selectedProfile); 229 ManageProfileOverlay.showManageDialog(selectedProfile);
229 }; 230 };
230 $('profiles-delete').onclick = function(event) { 231 $('profiles-delete').onclick = function(event) {
231 var selectedProfile = self.getSelectedProfileItem_(); 232 var selectedProfile = self.getSelectedProfileItem_();
232 if (selectedProfile) 233 if (selectedProfile)
233 ManageProfileOverlay.showDeleteDialog(selectedProfile); 234 ManageProfileOverlay.showDeleteDialog(selectedProfile);
234 }; 235 };
235 } 236 }
236 237
237 if (cr.isChromeOS) { 238 if (cr.isChromeOS) {
238 if (!UIAccountTweaks.loggedInAsGuest()) { 239 if (!UIAccountTweaks.loggedInAsGuest()) {
239 $('account-picture-wrapper').onclick = function(event) { 240 $('account-picture-wrapper').onclick = function(event) {
240 OptionsPage.navigateToPage('changePicture'); 241 OptionsPage.navigateToPage('changePicture');
241 }; 242 };
242 } 243 }
243 244
244 // Username (canonical email) of the currently logged in user or 245 // Username (canonical email) of the currently logged in user or
245 // |kGuestUser| if a guest session is active. 246 // |kGuestUser| if a guest session is active.
246 this.username_ = localStrings.getString('username'); 247 this.username_ = loadTimeData.getString('username');
247 248
248 this.updateAccountPicture_(); 249 this.updateAccountPicture_();
249 250
250 $('manage-accounts-button').onclick = function(event) { 251 $('manage-accounts-button').onclick = function(event) {
251 OptionsPage.navigateToPage('accounts'); 252 OptionsPage.navigateToPage('accounts');
252 chrome.send('coreOptionsUserMetricsAction', 253 chrome.send('coreOptionsUserMetricsAction',
253 ['Options_ManageAccounts']); 254 ['Options_ManageAccounts']);
254 }; 255 };
255 } else { 256 } else {
256 $('import-data').onclick = function(event) { 257 $('import-data').onclick = function(event) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 $('autofill-settings').disabled = true; 364 $('autofill-settings').disabled = true;
364 365
365 // Disable and turn off Password Manager in guest mode. 366 // Disable and turn off Password Manager in guest mode.
366 var passwordManagerEnabled = $('password-manager-enabled'); 367 var passwordManagerEnabled = $('password-manager-enabled');
367 passwordManagerEnabled.disabled = true; 368 passwordManagerEnabled.disabled = true;
368 passwordManagerEnabled.checked = false; 369 passwordManagerEnabled.checked = false;
369 cr.dispatchSimpleEvent(passwordManagerEnabled, 'change'); 370 cr.dispatchSimpleEvent(passwordManagerEnabled, 'change');
370 $('manage-passwords').disabled = true; 371 $('manage-passwords').disabled = true;
371 } 372 }
372 373
373 if (cr.isMac) 374 if (cr.isMac) {
374 $('mac-passwords-warning').hidden = !templateData.multiple_profiles; 375 $('mac-passwords-warning').hidden =
376 !loadTimeData.getBoolean('multiple_profiles');
377 }
375 378
376 // Network section. 379 // Network section.
377 if (!cr.isChromeOS) { 380 if (!cr.isChromeOS) {
378 $('proxiesConfigureButton').onclick = function(event) { 381 $('proxiesConfigureButton').onclick = function(event) {
379 chrome.send('showNetworkProxySettings'); 382 chrome.send('showNetworkProxySettings');
380 }; 383 };
381 } 384 }
382 385
383 // Web Content section. 386 // Web Content section.
384 $('fontSettingsCustomizeFontsButton').onclick = function(event) { 387 $('fontSettingsCustomizeFontsButton').onclick = function(event) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 }; 435 };
433 436
434 // Cloud Print section. 437 // Cloud Print section.
435 // 'cloudPrintProxyEnabled' is true for Chrome branded builds on 438 // 'cloudPrintProxyEnabled' is true for Chrome branded builds on
436 // certain platforms, or could be enabled by a lab. 439 // certain platforms, or could be enabled by a lab.
437 if (!cr.isChromeOS) { 440 if (!cr.isChromeOS) {
438 $('cloudPrintConnectorSetupButton').onclick = function(event) { 441 $('cloudPrintConnectorSetupButton').onclick = function(event) {
439 if ($('cloudPrintManageButton').style.display == 'none') { 442 if ($('cloudPrintManageButton').style.display == 'none') {
440 // Disable the button, set its text to the intermediate state. 443 // Disable the button, set its text to the intermediate state.
441 $('cloudPrintConnectorSetupButton').textContent = 444 $('cloudPrintConnectorSetupButton').textContent =
442 localStrings.getString('cloudPrintConnectorEnablingButton'); 445 loadTimeData.getString('cloudPrintConnectorEnablingButton');
443 $('cloudPrintConnectorSetupButton').disabled = true; 446 $('cloudPrintConnectorSetupButton').disabled = true;
444 chrome.send('showCloudPrintSetupDialog'); 447 chrome.send('showCloudPrintSetupDialog');
445 } else { 448 } else {
446 chrome.send('disableCloudPrintConnector'); 449 chrome.send('disableCloudPrintConnector');
447 } 450 }
448 }; 451 };
449 } 452 }
450 $('cloudPrintManageButton').onclick = function(event) { 453 $('cloudPrintManageButton').onclick = function(event) {
451 chrome.send('showCloudPrintManagePage'); 454 chrome.send('showCloudPrintManagePage');
452 }; 455 };
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 } else { 607 } else {
605 // Set the section height to 'auto' to allow for size changes 608 // Set the section height to 'auto' to allow for size changes
606 // (due to font change or dynamic content). 609 // (due to font change or dynamic content).
607 section.style.height = 'auto'; 610 section.style.height = 'auto';
608 } 611 }
609 }, 612 },
610 613
611 updateAdvancedSettingsExpander_: function() { 614 updateAdvancedSettingsExpander_: function() {
612 var expander = $('advanced-settings-expander'); 615 var expander = $('advanced-settings-expander');
613 if ($('advanced-settings').style.height == '') 616 if ($('advanced-settings').style.height == '')
614 expander.textContent = localStrings.getString('showAdvancedSettings'); 617 expander.textContent = loadTimeData.getString('showAdvancedSettings');
615 else 618 else
616 expander.textContent = localStrings.getString('hideAdvancedSettings'); 619 expander.textContent = loadTimeData.getString('hideAdvancedSettings');
617 }, 620 },
618 621
619 /** 622 /**
620 * Updates the sync section with the given state. 623 * Updates the sync section with the given state.
621 * @param {Object} syncData A bunch of data records that describe the status 624 * @param {Object} syncData A bunch of data records that describe the status
622 * of the sync system. 625 * of the sync system.
623 * @private 626 * @private
624 */ 627 */
625 updateSyncState_: function(syncData) { 628 updateSyncState_: function(syncData) {
626 if (!syncData.syncSystemEnabled) { 629 if (!syncData.syncSystemEnabled) {
627 $('sync-section').hidden = true; 630 $('sync-section').hidden = true;
628 return; 631 return;
629 } 632 }
630 633
631 $('sync-section').hidden = false; 634 $('sync-section').hidden = false;
632 this.syncSetupCompleted = syncData.setupCompleted; 635 this.syncSetupCompleted = syncData.setupCompleted;
633 $('customize-sync').hidden = !syncData.setupCompleted; 636 $('customize-sync').hidden = !syncData.setupCompleted;
634 637
635 var startStopButton = $('start-stop-sync'); 638 var startStopButton = $('start-stop-sync');
636 startStopButton.disabled = syncData.managed || 639 startStopButton.disabled = syncData.managed ||
637 syncData.setupInProgress; 640 syncData.setupInProgress;
638 startStopButton.hidden = 641 startStopButton.hidden =
639 syncData.setupCompleted && cr.isChromeOS; 642 syncData.setupCompleted && cr.isChromeOS;
640 startStopButton.textContent = 643 startStopButton.textContent =
641 syncData.setupCompleted ? 644 syncData.setupCompleted ?
642 localStrings.getString('syncButtonTextStop') : 645 loadTimeData.getString('syncButtonTextStop') :
643 syncData.setupInProgress ? 646 syncData.setupInProgress ?
644 localStrings.getString('syncButtonTextInProgress') : 647 loadTimeData.getString('syncButtonTextInProgress') :
645 localStrings.getString('syncButtonTextStart'); 648 loadTimeData.getString('syncButtonTextStart');
646 649
647 650
648 // TODO(estade): can this just be textContent? 651 // TODO(estade): can this just be textContent?
649 $('sync-status-text').innerHTML = syncData.statusText; 652 $('sync-status-text').innerHTML = syncData.statusText;
650 var statusSet = syncData.statusText.length != 0; 653 var statusSet = syncData.statusText.length != 0;
651 $('sync-overview').hidden = statusSet; 654 $('sync-overview').hidden = statusSet;
652 $('sync-status').hidden = !statusSet; 655 $('sync-status').hidden = !statusSet;
653 656
654 $('sync-action-link').textContent = syncData.actionLinkText; 657 $('sync-action-link').textContent = syncData.actionLinkText;
655 $('sync-action-link').hidden = syncData.actionLinkText.length == 0; 658 $('sync-action-link').hidden = syncData.actionLinkText.length == 0;
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 * available. 962 * available.
960 * @param {number} numProfiles The number of profiles to display. 963 * @param {number} numProfiles The number of profiles to display.
961 * @private 964 * @private
962 */ 965 */
963 setProfileViewSingle_: function(numProfiles) { 966 setProfileViewSingle_: function(numProfiles) {
964 var hasSingleProfile = numProfiles == 1; 967 var hasSingleProfile = numProfiles == 1;
965 $('profiles-list').hidden = hasSingleProfile; 968 $('profiles-list').hidden = hasSingleProfile;
966 $('profiles-single-message').hidden = !hasSingleProfile; 969 $('profiles-single-message').hidden = !hasSingleProfile;
967 $('profiles-manage').hidden = hasSingleProfile; 970 $('profiles-manage').hidden = hasSingleProfile;
968 $('profiles-delete').textContent = hasSingleProfile ? 971 $('profiles-delete').textContent = hasSingleProfile ?
969 templateData.profilesDeleteSingle : 972 loadTimeData.getString('profilesDeleteSingle') :
970 templateData.profilesDelete; 973 loadTimeData.getString('profilesDelete');
971 }, 974 },
972 975
973 /** 976 /**
974 * Adds all |profiles| to the list. 977 * Adds all |profiles| to the list.
975 * @param {Array.<Object>} profiles An array of profile info objects. 978 * @param {Array.<Object>} profiles An array of profile info objects.
976 * each object is of the form: 979 * each object is of the form:
977 * profileInfo = { 980 * profileInfo = {
978 * name: "Profile Name", 981 * name: "Profile Name",
979 * iconURL: "chrome://path/to/icon/image", 982 * iconURL: "chrome://path/to/icon/image",
980 * filePath: "/path/to/profile/data/on/disk", 983 * filePath: "/path/to/profile/data/on/disk",
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 if (selectCtl.options[i].value == font_size_value) { 1053 if (selectCtl.options[i].value == font_size_value) {
1051 selectCtl.selectedIndex = i; 1054 selectCtl.selectedIndex = i;
1052 if ($('Custom')) 1055 if ($('Custom'))
1053 selectCtl.remove($('Custom').index); 1056 selectCtl.remove($('Custom').index);
1054 return; 1057 return;
1055 } 1058 }
1056 } 1059 }
1057 1060
1058 // Add/Select Custom Option in the font size label list. 1061 // Add/Select Custom Option in the font size label list.
1059 if (!$('Custom')) { 1062 if (!$('Custom')) {
1060 var option = new Option(localStrings.getString('fontSizeLabelCustom'), 1063 var option = new Option(loadTimeData.getString('fontSizeLabelCustom'),
1061 -1, false, true); 1064 -1, false, true);
1062 option.setAttribute('id', 'Custom'); 1065 option.setAttribute('id', 'Custom');
1063 selectCtl.add(option); 1066 selectCtl.add(option);
1064 } 1067 }
1065 $('Custom').selected = true; 1068 $('Custom').selected = true;
1066 }, 1069 },
1067 1070
1068 /** 1071 /**
1069 * Populate the page zoom selector with values received from the caller. 1072 * Populate the page zoom selector with values received from the caller.
1070 * @param {Array} items An array of items to populate the selector. 1073 * @param {Array} items An array of items to populate the selector.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 1153
1151 /** 1154 /**
1152 * Set the Cloud Print proxy UI to enabled, disabled, or processing. 1155 * Set the Cloud Print proxy UI to enabled, disabled, or processing.
1153 * @private 1156 * @private
1154 */ 1157 */
1155 setupCloudPrintConnectorSection_: function(disabled, label, allowed) { 1158 setupCloudPrintConnectorSection_: function(disabled, label, allowed) {
1156 if (!cr.isChromeOS) { 1159 if (!cr.isChromeOS) {
1157 $('cloudPrintConnectorLabel').textContent = label; 1160 $('cloudPrintConnectorLabel').textContent = label;
1158 if (disabled || !allowed) { 1161 if (disabled || !allowed) {
1159 $('cloudPrintConnectorSetupButton').textContent = 1162 $('cloudPrintConnectorSetupButton').textContent =
1160 localStrings.getString('cloudPrintConnectorDisabledButton'); 1163 loadTimeData.getString('cloudPrintConnectorDisabledButton');
1161 $('cloudPrintManageButton').style.display = 'none'; 1164 $('cloudPrintManageButton').style.display = 'none';
1162 } else { 1165 } else {
1163 $('cloudPrintConnectorSetupButton').textContent = 1166 $('cloudPrintConnectorSetupButton').textContent =
1164 localStrings.getString('cloudPrintConnectorEnabledButton'); 1167 loadTimeData.getString('cloudPrintConnectorEnabledButton');
1165 $('cloudPrintManageButton').style.display = 'inline'; 1168 $('cloudPrintManageButton').style.display = 'inline';
1166 } 1169 }
1167 $('cloudPrintConnectorSetupButton').disabled = !allowed; 1170 $('cloudPrintConnectorSetupButton').disabled = !allowed;
1168 } 1171 }
1169 }, 1172 },
1170 1173
1171 /** 1174 /**
1172 * @private 1175 * @private
1173 */ 1176 */
1174 removeCloudPrintConnectorSection_: function() { 1177 removeCloudPrintConnectorSection_: function() {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 BrowserOptions.getLoggedInUsername = function() { 1377 BrowserOptions.getLoggedInUsername = function() {
1375 return BrowserOptions.getInstance().username_; 1378 return BrowserOptions.getInstance().username_;
1376 }; 1379 };
1377 } 1380 }
1378 1381
1379 // Export 1382 // Export
1380 return { 1383 return {
1381 BrowserOptions: BrowserOptions 1384 BrowserOptions: BrowserOptions
1382 }; 1385 };
1383 }); 1386 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698