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

Unified Diff: chrome/browser/resources/translate_internals/translate_internals.js

Issue 15728008: Add the 'content' column to see what text is used to detect a language (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: (Rebasing) Created 7 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 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 4ccbbd39824b50baf385c089f5f5f71ec1c9babd..2afb91d02e94fedf03615ef82e32b2142ee99996 100644
--- a/chrome/browser/resources/translate_internals/translate_internals.js
+++ b/chrome/browser/resources/translate_internals/translate_internals.js
@@ -7,6 +7,14 @@
cr.define('cr.translateInternals', function() {
+ var detectionLogs_ = null;
+
+ function detectionLogs() {
+ if (detectionLogs_ === null)
+ detectionLogs_ = [];
+ return detectionLogs_;
+ }
+
/**
* Initializes UI and sends a message to the browser for
* initialization.
@@ -14,6 +22,9 @@
function initialize() {
cr.ui.decorate('tabbox', cr.ui.TabBox);
chrome.send('requestInfo');
+
+ var button = $('detection-logs-dump');
+ button.addEventListener('click', onDetectionLogsDump);
}
/**
@@ -211,6 +222,8 @@
* @param {Object} detail The object which represents the logs.
*/
function onLanguageDetectionInfoAdded(detail) {
+ cr.translateInternals.detectionLogs().push(detail);
+
var tr = document.createElement('tr');
var date = new Date(detail['time']);
@@ -225,10 +238,20 @@
'detection-logs-is-cld-reliable'),
createTD(formatLanguageCode(detail['language']),
'detection-logs-language'),
+ createTD(formatLanguageCode(detail['content']),
+ 'detection-logs-content'),
].forEach(function(td) {
tr.appendChild(td);
});
+ // TD (and TR) can't use the CSS property 'max-height', so DIV
+ // in the content is needed.
+ var contentTD = tr.querySelector('.detection-logs-content');
+ var div = document.createElement('div');
+ div.textContent = contentTD.textContent;
+ contentTD.textContent = '';
+ contentTD.appendChild(div);
+
var tbody = $('detection-logs').getElementsByTagName('tbody')[0];
tbody.appendChild(tr);
}
@@ -281,7 +304,27 @@
}
}
+ /**
+ * The callback of button#detetion-logs-dump.
+ */
+ function onDetectionLogsDump() {
+ var data = JSON.stringify(cr.translateInternals.detectionLogs());
+ var blob = new Blob([data], {'type': 'text/json'});
+ var url = webkitURL.createObjectURL(blob);
+ var filename = 'translate_internals_detect_logs_dump.json';
+
+ var a = document.createElement('a');
+ a.setAttribute('href', url);
+ a.setAttribute('download', filename);
+
+ var event = document.createEvent('MouseEvent');
+ event.initMouseEvent('click', true, true, window, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, null);
+ a.dispatchEvent(event);
+ }
+
return {
+ detectionLogs: detectionLogs,
initialize: initialize,
messageHandler: messageHandler,
onLanguageDetectionInfoAdded: onLanguageDetectionInfoAdded,

Powered by Google App Engine
This is Rietveld 408576698