OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * This view displays options for importing/exporting the captured data. Its |
| 7 * primarily usefulness is to allow users to copy-paste their data in an easy |
| 8 * to read format for bug reports. |
| 9 * |
| 10 * - Has a button to generate a text report. |
| 11 * |
| 12 * - Shows how many events have been captured. |
| 13 * @constructor |
| 14 */ |
| 15 function InfoView(mainBoxId) { |
| 16 DivView.call(this, mainBoxId); |
| 17 |
| 18 this.textDiv_ = document.getElementById('info-text'); |
| 19 this.gpuInfo_ = undefined; |
| 20 this.clientInfo_ = undefined; |
| 21 |
| 22 var self = this; |
| 23 |
| 24 // This function begins a request for the ClientInfo. If it comes back |
| 25 // as undefined, then we will issue the request again in 250ms. |
| 26 function beginRequestClientInfo() { |
| 27 g_browser.callAsync('requestClientInfo', undefined, function(data) { |
| 28 self.clientInfo_ = data; |
| 29 self.refresh_(); |
| 30 if(data === undefined) { // try again in 250 ms |
| 31 window.setTimeout(beginRequestClientInfo, 250); |
| 32 } |
| 33 }); |
| 34 } |
| 35 beginRequestClientInfo(); |
| 36 |
| 37 // This function begins a request for the GpuInfo. If it comes back |
| 38 // as undefined, then we will issue the request again in 250ms. |
| 39 function beginRequestGpuInfo() { |
| 40 g_browser.callAsync('requestGpuInfo', undefined, function(data) { |
| 41 self.gpuInfo_ = data; |
| 42 self.refresh_(); |
| 43 if(data === undefined) { // try again in 250 ms |
| 44 window.setTimeout(beginRequestGpuInfo, 250); |
| 45 } |
| 46 }); |
| 47 } |
| 48 beginRequestGpuInfo(); |
| 49 this.refresh_(); |
| 50 } |
| 51 |
| 52 inherits(InfoView, DivView); |
| 53 |
| 54 /** |
| 55 * Updates the view based on its currently known data |
| 56 */ |
| 57 InfoView.prototype.refresh_ = function(data) { |
| 58 var html = []; |
| 59 function outputObject(obj) { |
| 60 var all_values = true; |
| 61 for (var k in obj) { // output values |
| 62 var v = obj[k]; |
| 63 if(!(typeof(v) === 'number' || typeof(v) === "string")) { |
| 64 all_values = false; |
| 65 } |
| 66 } |
| 67 if (all_values) |
| 68 html.push("<table class='border'>"); |
| 69 else |
| 70 html.push("<table>"); |
| 71 for (var k in obj) { // output values |
| 72 var v = obj[k]; |
| 73 if (typeof(v) === 'number' || typeof(v) === "string") { |
| 74 html.push("<tr><td><strong>"); |
| 75 html.push(k); |
| 76 html.push("</strong></td><td>"); |
| 77 html.push(v); |
| 78 html.push("</td></tr>"); |
| 79 } else { |
| 80 html.push("<tr><td colspan=2><strong>" + k + ":</strong>"); |
| 81 html.push("<div style=\"padding-left: 8px;\">"); |
| 82 outputObject(v); |
| 83 html.push("</div>"); |
| 84 html.push("</td></tr>"); |
| 85 } |
| 86 } |
| 87 html.push("</table>"); |
| 88 } |
| 89 |
| 90 html.push('<h2>Chrome information</h2>'); |
| 91 if (this.clientInfo_) { |
| 92 var chromeVersion = this.clientInfo_.version + |
| 93 ' (' + this.clientInfo_.official + |
| 94 ' ' + this.clientInfo_.cl + |
| 95 ') ' + this.clientInfo_.version_mod + "</p>"; |
| 96 var data = {'Data exported on' : (new Date()).toLocaleString(), |
| 97 'Chrome version: ' : chromeVersion}; |
| 98 outputObject(data); |
| 99 } else { |
| 100 html.push('... refreshing data ...'); |
| 101 } |
| 102 |
| 103 html.push('<h2>GPU information</h2>'); |
| 104 if (this.gpuInfo_) { |
| 105 outputObject(this.gpuInfo_); |
| 106 } else { |
| 107 html.push('... refreshing data ...'); |
| 108 } |
| 109 |
| 110 // Open a new window to display this text. |
| 111 this.textDiv_.innerHTML = html.join("\n"); |
| 112 }; |
| 113 |
OLD | NEW |