OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** @type {string} | 5 /** @type {string} |
6 * @const | 6 * @const |
7 */ | 7 */ |
8 var FEEDBACK_LANDING_PAGE = | 8 var FEEDBACK_LANDING_PAGE = |
9 'https://www.google.com/support/chrome/go/feedback_confirmation'; | 9 'https://www.google.com/support/chrome/go/feedback_confirmation'; |
10 /** @type {number} | 10 /** @type {number} |
11 * @const | 11 * @const |
12 */ | 12 */ |
13 var MAX_ATTACH_FILE_SIZE = 3 * 1024 * 1024; | 13 var MAX_ATTACH_FILE_SIZE = 3 * 1024 * 1024; |
14 | 14 |
15 var attachedFileBlob = null; | 15 var attachedFileBlob = null; |
16 var lastReader = null; | 16 var lastReader = null; |
17 | 17 |
18 var feedbackInfo = null; | 18 var feedbackInfo = null; |
19 var systemInfo = null; | 19 var systemInfo = null; |
20 | 20 |
21 var systemInfoWindowId = 0; | |
22 | |
21 /** | 23 /** |
22 * Reads the selected file when the user selects a file. | 24 * Reads the selected file when the user selects a file. |
23 * @param {Event} fileSelectedEvent The onChanged event for the file input box. | 25 * @param {Event} fileSelectedEvent The onChanged event for the file input box. |
24 */ | 26 */ |
25 function onFileSelected(fileSelectedEvent) { | 27 function onFileSelected(fileSelectedEvent) { |
26 $('attach-error').hidden = true; | 28 $('attach-error').hidden = true; |
27 var file = fileSelectedEvent.target.files[0]; | 29 var file = fileSelectedEvent.target.files[0]; |
28 if (!file) { | 30 if (!file) { |
29 // User canceled file selection. | 31 // User canceled file selection. |
30 attachedFileBlob = null; | 32 attachedFileBlob = null; |
(...skipping 18 matching lines...) Expand all Loading... | |
49 * attach another file. | 51 * attach another file. |
50 */ | 52 */ |
51 function clearAttachedFile() { | 53 function clearAttachedFile() { |
52 $('custom-file-container').hidden = true; | 54 $('custom-file-container').hidden = true; |
53 attachedFileBlob = null; | 55 attachedFileBlob = null; |
54 feedbackInfo.attachedFile = null; | 56 feedbackInfo.attachedFile = null; |
55 $('attach-file').hidden = false; | 57 $('attach-file').hidden = false; |
56 } | 58 } |
57 | 59 |
58 /** | 60 /** |
59 * Opens a new tab with chrome://system, showing the current system info. | 61 * Opens a new window with chrome://system, showing the current system info. |
60 */ | 62 */ |
61 function openSystemTab() { | 63 function openSystemInfoWindow() { |
62 window.open('chrome://system', '_blank'); | 64 if (systemInfoWindowId == 0) { |
65 chrome.windows.create({url: 'chrome://system'}, function(win) { | |
66 systemInfoWindowId = win.id; | |
67 chrome.app.window.current().show(); | |
xiyuan
2013/09/16 23:53:45
Is this necessary? Could you pass focused: true in
rkc
2013/09/17 00:00:00
Focused:true I believe is the default. Passing tha
| |
68 }); | |
69 } else { | |
70 chrome.windows.update(systemInfoWindowId, {drawAttention: true}); | |
71 } | |
63 } | 72 } |
64 | 73 |
65 /** | 74 /** |
66 * Sends the report; after the report is sent, we need to be redirected to | 75 * Sends the report; after the report is sent, we need to be redirected to |
67 * the landing page, but we shouldn't be able to navigate back, hence | 76 * the landing page, but we shouldn't be able to navigate back, hence |
68 * we open the landing page in a new tab and sendReport closes this tab. | 77 * we open the landing page in a new tab and sendReport closes this tab. |
69 * @return {boolean} True if the report was sent. | 78 * @return {boolean} True if the report was sent. |
70 */ | 79 */ |
71 function sendReport() { | 80 function sendReport() { |
72 if ($('description-text').value.length == 0) { | 81 if ($('description-text').value.length == 0) { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 | 192 |
184 window.addEventListener('DOMContentLoaded', function() { | 193 window.addEventListener('DOMContentLoaded', function() { |
185 // Ready to receive the feedback object. | 194 // Ready to receive the feedback object. |
186 chrome.runtime.sendMessage({ready: true}); | 195 chrome.runtime.sendMessage({ready: true}); |
187 | 196 |
188 // Setup our event handlers. | 197 // Setup our event handlers. |
189 $('attach-file').addEventListener('change', onFileSelected); | 198 $('attach-file').addEventListener('change', onFileSelected); |
190 $('send-report-button').onclick = sendReport; | 199 $('send-report-button').onclick = sendReport; |
191 $('cancel-button').onclick = cancel; | 200 $('cancel-button').onclick = cancel; |
192 $('remove-attached-file').onclick = clearAttachedFile; | 201 $('remove-attached-file').onclick = clearAttachedFile; |
202 | |
203 chrome.windows.onRemoved.addListener(function(windowId, removeInfo) { | |
204 if (windowId == systemInfoWindowId) | |
205 systemInfoWindowId = 0; | |
206 }); | |
193 if ($('sysinfo-url')) { | 207 if ($('sysinfo-url')) { |
194 $('sysinfo-url').onclick = openSystemTab; | 208 $('sysinfo-url').onclick = openSystemInfoWindow; |
195 } | 209 } |
196 }); | 210 }); |
197 } | 211 } |
198 | 212 |
199 initialize(); | 213 initialize(); |
OLD | NEW |