Index: chrome/browser/resources/gpu/infoview.js |
=================================================================== |
--- chrome/browser/resources/gpu/infoview.js (revision 0) |
+++ chrome/browser/resources/gpu/infoview.js (revision 0) |
@@ -0,0 +1,149 @@ |
+// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+/** |
+ * This view displays options for importing/exporting the captured data. Its |
+ * primarily usefulness is to allow users to copy-paste their data in an easy |
+ * to read format for bug reports. |
+ * |
+ * - Has a button to generate a text report. |
+ * |
+ * - Shows how many events have been captured. |
+ * @constructor |
+ */ |
+function InfoView(mainBoxId) { |
+ DivView.call(this, mainBoxId); |
+ |
+ this.textDiv_ = document.getElementById('infoText'); |
+ this.gpuInfo_ = undefined; |
+ this.clientInfo_ = undefined; |
+ |
+ var self = this; |
+ |
+ // This function begins a request for the ClientInfo. If it comes back |
+ // as undefined, then we will issue the request again in 250ms. |
+ function beginRequestClientInfo() { |
+ g_browser.callAsync('requestClientInfo', undefined, function(data) { |
+ self.clientInfo_ = data; |
+ self.refresh_(); |
+ if(data === undefined) { // try again in 250 ms |
+ window.setTimeout(beginRequestClientInfo, 250) |
+ } |
+ }); |
+ } |
+ beginRequestClientInfo(); |
+ |
+ // This function begins a request for the GpuInfo. If it comes back |
+ // as undefined, then we will issue the request again in 250ms. |
+ function beginRequestGpuInfo() { |
+ g_browser.callAsync('requestGpuInfo', undefined, function(data) { |
+ self.gpuInfo_ = data; |
+ self.refresh_(); |
+ if(data === undefined) { // try again in 250 ms |
+ window.setTimeout(beginRequestGpuInfo, 250) |
+ } |
+ }); |
+ } |
+ beginRequestGpuInfo(); |
+ this.refresh_(); |
+} |
+ |
+inherits(InfoView, DivView); |
+ |
+/** |
+* Updates the view based on its currently known data |
+*/ |
+InfoView.prototype.refresh_ = function(data) { |
+ var html = []; |
+ function separateValues(obj) { |
+ var subdicts = {} |
mmenke
2010/11/23 19:27:13
nit: Missing semi-colons here and on the next line
nduca
2010/11/23 19:39:01
Done.
|
+ var values = {} |
+ for(var k in obj) { |
+ var v = obj[k]; |
+ if(typeof(v) === 'number' || typeof(v) === "string") { |
mmenke
2010/11/23 19:27:13
nit: Single quotes are preferred by Google style g
nduca
2010/11/23 19:39:01
Done.
|
+ values[k] = v; |
+ } else { |
+ subdicts[k] = v; |
+ } |
+ } |
+ return [subdicts,values]; |
+ } |
+ function outputObject(obj) { |
+ var items = separateValues(obj); |
+ var subdicts = items[0]; |
+ var values = items[1]; |
+ html.push("<table>"); |
+ for(var k in values) { // output values |
+ html.push("<tr><td><strong>"); |
+ html.push(k); |
+ html.push("</strong></td><td>"); |
+ html.push(values[k]); |
+ html.push("</td></tr>"); |
+ } |
+ html.push("</table>"); |
+ |
+ html.push("<ul>"); |
+ for(var k in subdicts) { // output subdicts |
+ html.push("<li><strong>" + k + ":</strong> "); |
+ outputObject(subdicts[k]); |
+ html.push("</li>"); |
+ } |
+ html.push("</ul>"); |
+ } |
+ |
+ function outputObjectV2(obj) { |
+ var all_values = true; |
+ for (var k in obj) { // output values |
+ var v = obj[k]; |
+ if(!(typeof(v) === 'number' || typeof(v) === "string")) { |
+ all_values = false; |
+ } |
+ } |
+ if (all_values) |
+ html.push("<table class='border'>"); |
+ else |
+ html.push("<table>"); |
+ for (var k in obj) { // output values |
+ var v = obj[k]; |
+ if (typeof(v) === 'number' || typeof(v) === "string") { |
+ html.push("<tr><td><strong>"); |
+ html.push(k); |
+ html.push("</strong></td><td>"); |
+ html.push(v); |
+ html.push("</td></tr>"); |
+ } else { |
+ html.push("<tr><td colspan=2><strong>" + k + ":</strong>"); |
+ html.push("<div style=\"padding-left: 8px;\">"); |
+ outputObjectV2(v); |
+ html.push("</div>"); |
+ html.push("</td></tr>"); |
+ } |
+ } |
+ html.push("</table>"); |
+ } |
+ |
+ html.push('<h2>Chrome information</h2>'); |
+ if (this.clientInfo_) { |
+ var chromeVersion = this.clientInfo_.version + |
+ ' (' + this.clientInfo_.official + |
+ ' ' + this.clientInfo_.cl + |
+ ') ' + this.clientInfo_.version_mod + "</p>"; |
+ var data = {'Data exported on' : (new Date()).toLocaleString(), |
+ 'Chrome version: ' : chromeVersion}; |
+ outputObjectV2(data); |
+ } else { |
+ html.push('... refreshing data ...'); |
+ } |
+ |
+ html.push('<h2>GPU information</h2>'); |
+ if (this.gpuInfo_) { |
+ outputObjectV2(this.gpuInfo_); |
+ } else { |
+ html.push('... refreshing data ...'); |
+ } |
+ |
+ // Open a new window to display this text. |
+ this.textDiv_.innerHTML = html.join("\n"); |
+} |
mmenke
2010/11/23 19:27:13
nit: Missing semi-colon. This is actually closing
nduca
2010/11/23 19:39:01
Done.
|
+ |
Property changes on: chrome\browser\resources\gpu\infoview.js |
___________________________________________________________________ |
Added: svn:eol-style |
+ LF |