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

Side by Side Diff: chrome/browser/resources/chromeos/image_burner.js

Issue 586953002: get rid of almost all old fashioned i18nTemplates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: window dot Created 6 years, 3 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
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 var localStrings;
6 var browserBridge; 5 var browserBridge;
7 6
8 /** 7 /**
9 * Class that keeps track of current burn process state. 8 * Class that keeps track of current burn process state.
10 * @param {Object} strings Localized state strings. 9 * @param {Object} strings Localized state strings.
11 * @constructor 10 * @constructor
12 */ 11 */
13 function State(strings) { 12 function State(strings) {
14 this.setStrings(strings); 13 this.setStrings(strings);
15 this.changeState(State.StatesEnum.DEVICE_NONE); 14 this.changeState(State.StatesEnum.DEVICE_NONE);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 this.state = newState; 94 this.state = newState;
96 95
97 $('main-content').className = this.state.cssState; 96 $('main-content').className = this.state.cssState;
98 97
99 $('status-text').textContent = this.state.statusText; 98 $('status-text').textContent = this.state.statusText;
100 99
101 if (newState.warningText) 100 if (newState.warningText)
102 $('warning-text').textContent = this.state.warningText; 101 $('warning-text').textContent = this.state.warningText;
103 102
104 if (this.isInitialState() && this.state != State.StatesEnum.DEVICE_NONE) { 103 if (this.isInitialState() && this.state != State.StatesEnum.DEVICE_NONE) {
105 $('warning-button').textContent = localStrings.getString('confirmButton'); 104 $('warning-button').textContent = loadTimeData.getString('confirmButton');
106 } else if (this.state == State.StatesEnum.FAIL) { 105 } else if (this.state == State.StatesEnum.FAIL) {
107 $('warning-button').textContent = 106 $('warning-button').textContent =
108 localStrings.getString('retryButton'); 107 loadTimeData.getString('retryButton');
109 } 108 }
110 }, 109 },
111 110
112 /** 111 /**
113 * Reset to initial state. 112 * Reset to initial state.
114 * @param {Array} devices Array of device information. 113 * @param {Array} devices Array of device information.
115 */ 114 */
116 gotoInitialState: function(devices) { 115 gotoInitialState: function(devices) {
117 if (devices.length == 0) { 116 if (devices.length == 0) {
118 this.changeState(State.StatesEnum.DEVICE_NONE); 117 this.changeState(State.StatesEnum.DEVICE_NONE);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 * @param {string} devicePath Selected device path. 176 * @param {string} devicePath Selected device path.
178 */ 177 */
179 onDeviceSelected: function(label, filePath, devicePath) { 178 onDeviceSelected: function(label, filePath, devicePath) {
180 $('warning-button').onclick = 179 $('warning-button').onclick =
181 browserBridge.sendBurnImageMessage.bind(browserBridge, filePath, 180 browserBridge.sendBurnImageMessage.bind(browserBridge, filePath,
182 devicePath); 181 devicePath);
183 182
184 this.selectedDevice = devicePath; 183 this.selectedDevice = devicePath;
185 184
186 $('warning-text').textContent = 185 $('warning-text').textContent =
187 localStrings.getStringF('warningDevices', label); 186 loadTimeData.getStringF('warningDevices', label);
188 }, 187 },
189 188
190 /** 189 /**
191 * Selects the specified device based on the specified path. 190 * Selects the specified device based on the specified path.
192 * @param {string} path Device path. 191 * @param {string} path Device path.
193 */ 192 */
194 selectDevice: function(path) { 193 selectDevice: function(path) {
195 var element = $('radio-' + path); 194 var element = $('radio-' + path);
196 element.checked = true; 195 element.checked = true;
197 element.onclick.apply(element); 196 element.onclick.apply(element);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 295 }
297 return undefined; 296 return undefined;
298 } 297 }
299 }; 298 };
300 299
301 /** 300 /**
302 * Class that handles communication with chrome. 301 * Class that handles communication with chrome.
303 * @constructor 302 * @constructor
304 */ 303 */
305 function BrowserBridge() { 304 function BrowserBridge() {
306 this.currentState = new State(localStrings); 305 this.currentState = new State(loadTimeData);
307 this.deviceSelection = new DeviceSelection(); 306 this.deviceSelection = new DeviceSelection();
308 // We will use these often so it makes sence making them class members to 307 // We will use these often so it makes sence making them class members to
309 // avoid frequent document.getElementById calls. 308 // avoid frequent document.getElementById calls.
310 this.progressElement = $('progress-div'); 309 this.progressElement = $('progress-div');
311 this.progressText = $('progress-text'); 310 this.progressText = $('progress-text');
312 this.progressTimeLeftText = $('pending-time'); 311 this.progressTimeLeftText = $('pending-time');
313 } 312 }
314 313
315 BrowserBridge.prototype = { 314 BrowserBridge.prototype = {
316 sendCancelMessage: function() { 315 sendCancelMessage: function() {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 } 418 }
420 }, 419 },
421 420
422 /** 421 /**
423 * Updates the current state to report device too small error. 422 * Updates the current state to report device too small error.
424 * @param {number} deviceSize Received device size. 423 * @param {number} deviceSize Received device size.
425 */ 424 */
426 reportDeviceTooSmall: function(deviceSize) { 425 reportDeviceTooSmall: function(deviceSize) {
427 this.currentState.changeState(State.StatesEnum.ERROR_DEVICE_TOO_SMALL); 426 this.currentState.changeState(State.StatesEnum.ERROR_DEVICE_TOO_SMALL);
428 $('warning-text').textContent = 427 $('warning-text').textContent =
429 localStrings.getStringF('warningNoSpace', deviceSize); 428 loadTimeData.getStringF('warningNoSpace', deviceSize);
430 }, 429 },
431 430
432 /** 431 /**
433 * Processes click on 'Retry' button in FAIL state. 432 * Processes click on 'Retry' button in FAIL state.
434 */ 433 */
435 onBurnRetry: function() { 434 onBurnRetry: function() {
436 this.deviceSelection.showDeviceSelection(); 435 this.deviceSelection.showDeviceSelection();
437 this.currentState.gotoInitialState(this.deviceSelection.devices); 436 this.currentState.gotoInitialState(this.deviceSelection.devices);
438 } 437 }
439 }; 438 };
440 439
441 document.addEventListener('DOMContentLoaded', function() { 440 document.addEventListener('DOMContentLoaded', function() {
442 localStrings = new LocalStrings();
443 browserBridge = new BrowserBridge(); 441 browserBridge = new BrowserBridge();
444 442
445 jstProcess(new JsEvalContext(templateData), $('more-info-link'));
446
447 $('cancel-button').onclick = 443 $('cancel-button').onclick =
448 browserBridge.sendCancelMessage.bind(browserBridge); 444 browserBridge.sendCancelMessage.bind(browserBridge);
449 browserBridge.sendGetDevicesMessage(); 445 browserBridge.sendGetDevicesMessage();
450 }); 446 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/image_burner.html ('k') | chrome/browser/resources/quota_internals/event_handler.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698