| 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"; | |
| 90 const char kDnsPath[] = "dns"; | 89 const char kDnsPath[] = "dns"; |
| 91 const char kHistogramsPath[] = "histograms"; | 90 const char kHistogramsPath[] = "histograms"; |
| 92 const char kMemoryRedirectPath[] = "memory-redirect"; | 91 const char kMemoryRedirectPath[] = "memory-redirect"; |
| 93 const char kMemoryPath[] = "memory"; | 92 const char kMemoryPath[] = "memory"; |
| 94 const char kStatsPath[] = "stats"; | 93 const char kStatsPath[] = "stats"; |
| 95 const char kSyncPath[] = "sync"; | 94 const char kSyncPath[] = "sync"; |
| 96 const char kTasksPath[] = "tasks"; | 95 const char kTasksPath[] = "tasks"; |
| 97 const char kTcmallocPath[] = "tcmalloc"; | 96 const char kTcmallocPath[] = "tcmalloc"; |
| 98 const char kTermsPath[] = "terms"; | 97 const char kTermsPath[] = "terms"; |
| 99 const char kVersionPath[] = "version"; | 98 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"; | |
| 104 | 99 |
| 105 #if defined(OS_LINUX) | 100 #if defined(OS_LINUX) |
| 106 const char kLinuxProxyConfigPath[] = "linux-proxy-config"; | 101 const char kLinuxProxyConfigPath[] = "linux-proxy-config"; |
| 107 #endif | 102 #endif |
| 108 | 103 |
| 109 #if defined(OS_CHROMEOS) | 104 #if defined(OS_CHROMEOS) |
| 110 const char kNetworkPath[] = "network"; | 105 const char kNetworkPath[] = "network"; |
| 111 const char kOSCreditsPath[] = "os-credits"; | 106 const char kOSCreditsPath[] = "os-credits"; |
| 112 const char kSysPath[] = "system"; | 107 const char kSysPath[] = "system"; |
| 113 #endif | 108 #endif |
| 114 | 109 |
| 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 kOSCreditPath, | |
| 136 kSysPath, | |
| 137 #endif | |
| 138 }; | |
| 139 | |
| 140 // Points to the singleton AboutSource object, if any. | 110 // Points to the singleton AboutSource object, if any. |
| 141 ChromeURLDataManager::DataSource* about_source = NULL; | 111 ChromeURLDataManager::DataSource* about_source = NULL; |
| 142 | 112 |
| 143 // When you type about:memory, it actually loads an intermediate URL that | 113 // When you type about:memory, it actually loads an intermediate URL that |
| 144 // redirects you to the final page. This avoids the problem where typing | 114 // redirects you to the final page. This avoids the problem where typing |
| 145 // "about:memory" on the new tab page or any other page where a process | 115 // "about:memory" on the new tab page or any other page where a process |
| 146 // transition would occur to the about URL will cause some confusion. | 116 // transition would occur to the about URL will cause some confusion. |
| 147 // | 117 // |
| 148 // The problem is that during the processing of the memory page, there are two | 118 // The problem is that during the processing of the memory page, there are two |
| 149 // processes active, the original and the destination one. This can create the | 119 // 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... |
| 228 | 198 |
| 229 // Used to request the version. | 199 // Used to request the version. |
| 230 CancelableRequestConsumer consumer_; | 200 CancelableRequestConsumer consumer_; |
| 231 | 201 |
| 232 DISALLOW_COPY_AND_ASSIGN(ChromeOSAboutVersionHandler); | 202 DISALLOW_COPY_AND_ASSIGN(ChromeOSAboutVersionHandler); |
| 233 }; | 203 }; |
| 234 #endif | 204 #endif |
| 235 | 205 |
| 236 // Individual about handlers --------------------------------------------------- | 206 // Individual about handlers --------------------------------------------------- |
| 237 | 207 |
| 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 | |
| 269 #if defined(OS_CHROMEOS) | 208 #if defined(OS_CHROMEOS) |
| 270 std::string AboutNetwork(const std::string& query) { | 209 std::string AboutNetwork(const std::string& query) { |
| 271 int refresh; | 210 int refresh; |
| 272 StringToInt(query, &refresh); | 211 StringToInt(query, &refresh); |
| 273 return chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> | 212 return chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> |
| 274 GetHtmlInfo(refresh); | 213 GetHtmlInfo(refresh); |
| 275 } | 214 } |
| 276 #endif | 215 #endif |
| 277 | 216 |
| 278 // AboutDnsHandler bounces the request back to the IO thread to collect | 217 // AboutDnsHandler bounces the request back to the IO thread to collect |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 #if defined(OS_CHROMEOS) | 733 #if defined(OS_CHROMEOS) |
| 795 new ChromeOSAboutVersionHandler(this, request_id); | 734 new ChromeOSAboutVersionHandler(this, request_id); |
| 796 return; | 735 return; |
| 797 #else | 736 #else |
| 798 DictionaryValue value; | 737 DictionaryValue value; |
| 799 response = AboutVersion(&value); | 738 response = AboutVersion(&value); |
| 800 #endif | 739 #endif |
| 801 } else if (path == kCreditsPath) { | 740 } else if (path == kCreditsPath) { |
| 802 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 741 response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 803 IDR_CREDITS_HTML).as_string(); | 742 IDR_CREDITS_HTML).as_string(); |
| 804 } else if (path == kAboutPath) { | |
| 805 response = AboutAbout(); | |
| 806 #if defined(OS_CHROMEOS) | 743 #if defined(OS_CHROMEOS) |
| 807 } else if (path == kOSCreditsPath) { | 744 } else if (path == kOSCreditsPath) { |
| 808 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 745 response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 809 IDR_OS_CREDITS_HTML).as_string(); | 746 IDR_OS_CREDITS_HTML).as_string(); |
| 810 } else if (path == kNetworkPath) { | 747 } else if (path == kNetworkPath) { |
| 811 response = AboutNetwork(info); | 748 response = AboutNetwork(info); |
| 812 #endif | 749 #endif |
| 813 } else if (path == kTermsPath) { | 750 } else if (path == kTermsPath) { |
| 814 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 751 response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 815 IDR_TERMS_HTML).as_string(); | 752 IDR_TERMS_HTML).as_string(); |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1106 // Run the dialog. This will re-use the existing one if it's already up. | 1043 // Run the dialog. This will re-use the existing one if it's already up. |
| 1107 AboutIPCDialog::RunDialog(); | 1044 AboutIPCDialog::RunDialog(); |
| 1108 return true; | 1045 return true; |
| 1109 } | 1046 } |
| 1110 #endif | 1047 #endif |
| 1111 | 1048 |
| 1112 #endif // OFFICIAL_BUILD | 1049 #endif // OFFICIAL_BUILD |
| 1113 | 1050 |
| 1114 return false; | 1051 return false; |
| 1115 } | 1052 } |
| OLD | NEW |