diff options
Diffstat (limited to 'chromium/chrome/browser/resources/feedback/js/feedback.js')
-rw-r--r-- | chromium/chrome/browser/resources/feedback/js/feedback.js | 68 |
1 files changed, 25 insertions, 43 deletions
diff --git a/chromium/chrome/browser/resources/feedback/js/feedback.js b/chromium/chrome/browser/resources/feedback/js/feedback.js index 1edda2dcd59..55933f52e22 100644 --- a/chromium/chrome/browser/resources/feedback/js/feedback.js +++ b/chromium/chrome/browser/resources/feedback/js/feedback.js @@ -21,7 +21,7 @@ var FEEDBACK_MIN_WIDTH = 500; * @type {number} * @const */ -var FEEDBACK_MIN_HEIGHT = 625; +var FEEDBACK_MIN_HEIGHT = 585; /** @type {number} * @const @@ -33,15 +33,22 @@ var CONTENT_MARGIN_HEIGHT = 40; */ var MAX_SCREENSHOT_WIDTH = 100; +/** @type {string} + * @const + */ +var SYSINFO_WINDOW_ID = 'sysinfo_window'; + +/** @type {string} + * @const + */ +var STATS_WINDOW_ID = 'stats_window'; + var attachedFileBlob = null; var lastReader = null; var feedbackInfo = null; var systemInfo = null; -var systemInfoWindow = {id: 0}; -var histogramsWindow = {id: 0}; - /** * Reads the selected file when the user selects a file. * @param {Event} fileSelectedEvent The onChanged event for the file input box. @@ -80,22 +87,15 @@ function clearAttachedFile() { } /** - * Creates and shows a window with the given url, if the window is not already - * open. - * @param {Object} window An object with the id of the window to update, or 0. + * Creates a closure that creates or shows a window with the given url. + * @param {string} windowId A string with the ID of the window we are opening. * @param {string} url The destination URL of the new window. * @return {function()} A function to be called to open the window. */ -function windowOpener(window, url) { - return function() { - if (window.id == 0) { - chrome.windows.create({url: url}, function(win) { - window.id = win.id; - chrome.app.window.current().show(); - }); - } else { - chrome.windows.update(window.id, {drawAttention: true}); - } +function windowOpener(windowId, url) { + return function(e) { + e.preventDefault(); + chrome.app.window.create(url, {id: windowId}); }; } @@ -103,9 +103,8 @@ function windowOpener(window, url) { * Opens a new window with chrome://slow_trace, downloading performance data. */ function openSlowTraceWindow() { - chrome.windows.create( - {url: 'chrome://slow_trace/tracing.zip#' + feedbackInfo.traceId}, - function(win) {}); + chrome.app.window.create( + 'chrome://slow_trace/tracing.zip#' + feedbackInfo.traceId); } /** @@ -136,29 +135,19 @@ function sendReport() { var useSystemInfo = false; var useHistograms = false; - // On ChromeOS, since we gather System info, check if the user has given his - // permission for us to send system info. -<if expr="pp_ifdef('chromeos')"> if ($('sys-info-checkbox') != null && $('sys-info-checkbox').checked && systemInfo != null) { // Send histograms along with system info. useSystemInfo = useHistograms = true; } +<if expr="chromeos"> if ($('performance-info-checkbox') == null || !($('performance-info-checkbox').checked)) { feedbackInfo.traceId = null; } </if> -// On NonChromeOS, we don't have any system information gathered except the -// Chrome version and the OS version. Hence for Chrome, pass the system info -// through. -<if expr="not pp_ifdef('chromeos')"> - if (systemInfo != null) - useSystemInfo = true; -</if> - if (useSystemInfo) { if (feedbackInfo.systemInformation != null) { // Concatenate sysinfo if we had any initial system information @@ -208,7 +197,7 @@ function dataUrlToBlob(url) { return new Blob([new Uint8Array(dataArray)], {type: mimeString}); } -<if expr="pp_ifdef('chromeos')"> +<if expr="chromeos"> /** * Update the page when performance feedback state is changed. */ @@ -303,7 +292,7 @@ function initialize() { $('attach-file').hidden = true; } -<if expr="pp_ifdef('chromeos')"> +<if expr="chromeos"> if (feedbackInfo.traceId && ($('performance-info-area'))) { $('performance-info-area').hidden = false; $('performance-info-checkbox').checked = true; @@ -319,12 +308,12 @@ function initialize() { if ($('sys-info-url')) { // Opens a new window showing the current system info. $('sys-info-url').onclick = - windowOpener(systemInfoWindow, 'chrome://system'); + windowOpener(SYSINFO_WINDOW_ID, 'chrome://system'); } if ($('histograms-url')) { // Opens a new window showing the histogram metrics. $('histograms-url').onclick = - windowOpener(histogramsWindow, 'chrome://histograms'); + windowOpener(STATS_WINDOW_ID, 'chrome://histograms'); } }); } @@ -341,17 +330,10 @@ function initialize() { $('send-report-button').onclick = sendReport; $('cancel-button').onclick = cancel; $('remove-attached-file').onclick = clearAttachedFile; -<if expr="pp_ifdef('chromeos')"> +<if expr="chromeos"> $('performance-info-checkbox').addEventListener( 'change', performanceFeedbackChanged); </if> - - chrome.windows.onRemoved.addListener(function(windowId, removeInfo) { - if (windowId == systemInfoWindow.id) - systemInfoWindow.id = 0; - else if (windowId == histogramsWindow.id) - histogramsWindow.id = 0; - }); }); } |