OLD | NEW |
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 Loading... |
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 Loading... |
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 const GPUInfo& gpu_info = GpuProcessHostUIShim::Get()->gpu_info(); | |
762 | |
763 std::string html; | |
764 | |
765 html.append("<html><head><title>About GPU</title></head>\n"); | |
766 | |
767 if (gpu_info.progress() != GPUInfo::kComplete) { | |
768 GpuProcessHostUIShim::Get()->CollectGraphicsInfoAsynchronously(); | |
769 | |
770 // If it's not fully initialized yet, set a timeout to reload the page. | |
771 html.append("<body onload=\"setTimeout('window.location.reload(true)',"); | |
772 html.append("2000)\">\n"); | |
773 } else { | |
774 html.append("<body>\n"); | |
775 } | |
776 | |
777 html.append("<h2>GPU Information</h2>\n"); | |
778 | |
779 if (gpu_info.progress() == GPUInfo::kUninitialized) { | |
780 html.append("<p>Retrieving GPU information . . .</p>\n"); | |
781 } else { | |
782 html.append("<table><tr>"); | |
783 html.append("<td><strong>Initialization time</strong></td><td>"); | |
784 html.append(base::Int64ToString( | |
785 gpu_info.initialization_time().InMilliseconds())); | |
786 html.append("</td></tr><tr><td>"); | |
787 html.append("<strong>Vendor ID</strong></td><td>"); | |
788 html.append(base::StringPrintf("0x%04x", gpu_info.vendor_id())); | |
789 html.append("</td></tr><tr><td>"); | |
790 html.append("<strong>Device ID</strong></td><td>"); | |
791 html.append(base::StringPrintf("0x%04x", gpu_info.device_id())); | |
792 html.append("</td></tr><tr><td>"); | |
793 html.append("<strong>Driver Version</strong></td><td>"); | |
794 html.append(WideToASCII(gpu_info.driver_version()).c_str()); | |
795 html.append("</td></tr><tr><td>"); | |
796 html.append("<strong>Pixel Shader Version</strong></td><td>"); | |
797 html.append(VersionNumberToString(gpu_info.pixel_shader_version()).c_str()); | |
798 html.append("</td></tr><tr><td>"); | |
799 html.append("<strong>Vertex Shader Version</strong></td><td>"); | |
800 html.append(VersionNumberToString( | |
801 gpu_info.vertex_shader_version()).c_str()); | |
802 html.append("</td></tr><tr><td>"); | |
803 html.append("<strong>GL Version</strong></td><td>"); | |
804 html.append(VersionNumberToString(gpu_info.gl_version()).c_str()); | |
805 html.append("</td></tr></table>"); | |
806 | |
807 #if defined(OS_WIN) | |
808 if (gpu_info.progress() != GPUInfo::kComplete) { | |
809 html.append("<p>Retrieving DirectX Diagnostics . . .</p>\n"); | |
810 } else { | |
811 html.append("<h2>DirectX Diagnostics</h2>"); | |
812 DxDiagNodeToHTML(&html, gpu_info.dx_diagnostics()); | |
813 } | |
814 #endif | |
815 } | |
816 | |
817 html.append("</body></html>"); | |
818 | |
819 return html; | |
820 } | |
821 | |
822 // AboutSource ----------------------------------------------------------------- | 719 // AboutSource ----------------------------------------------------------------- |
823 | 720 |
824 AboutSource::AboutSource() | 721 AboutSource::AboutSource() |
825 : DataSource(chrome::kAboutScheme, MessageLoop::current()) { | 722 : DataSource(chrome::kAboutScheme, MessageLoop::current()) { |
826 // This should be a singleton. | 723 // This should be a singleton. |
827 DCHECK(!about_source); | 724 DCHECK(!about_source); |
828 about_source = this; | 725 about_source = this; |
829 | 726 |
830 // Add us to the global URL handler on the IO thread. | 727 // Add us to the global URL handler on the IO thread. |
831 BrowserThread::PostTask( | 728 BrowserThread::PostTask( |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 793 response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
897 IDR_TERMS_HTML).as_string(); | 794 IDR_TERMS_HTML).as_string(); |
898 #if defined(OS_LINUX) | 795 #if defined(OS_LINUX) |
899 } else if (path == kLinuxProxyConfigPath) { | 796 } else if (path == kLinuxProxyConfigPath) { |
900 response = AboutLinuxProxyConfig(); | 797 response = AboutLinuxProxyConfig(); |
901 } else if (path == kSandboxPath) { | 798 } else if (path == kSandboxPath) { |
902 response = AboutSandbox(); | 799 response = AboutSandbox(); |
903 #endif | 800 #endif |
904 } else if (path == kSyncPath) { | 801 } else if (path == kSyncPath) { |
905 response = AboutSync(); | 802 response = AboutSync(); |
906 } else if (path == kGpuPath) { | |
907 response = AboutGpu(); | |
908 } | 803 } |
909 | 804 |
910 FinishDataRequest(response, request_id); | 805 FinishDataRequest(response, request_id); |
911 } | 806 } |
912 | 807 |
913 void AboutSource::FinishDataRequest(const std::string& response, | 808 void AboutSource::FinishDataRequest(const std::string& response, |
914 int request_id) { | 809 int request_id) { |
915 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); | 810 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); |
916 html_bytes->data.resize(response.size()); | 811 html_bytes->data.resize(response.size()); |
917 std::copy(response.begin(), response.end(), html_bytes->data.begin()); | 812 std::copy(response.begin(), response.end(), html_bytes->data.begin()); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1131 *url = GURL(chrome::kChromeUIFlagsURL); | 1026 *url = GURL(chrome::kChromeUIFlagsURL); |
1132 return true; | 1027 return true; |
1133 } | 1028 } |
1134 | 1029 |
1135 // Rewrite about:net-internals/* URLs to chrome://net-internals/* | 1030 // Rewrite about:net-internals/* URLs to chrome://net-internals/* |
1136 if (StartsWithAboutSpecifier(*url, chrome::kAboutNetInternalsURL)) { | 1031 if (StartsWithAboutSpecifier(*url, chrome::kAboutNetInternalsURL)) { |
1137 *url = RemapAboutURL(chrome::kNetworkViewInternalsURL, *url); | 1032 *url = RemapAboutURL(chrome::kNetworkViewInternalsURL, *url); |
1138 return true; | 1033 return true; |
1139 } | 1034 } |
1140 | 1035 |
| 1036 // Rewrite about:gpu/* URLs to chrome://gpu-internals/* |
| 1037 if (StartsWithAboutSpecifier(*url, chrome::kAboutGpuURL)) { |
| 1038 *url = RemapAboutURL(chrome::kGpuInternalsURL, *url); |
| 1039 return true; |
| 1040 } |
| 1041 |
1141 // Rewrite about:appcache-internals/* URLs to chrome://appcache/* | 1042 // Rewrite about:appcache-internals/* URLs to chrome://appcache/* |
1142 if (StartsWithAboutSpecifier(*url, chrome::kAboutAppCacheInternalsURL)) { | 1043 if (StartsWithAboutSpecifier(*url, chrome::kAboutAppCacheInternalsURL)) { |
1143 *url = RemapAboutURL(chrome::kAppCacheViewInternalsURL, *url); | 1044 *url = RemapAboutURL(chrome::kAppCacheViewInternalsURL, *url); |
1144 return true; | 1045 return true; |
1145 } | 1046 } |
1146 | 1047 |
1147 // Rewrite about:plugins to chrome://plugins/. | 1048 // Rewrite about:plugins to chrome://plugins/. |
1148 if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutPluginsURL)) { | 1049 if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutPluginsURL)) { |
1149 *url = GURL(chrome::kChromeUIPluginsURL); | 1050 *url = GURL(chrome::kChromeUIPluginsURL); |
1150 return true; | 1051 return true; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 // Run the dialog. This will re-use the existing one if it's already up. | 1110 // Run the dialog. This will re-use the existing one if it's already up. |
1210 AboutIPCDialog::RunDialog(); | 1111 AboutIPCDialog::RunDialog(); |
1211 return true; | 1112 return true; |
1212 } | 1113 } |
1213 #endif | 1114 #endif |
1214 | 1115 |
1215 #endif // OFFICIAL_BUILD | 1116 #endif // OFFICIAL_BUILD |
1216 | 1117 |
1217 return false; | 1118 return false; |
1218 } | 1119 } |
OLD | NEW |