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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // Glue between the callback task and the method in the singleton. | 79 // Glue between the callback task and the method in the singleton. |
80 void AboutTcmallocRendererCallback(base::ProcessId pid, std::string output) { | 80 void AboutTcmallocRendererCallback(base::ProcessId pid, std::string output) { |
81 Singleton<AboutTcmallocOutputs>::get()->RendererCallback(pid, output); | 81 Singleton<AboutTcmallocOutputs>::get()->RendererCallback(pid, output); |
82 } | 82 } |
83 #endif | 83 #endif |
84 | 84 |
85 namespace { | 85 namespace { |
86 | 86 |
87 // The (alphabetized) paths used for the about pages. | 87 // The (alphabetized) paths used for the about pages. |
88 const char kCreditsPath[] = "credits"; | 88 const char kCreditsPath[] = "credits"; |
| 89 const char kCachePath[] = "cache"; |
89 const char kDnsPath[] = "dns"; | 90 const char kDnsPath[] = "dns"; |
90 const char kHistogramsPath[] = "histograms"; | 91 const char kHistogramsPath[] = "histograms"; |
91 const char kMemoryRedirectPath[] = "memory-redirect"; | 92 const char kMemoryRedirectPath[] = "memory-redirect"; |
92 const char kMemoryPath[] = "memory"; | 93 const char kMemoryPath[] = "memory"; |
93 const char kStatsPath[] = "stats"; | 94 const char kStatsPath[] = "stats"; |
94 const char kSyncPath[] = "sync"; | 95 const char kSyncPath[] = "sync"; |
95 const char kTasksPath[] = "tasks"; | 96 const char kTasksPath[] = "tasks"; |
96 const char kTcmallocPath[] = "tcmalloc"; | 97 const char kTcmallocPath[] = "tcmalloc"; |
97 const char kTermsPath[] = "terms"; | 98 const char kTermsPath[] = "terms"; |
98 const char kVersionPath[] = "version"; | 99 const char kVersionPath[] = "version"; |
| 100 const char kAboutPath[] = "about"; |
| 101 // Not about:* pages, but included to make about:about look nicer |
| 102 const char kNetInternalsPath[] = "net-internals"; |
| 103 const char kPluginsPath[] = "plugins"; |
99 | 104 |
100 #if defined(OS_LINUX) | 105 #if defined(OS_LINUX) |
101 const char kLinuxProxyConfigPath[] = "linux-proxy-config"; | 106 const char kLinuxProxyConfigPath[] = "linux-proxy-config"; |
102 #endif | 107 #endif |
103 | 108 |
104 #if defined(OS_CHROMEOS) | 109 #if defined(OS_CHROMEOS) |
105 const char kNetworkPath[] = "network"; | 110 const char kNetworkPath[] = "network"; |
106 const char kOSCreditsPath[] = "os-credits"; | 111 const char kOSCreditsPath[] = "os-credits"; |
107 const char kSysPath[] = "system"; | 112 const char kSysPath[] = "system"; |
108 #endif | 113 #endif |
109 | 114 |
| 115 // Add path here to be included in about:about |
| 116 const char *kAllAboutPaths[] = { |
| 117 kCachePath, |
| 118 kCreditsPath, |
| 119 kDnsPath, |
| 120 kHistogramsPath, |
| 121 kMemoryPath, |
| 122 kNetInternalsPath, |
| 123 kPluginsPath, |
| 124 kStatsPath, |
| 125 kSyncPath, |
| 126 kTasksPath, |
| 127 kTcmallocPath, |
| 128 kTermsPath, |
| 129 kVersionPath, |
| 130 #if defined(OS_LINUX) |
| 131 kLinuxProxyConfigPath, |
| 132 #endif |
| 133 #if defined(OS_CHROMEOS) |
| 134 kNetworkPath, |
| 135 kOSCreditsPath, |
| 136 kSysPath, |
| 137 #endif |
| 138 }; |
| 139 |
110 // Points to the singleton AboutSource object, if any. | 140 // Points to the singleton AboutSource object, if any. |
111 ChromeURLDataManager::DataSource* about_source = NULL; | 141 ChromeURLDataManager::DataSource* about_source = NULL; |
112 | 142 |
113 // When you type about:memory, it actually loads an intermediate URL that | 143 // When you type about:memory, it actually loads an intermediate URL that |
114 // redirects you to the final page. This avoids the problem where typing | 144 // redirects you to the final page. This avoids the problem where typing |
115 // "about:memory" on the new tab page or any other page where a process | 145 // "about:memory" on the new tab page or any other page where a process |
116 // transition would occur to the about URL will cause some confusion. | 146 // transition would occur to the about URL will cause some confusion. |
117 // | 147 // |
118 // The problem is that during the processing of the memory page, there are two | 148 // The problem is that during the processing of the memory page, there are two |
119 // processes active, the original and the destination one. This can create the | 149 // processes active, the original and the destination one. This can create the |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 228 |
199 // Used to request the version. | 229 // Used to request the version. |
200 CancelableRequestConsumer consumer_; | 230 CancelableRequestConsumer consumer_; |
201 | 231 |
202 DISALLOW_COPY_AND_ASSIGN(ChromeOSAboutVersionHandler); | 232 DISALLOW_COPY_AND_ASSIGN(ChromeOSAboutVersionHandler); |
203 }; | 233 }; |
204 #endif | 234 #endif |
205 | 235 |
206 // Individual about handlers --------------------------------------------------- | 236 // Individual about handlers --------------------------------------------------- |
207 | 237 |
| 238 std::string AboutAbout() { |
| 239 std::string html; |
| 240 html.append("<html><head><title>About Pages</title></head><body>\n"); |
| 241 html.append("<h2>List of About pages</h2><ul>\n"); |
| 242 for (size_t i = 0; i < arraysize(kAllAboutPaths); i++) { |
| 243 if (kAllAboutPaths[i] == kNetInternalsPath || |
| 244 kAllAboutPaths[i] == kPluginsPath) |
| 245 html.append("<li><a href='chrome://"); |
| 246 else |
| 247 html.append("<li><a href='chrome://about/"); |
| 248 html.append(kAllAboutPaths[i]); |
| 249 html.append("/'>about:"); |
| 250 html.append(kAllAboutPaths[i]); |
| 251 html.append("</a>\n"); |
| 252 } |
| 253 const char *debug[] = { "crash", "hang", "shorthang" }; |
| 254 html.append("</ul><h2>For Debug</h2>"); |
| 255 html.append("</ul><p>The following pages are for debugging purposes only. " |
| 256 "Because they crash or hang the renderer, they're not linked " |
| 257 "directly; you can type them into the address bar if you need " |
| 258 "them.</p><ul>"); |
| 259 for (size_t i = 0; i < arraysize(debug); i++) { |
| 260 html.append("<li>"); |
| 261 html.append("about:"); |
| 262 html.append(debug[i]); |
| 263 html.append("\n"); |
| 264 } |
| 265 html.append("</ul></body></html>"); |
| 266 return html; |
| 267 } |
| 268 |
208 #if defined(OS_CHROMEOS) | 269 #if defined(OS_CHROMEOS) |
209 std::string AboutNetwork(const std::string& query) { | 270 std::string AboutNetwork(const std::string& query) { |
210 int refresh; | 271 int refresh; |
211 StringToInt(query, &refresh); | 272 StringToInt(query, &refresh); |
212 return chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> | 273 return chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> |
213 GetHtmlInfo(refresh); | 274 GetHtmlInfo(refresh); |
214 } | 275 } |
215 #endif | 276 #endif |
216 | 277 |
217 // AboutDnsHandler bounces the request back to the IO thread to collect | 278 // AboutDnsHandler bounces the request back to the IO thread to collect |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 #if defined(OS_CHROMEOS) | 794 #if defined(OS_CHROMEOS) |
734 new ChromeOSAboutVersionHandler(this, request_id); | 795 new ChromeOSAboutVersionHandler(this, request_id); |
735 return; | 796 return; |
736 #else | 797 #else |
737 DictionaryValue value; | 798 DictionaryValue value; |
738 response = AboutVersion(&value); | 799 response = AboutVersion(&value); |
739 #endif | 800 #endif |
740 } else if (path == kCreditsPath) { | 801 } else if (path == kCreditsPath) { |
741 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 802 response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
742 IDR_CREDITS_HTML).as_string(); | 803 IDR_CREDITS_HTML).as_string(); |
| 804 } else if (path == kAboutPath) { |
| 805 response = AboutAbout(); |
743 #if defined(OS_CHROMEOS) | 806 #if defined(OS_CHROMEOS) |
744 } else if (path == kOSCreditsPath) { | 807 } else if (path == kOSCreditsPath) { |
745 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 808 response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
746 IDR_OS_CREDITS_HTML).as_string(); | 809 IDR_OS_CREDITS_HTML).as_string(); |
747 } else if (path == kNetworkPath) { | 810 } else if (path == kNetworkPath) { |
748 response = AboutNetwork(info); | 811 response = AboutNetwork(info); |
749 #endif | 812 #endif |
750 } else if (path == kTermsPath) { | 813 } else if (path == kTermsPath) { |
751 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 814 response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
752 IDR_TERMS_HTML).as_string(); | 815 IDR_TERMS_HTML).as_string(); |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 // Run the dialog. This will re-use the existing one if it's already up. | 1106 // Run the dialog. This will re-use the existing one if it's already up. |
1044 AboutIPCDialog::RunDialog(); | 1107 AboutIPCDialog::RunDialog(); |
1045 return true; | 1108 return true; |
1046 } | 1109 } |
1047 #endif | 1110 #endif |
1048 | 1111 |
1049 #endif // OFFICIAL_BUILD | 1112 #endif // OFFICIAL_BUILD |
1050 | 1113 |
1051 return false; | 1114 return false; |
1052 } | 1115 } |
OLD | NEW |