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

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

Powered by Google App Engine
This is Rietveld 408576698