Chromium Code Reviews| Index: chrome/browser/resources/translate_internals/translate_internals.js |
| diff --git a/chrome/browser/resources/translate_internals/translate_internals.js b/chrome/browser/resources/translate_internals/translate_internals.js |
| index e6ecc1b8b984172f0b66982f227ad3367533c7f6..8b9ec350becbdc7f1ba0833023e762f9b223b1b4 100644 |
| --- a/chrome/browser/resources/translate_internals/translate_internals.js |
| +++ b/chrome/browser/resources/translate_internals/translate_internals.js |
| @@ -253,7 +253,50 @@ |
| } |
| /** |
| - * Addes '0's to |number| as a string. |width| is length of the string |
| + * Handles the message of 'countryUpdated' from the browser. |
| + * |
| + * @param {Object} details the object containing the country |
| + * information. |
| + */ |
| + function onCountryUpdated(details) { |
| + var p; |
| + p = $('country-override'); |
| + |
| + p.innerHTML = ''; |
| + |
| + if ('country' in details) { |
| + var country = details['country']; |
| + |
| + var input = document.createElement('input'); |
| + input.type = 'text'; |
| + input.value = country; |
| + |
| + var button = document.createElement('button'); |
| + button.textContent = 'update'; |
| + 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
|
| + button.addEventListener('click', function() { |
| + chrome.send('overrideCountry', [input.value]); |
| + }, false); |
| + p.appendChild(input); |
| + p.appendChild(document.createElement('br')); |
| + p.appendChild(button); |
| + |
| + if ('update' in details && details['update']) { |
| + var div1 = document.createElement('div'); |
| + div1.textContent = 'Permanent stored country updated.'; |
| + var div2 = document.createElement('div'); |
| + div2.textContent = ('You will need to restart your browser ' + |
| + 'for the changes to take effect.'); |
| + p.appendChild(div1); |
| + p.appendChild(div2); |
| + } |
| + } else { |
| + p.textContent = 'Could not load country info from Variations.'; |
| + } |
| + } |
| + |
| + /** |
| + * Adds '0's to |number| as a string. |width| is length of the string |
| * including '0's. |
| * |
| * @param {string} number The number to be converted into a string. |
| @@ -405,6 +448,9 @@ |
| case 'supportedLanguagesUpdated': |
| onSupportedLanguagesUpdated(details); |
| break; |
| + case 'countryUpdated': |
| + onCountryUpdated(details); |
| + break; |
| case 'translateErrorDetailsAdded': |
| onTranslateErrorDetailsAdded(details); |
| break; |