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

Unified 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: UI polishing 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 side-by-side diff with in-line comments
Download patch
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..f2eec483007682aa2bf5db1b3530c4bce426a919 100644
--- a/chrome/browser/resources/translate_internals/translate_internals.js
+++ b/chrome/browser/resources/translate_internals/translate_internals.js
@@ -252,8 +252,55 @@
}
}
+
Alexei Svitkine (slow) 2016/04/20 20:30:23 Nit: Remove extra line.
hamelphi 2016/04/20 21:39:46 Done.
+ /**
+ * 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('textarea');
+ // FIXME: what is the max length of a country code?
Alexei Svitkine (slow) 2016/04/20 20:30:23 We can probably just not set this.
hamelphi 2016/04/20 21:39:46 Done.
+ input.maxLength = '20';
+ input.cols = '20';
+ input.rows = '1';
+ input.value = country;
+
+ var button = document.createElement('button');
+ button.textContent = 'update';
+ button.classList.add('override_country');
+ 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.';
+ }
+ }
+
/**
- * Addes '0's to |number| as a string. |width| is length of the string
+ * 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 +452,9 @@
case 'supportedLanguagesUpdated':
onSupportedLanguagesUpdated(details);
break;
+ case 'countryUpdated':
+ onCountryUpdated(details);
+ break;
case 'translateErrorDetailsAdded':
onTranslateErrorDetailsAdded(details);
break;

Powered by Google App Engine
This is Rietveld 408576698