Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: chrome/browser/browser_about_handler.cc

Issue 5228004: Switch the about:gpu implementation from an about handler to dom_ui.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 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 #include "chrome/browser/browser_about_handler.h" 5 #include "chrome/browser/browser_about_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 html.append("<html><head><title>About Pages</title></head><body>\n"); 267 html.append("<html><head><title>About Pages</title></head><body>\n");
268 html.append("<h2>List of About pages</h2><ul>\n"); 268 html.append("<h2>List of About pages</h2><ul>\n");
269 for (size_t i = 0; i < arraysize(kAllAboutPaths); i++) { 269 for (size_t i = 0; i < arraysize(kAllAboutPaths); i++) {
270 if (kAllAboutPaths[i] == kAppCacheInternalsPath || 270 if (kAllAboutPaths[i] == kAppCacheInternalsPath ||
271 kAllAboutPaths[i] == kBlobInternalsPath || 271 kAllAboutPaths[i] == kBlobInternalsPath ||
272 kAllAboutPaths[i] == kCachePath || 272 kAllAboutPaths[i] == kCachePath ||
273 #if defined(OS_WIN) 273 #if defined(OS_WIN)
274 kAllAboutPaths[i] == kConflictsPath || 274 kAllAboutPaths[i] == kConflictsPath ||
275 #endif 275 #endif
276 kAllAboutPaths[i] == kFlagsPath || 276 kAllAboutPaths[i] == kFlagsPath ||
277 kAllAboutPaths[i] == kGpuPath ||
277 kAllAboutPaths[i] == kNetInternalsPath || 278 kAllAboutPaths[i] == kNetInternalsPath ||
278 kAllAboutPaths[i] == kPluginsPath) { 279 kAllAboutPaths[i] == kPluginsPath) {
279 html.append("<li><a href='chrome://"); 280 html.append("<li><a href='chrome://");
280 } else { 281 } else {
281 html.append("<li><a href='chrome://about/"); 282 html.append("<li><a href='chrome://about/");
282 } 283 }
283 html.append(kAllAboutPaths[i]); 284 html.append(kAllAboutPaths[i]);
284 html.append("/'>about:"); 285 html.append("/'>about:");
285 html.append(kAllAboutPaths[i]); 286 html.append(kAllAboutPaths[i]);
286 html.append("</a>\n"); 287 html.append("</a>\n");
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 return jstemplate_builder::GetTemplatesHtml( 709 return jstemplate_builder::GetTemplatesHtml(
709 sync_html, &strings , "t" /* template root node id */); 710 sync_html, &strings , "t" /* template root node id */);
710 } 711 }
711 712
712 std::string VersionNumberToString(uint32 value) { 713 std::string VersionNumberToString(uint32 value) {
713 int hi = (value >> 8) & 0xff; 714 int hi = (value >> 8) & 0xff;
714 int low = value & 0xff; 715 int low = value & 0xff;
715 return base::IntToString(hi) + "." + base::IntToString(low); 716 return base::IntToString(hi) + "." + base::IntToString(low);
716 } 717 }
717 718
718 namespace {
719
720 #if defined(OS_WIN)
721
722 // Output DxDiagNode tree as HTML tables and nested HTML unordered list
723 // elements.
724 void DxDiagNodeToHTML(std::string* output, const DxDiagNode& node) {
725 output->append("<table>\n");
726
727 for (std::map<std::string, std::string>::const_iterator it =
728 node.values.begin();
729 it != node.values.end();
730 ++it) {
731 output->append("<tr><td><strong>");
732 output->append(EscapeForHTML(it->first));
733 output->append("</strong></td><td>");
734 output->append(EscapeForHTML(it->second));
735 output->append("</td></tr>\n");
736 }
737
738 output->append("</table>\n<ul>\n");
739
740 for (std::map<std::string, DxDiagNode>::const_iterator it =
741 node.children.begin();
742 it != node.children.end();
743 ++it) {
744 output->append("<li><strong>");
745 output->append(EscapeForHTML(it->first));
746 output->append("</strong>");
747
748 DxDiagNodeToHTML(output, it->second);
749
750 output->append("</li>\n");
751 }
752
753 output->append("</ul>\n");
754 }
755
756 #endif // OS_WIN
757
758 }
759
760 std::string AboutGpu() {
761 GPUInfo gpu_info = GpuProcessHost::Get()->gpu_info();
762
763 std::string html;
764 if (!gpu_info.initialized()) {
765 GpuProcessHostUIShim::Get()->CollectGraphicsInfoAsynchronously();
766 // If it's not initialized yet, let the user know and reload the page
767 html.append("<html><head><title>About GPU</title></head>\n");
768 html.append("<body onload=\"setTimeout('window.location.reload(true)',");
769 html.append("2000)\">\n");
770 html.append("<h2>GPU Information</h2>\n");
771 html.append("<p>Retrieving GPU information . . .</p>\n");
772 html.append("</body></html> ");
773 } else {
774 html.append("<html><head><title>About GPU</title></head><body>\n");
775 html.append("<h2>GPU Information</h2>\n");
776 html.append("<table><tr>");
777 html.append("<td><strong>Initialization time</strong></td><td>");
778 html.append(base::Int64ToString(
779 gpu_info.initialization_time().InMilliseconds()));
780 html.append("</td></tr><tr><td>");
781 html.append("<strong>Vendor ID</strong></td><td>");
782 html.append(base::StringPrintf("0x%04x", gpu_info.vendor_id()));
783 html.append("</td></tr><tr><td>");
784 html.append("<strong>Device ID</strong></td><td>");
785 html.append(base::StringPrintf("0x%04x", gpu_info.device_id()));
786 html.append("</td></tr><tr><td>");
787 html.append("<strong>Driver Version</strong></td><td>");
788 html.append(WideToASCII(gpu_info.driver_version()).c_str());
789 html.append("</td></tr><tr><td>");
790 html.append("<strong>Pixel Shader Version</strong></td><td>");
791 html.append(VersionNumberToString(gpu_info.pixel_shader_version()).c_str());
792 html.append("</td></tr><tr><td>");
793 html.append("<strong>Vertex Shader Version</strong></td><td>");
794 html.append(VersionNumberToString(
795 gpu_info.vertex_shader_version()).c_str());
796 html.append("</td></tr><tr><td>");
797 html.append("<strong>GL Version</strong></td><td>");
798 html.append(VersionNumberToString(gpu_info.gl_version()).c_str());
799 html.append("</td></tr></table>");
800
801 #if defined(OS_WIN)
802 html.append("<h2>DirectX Diagnostics</h2>");
803 DxDiagNodeToHTML(&html, gpu_info.dx_diagnostics());
804 #endif
805
806 html.append("</body></html>");
807 }
808 return html;
809 }
810
811 // AboutSource ----------------------------------------------------------------- 719 // AboutSource -----------------------------------------------------------------
812 720
813 AboutSource::AboutSource() 721 AboutSource::AboutSource()
814 : DataSource(chrome::kAboutScheme, MessageLoop::current()) { 722 : DataSource(chrome::kAboutScheme, MessageLoop::current()) {
815 // This should be a singleton. 723 // This should be a singleton.
816 DCHECK(!about_source); 724 DCHECK(!about_source);
817 about_source = this; 725 about_source = this;
818 726
819 // Add us to the global URL handler on the IO thread. 727 // Add us to the global URL handler on the IO thread.
820 BrowserThread::PostTask( 728 BrowserThread::PostTask(
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 response = ResourceBundle::GetSharedInstance().GetRawDataResource( 793 response = ResourceBundle::GetSharedInstance().GetRawDataResource(
886 IDR_TERMS_HTML).as_string(); 794 IDR_TERMS_HTML).as_string();
887 #if defined(OS_LINUX) 795 #if defined(OS_LINUX)
888 } else if (path == kLinuxProxyConfigPath) { 796 } else if (path == kLinuxProxyConfigPath) {
889 response = AboutLinuxProxyConfig(); 797 response = AboutLinuxProxyConfig();
890 } else if (path == kSandboxPath) { 798 } else if (path == kSandboxPath) {
891 response = AboutSandbox(); 799 response = AboutSandbox();
892 #endif 800 #endif
893 } else if (path == kSyncPath) { 801 } else if (path == kSyncPath) {
894 response = AboutSync(); 802 response = AboutSync();
895 } else if (path == kGpuPath) {
896 response = AboutGpu();
897 } 803 }
898 804
899 FinishDataRequest(response, request_id); 805 FinishDataRequest(response, request_id);
900 } 806 }
901 807
902 void AboutSource::FinishDataRequest(const std::string& response, 808 void AboutSource::FinishDataRequest(const std::string& response,
903 int request_id) { 809 int request_id) {
904 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); 810 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes);
905 html_bytes->data.resize(response.size()); 811 html_bytes->data.resize(response.size());
906 std::copy(response.begin(), response.end(), html_bytes->data.begin()); 812 std::copy(response.begin(), response.end(), html_bytes->data.begin());
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 *url = GURL(chrome::kChromeUIFlagsURL); 1025 *url = GURL(chrome::kChromeUIFlagsURL);
1120 return true; 1026 return true;
1121 } 1027 }
1122 1028
1123 // Rewrite about:net-internals/* URLs to chrome://net-internals/* 1029 // Rewrite about:net-internals/* URLs to chrome://net-internals/*
1124 if (StartsWithAboutSpecifier(*url, chrome::kAboutNetInternalsURL)) { 1030 if (StartsWithAboutSpecifier(*url, chrome::kAboutNetInternalsURL)) {
1125 *url = RemapAboutURL(chrome::kNetworkViewInternalsURL, *url); 1031 *url = RemapAboutURL(chrome::kNetworkViewInternalsURL, *url);
1126 return true; 1032 return true;
1127 } 1033 }
1128 1034
1035 // Rewrite about:gpu/* URLs to chrome://gpu/*
1036 if (StartsWithAboutSpecifier(*url, chrome::kAboutGpuURL)) {
1037 *url = RemapAboutURL(chrome::kGpuURL, *url);
1038 return true;
1039 }
1040
1129 // Rewrite about:appcache-internals/* URLs to chrome://appcache/* 1041 // Rewrite about:appcache-internals/* URLs to chrome://appcache/*
1130 if (StartsWithAboutSpecifier(*url, chrome::kAboutAppCacheInternalsURL)) { 1042 if (StartsWithAboutSpecifier(*url, chrome::kAboutAppCacheInternalsURL)) {
1131 *url = RemapAboutURL(chrome::kAppCacheViewInternalsURL, *url); 1043 *url = RemapAboutURL(chrome::kAppCacheViewInternalsURL, *url);
1132 return true; 1044 return true;
1133 } 1045 }
1134 1046
1135 // Rewrite about:plugins to chrome://plugins/. 1047 // Rewrite about:plugins to chrome://plugins/.
1136 if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutPluginsURL)) { 1048 if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutPluginsURL)) {
1137 *url = GURL(chrome::kChromeUIPluginsURL); 1049 *url = GURL(chrome::kChromeUIPluginsURL);
1138 return true; 1050 return true;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 // Run the dialog. This will re-use the existing one if it's already up. 1109 // Run the dialog. This will re-use the existing one if it's already up.
1198 AboutIPCDialog::RunDialog(); 1110 AboutIPCDialog::RunDialog();
1199 return true; 1111 return true;
1200 } 1112 }
1201 #endif 1113 #endif
1202 1114
1203 #endif // OFFICIAL_BUILD 1115 #endif // OFFICIAL_BUILD
1204 1116
1205 return false; 1117 return false;
1206 } 1118 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/browser_about_handler_unittest.cc » ('j') | chrome/browser/resources/gpu/infoview.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698