Chromium Code Reviews| Index: chrome/browser/resources/feedback/js/feedback.js |
| diff --git a/chrome/browser/resources/feedback/js/feedback.js b/chrome/browser/resources/feedback/js/feedback.js |
| index 6cd19b693287b16c2017311f2a0a78ecf4218efd..652b20674d2f216af2d299e4b83b4f76c2178818 100644 |
| --- a/chrome/browser/resources/feedback/js/feedback.js |
| +++ b/chrome/browser/resources/feedback/js/feedback.js |
| @@ -63,7 +63,12 @@ var FeedbackFlow = { |
| var attachedFileBlob = null; |
| var lastReader = null; |
| -var feedbackInfo = null; |
| +/** |
| + * Determines whether the system information associated with this instance of |
| + * the feedback window has been received. |
| + * @type {boolean} |
| + */ |
| +var isSystemInfoReady = false; |
| /** |
| * The callback used by the sys_info_page to receive the event that the system |
| @@ -176,29 +181,17 @@ function sendReport() { |
| if (!$('screenshot-checkbox').checked) |
| feedbackInfo.screenshot = null; |
| - if (useSystemInfo) { |
| - // The user chose to include the system information as part of the report. |
| - // If they are not ready yet, we have to send the report later. |
| - if (!isSystemInfoReady()) { |
| - // The report will be sent later by the feedback extension's background |
| - // page (see event_handler.js). |
| - sendReportLater(feedbackInfo); |
| - |
| - // No landing page for login screen feedback. |
| - if (feedbackInfo.flow != FeedbackFlow.LOGIN) |
| - window.open(FEEDBACK_LANDING_PAGE, '_blank'); |
| - window.close(); |
| - return true; |
| - } |
| - } |
| - |
| - chrome.feedbackPrivate.sendFeedback(feedbackInfo, function(result) { |
| - // No landing page for login screen feedback. |
| - if (feedbackInfo.flow != FeedbackFlow.LOGIN) |
| - window.open(FEEDBACK_LANDING_PAGE, '_blank'); |
| - window.close(); |
| - }); |
| + // Clear the system information if the user doesn't want it to be sent. |
| + if (!useSystemInfo) |
| + feedbackInfo.systemInformation = null; |
|
xiyuan
2016/03/16 16:39:28
It is probably safer to remember useSystemInfo in
afakhry
2016/03/16 17:51:22
Thanks for catching this. Done.
|
| + // Request sending the report, show the landing page (if allowed), and close |
| + // this window right away. The FeedbackRequest object that represents this |
| + // report will take care of sending the report in the background. |
| + sendFeedbackReport(useSystemInfo); |
| + if (feedbackInfo.flow != FeedbackFlow.LOGIN) |
| + window.open(FEEDBACK_LANDING_PAGE, '_blank'); |
| + window.close(); |
| return true; |
| } |
| @@ -267,18 +260,9 @@ function resizeAppWindow() { |
| /** |
| * A callback to be invoked when the background page of this extension receives |
| * the system information. |
| - * @param {Object} sysInfo The received system information. |
| */ |
| -function onSystemInformation(sysInfo) { |
| - // Concatenate the feedbackInfo's systemInformation with the newly received |
| - // sysInfo once (if any). |
| - if (feedbackInfo.systemInformation) { |
| - feedbackInfo.systemInformation = |
| - feedbackInfo.systemInformation.concat(sysInfo); |
| - } else { |
| - feedbackInfo.systemInformation = sysInfo; |
| - } |
| - |
| +function onSystemInformation() { |
| + isSystemInfoReady = true; |
| // In case the sys_info_page needs to be notified by this event, do so. |
| if (sysInfoPageOnSysInfoReadyCallback != null) { |
| sysInfoPageOnSysInfoReadyCallback(feedbackInfo.systemInformation); |
| @@ -301,8 +285,6 @@ function initialize() { |
| // Add listener to receive the feedback info object. |
| chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) { |
| if (request.sentFromEventPage) { |
| - feedbackInfo = request.data; |
| - |
| if (!feedbackInfo.flow) |
| feedbackInfo.flow = FeedbackFlow.REGULAR; |
| @@ -329,8 +311,8 @@ function initialize() { |
| $('user-email-text').value = email; |
| }); |
| - // Initiate getting the system info and use it to prepare the full |
| - // feedback info. |
| + // Initiate getting the system info. |
| + isSystemInfoReady = false; |
| getSystemInformation(onSystemInformation); |
| // An extension called us with an attached file. |
| @@ -385,7 +367,7 @@ function initialize() { |
| // Gets the full system information for the new window. |
| appWindow.contentWindow.getFullSystemInfo = |
| function(callback) { |
| - if (isSystemInfoReady()) { |
| + if (isSystemInfoReady) { |
| callback(feedbackInfo.systemInformation); |
| return; |
| } |