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

Side by Side Diff: chrome/browser/resources/translate_internals/translate_internals.js

Issue 1903593002: Allows to manually change the stored permanent country in Variations from the translate-internals d… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 (function() { 5 (function() {
6 'use strict'; 6 'use strict';
7 7
8 cr.define('cr.translateInternals', function() { 8 cr.define('cr.translateInternals', function() {
9 9
10 var detectionLogs_ = null; 10 var detectionLogs_ = null;
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 var text = formatLanguageCode(language); 246 var text = formatLanguageCode(language);
247 if (details['alpha_languages'].indexOf(language) != -1) 247 if (details['alpha_languages'].indexOf(language) != -1)
248 text += ' - alpha'; 248 text += ' - alpha';
249 li.innerText = text; 249 li.innerText = text;
250 250
251 ul.appendChild(li); 251 ul.appendChild(li);
252 } 252 }
253 } 253 }
254 254
255 /** 255 /**
256 * Addes '0's to |number| as a string. |width| is length of the string 256 * Handles the message of 'countryUpdated' from the browser.
257 *
258 * @param {Object} details the object containing the country
259 * information.
260 */
261 function onCountryUpdated(details) {
262 var p;
263 p = $('country-override');
264
265 p.innerHTML = '';
266
267 if ('country' in details) {
268 var country = details['country'];
269
270 var input = document.createElement('input');
271 input.type = 'text';
272 input.value = country;
273
274 var button = document.createElement('button');
275 button.textContent = 'update';
276 button.classList.add('override_country');
Alexei Svitkine (slow) 2016/04/21 15:21:21 Are you defining the css for this somewhere?
hamelphi 2016/04/21 21:14:44 Ah, no. But I guess it is not needed. Removed the
277 button.addEventListener('click', function() {
278 chrome.send('overrideCountry', [input.value]);
279 }, false);
280 p.appendChild(input);
281 p.appendChild(document.createElement('br'));
282 p.appendChild(button);
283
284 if ('update' in details && details['update']) {
285 var div1 = document.createElement('div');
286 div1.textContent = 'Permanent stored country updated.';
287 var div2 = document.createElement('div');
288 div2.textContent = ('You will need to restart your browser ' +
289 'for the changes to take effect.');
290 p.appendChild(div1);
291 p.appendChild(div2);
292 }
293 } else {
294 p.textContent = 'Could not load country info from Variations.';
295 }
296 }
297
298 /**
299 * Adds '0's to |number| as a string. |width| is length of the string
257 * including '0's. 300 * including '0's.
258 * 301 *
259 * @param {string} number The number to be converted into a string. 302 * @param {string} number The number to be converted into a string.
260 * @param {number} width The width of the returned string. 303 * @param {number} width The width of the returned string.
261 * @return {string} The formatted string. 304 * @return {string} The formatted string.
262 */ 305 */
263 function padWithZeros(number, width) { 306 function padWithZeros(number, width) {
264 var numberStr = number.toString(); 307 var numberStr = number.toString();
265 var restWidth = width - numberStr.length; 308 var restWidth = width - numberStr.length;
266 if (restWidth <= 0) 309 if (restWidth <= 0)
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 switch (message) { 441 switch (message) {
399 case 'languageDetectionInfoAdded': 442 case 'languageDetectionInfoAdded':
400 onLanguageDetectionInfoAdded(details); 443 onLanguageDetectionInfoAdded(details);
401 break; 444 break;
402 case 'prefsUpdated': 445 case 'prefsUpdated':
403 onPrefsUpdated(details); 446 onPrefsUpdated(details);
404 break; 447 break;
405 case 'supportedLanguagesUpdated': 448 case 'supportedLanguagesUpdated':
406 onSupportedLanguagesUpdated(details); 449 onSupportedLanguagesUpdated(details);
407 break; 450 break;
451 case 'countryUpdated':
452 onCountryUpdated(details);
453 break;
408 case 'translateErrorDetailsAdded': 454 case 'translateErrorDetailsAdded':
409 onTranslateErrorDetailsAdded(details); 455 onTranslateErrorDetailsAdded(details);
410 break; 456 break;
411 case 'translateEventDetailsAdded': 457 case 'translateEventDetailsAdded':
412 onTranslateEventDetailsAdded(details); 458 onTranslateEventDetailsAdded(details);
413 break; 459 break;
414 default: 460 default:
415 console.error('Unknown message:', message); 461 console.error('Unknown message:', message);
416 break; 462 break;
417 } 463 }
(...skipping 28 matching lines...) Expand all
446 /** 492 /**
447 * The entry point of the UI. 493 * The entry point of the UI.
448 */ 494 */
449 function main() { 495 function main() {
450 cr.doc.addEventListener('DOMContentLoaded', 496 cr.doc.addEventListener('DOMContentLoaded',
451 cr.translateInternals.initialize); 497 cr.translateInternals.initialize);
452 } 498 }
453 499
454 main(); 500 main();
455 })(); 501 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698