| 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 11 matching lines...) Expand all Loading... |
| 22 #include "base/string_piece.h" | 22 #include "base/string_piece.h" |
| 23 #include "base/string_util.h" | 23 #include "base/string_util.h" |
| 24 #include "base/thread.h" | 24 #include "base/thread.h" |
| 25 #include "base/tracked_objects.h" | 25 #include "base/tracked_objects.h" |
| 26 #include "base/utf_string_conversions.h" | 26 #include "base/utf_string_conversions.h" |
| 27 #include "chrome/browser/browser.h" | 27 #include "chrome/browser/browser.h" |
| 28 #include "chrome/browser/browser_process.h" | 28 #include "chrome/browser/browser_process.h" |
| 29 #include "chrome/browser/chrome_thread.h" | 29 #include "chrome/browser/chrome_thread.h" |
| 30 #include "chrome/browser/defaults.h" | 30 #include "chrome/browser/defaults.h" |
| 31 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" | 31 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" |
| 32 #include "chrome/browser/labs.h" | |
| 33 #include "chrome/browser/memory_details.h" | 32 #include "chrome/browser/memory_details.h" |
| 34 #include "chrome/browser/metrics/histogram_synchronizer.h" | 33 #include "chrome/browser/metrics/histogram_synchronizer.h" |
| 35 #include "chrome/browser/net/predictor_api.h" | 34 #include "chrome/browser/net/predictor_api.h" |
| 36 #include "chrome/browser/platform_util.h" | 35 #include "chrome/browser/platform_util.h" |
| 37 #include "chrome/browser/prefs/pref_service.h" | 36 #include "chrome/browser/prefs/pref_service.h" |
| 38 #include "chrome/browser/profile.h" | 37 #include "chrome/browser/profile.h" |
| 39 #include "chrome/browser/profile_manager.h" | 38 #include "chrome/browser/profile_manager.h" |
| 40 #include "chrome/browser/renderer_host/render_process_host.h" | 39 #include "chrome/browser/renderer_host/render_process_host.h" |
| 41 #include "chrome/browser/renderer_host/render_view_host.h" | 40 #include "chrome/browser/renderer_host/render_view_host.h" |
| 42 #include "chrome/browser/sync/profile_sync_service.h" | 41 #include "chrome/browser/sync/profile_sync_service.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 89 |
| 91 namespace { | 90 namespace { |
| 92 | 91 |
| 93 // The (alphabetized) paths used for the about pages. | 92 // The (alphabetized) paths used for the about pages. |
| 94 // Note: Keep these in sync with url_constants.h | 93 // Note: Keep these in sync with url_constants.h |
| 95 const char kAppCacheInternalsPath[] = "appcache-internals"; | 94 const char kAppCacheInternalsPath[] = "appcache-internals"; |
| 96 const char kCreditsPath[] = "credits"; | 95 const char kCreditsPath[] = "credits"; |
| 97 const char kCachePath[] = "view-http-cache"; | 96 const char kCachePath[] = "view-http-cache"; |
| 98 const char kDnsPath[] = "dns"; | 97 const char kDnsPath[] = "dns"; |
| 99 const char kHistogramsPath[] = "histograms"; | 98 const char kHistogramsPath[] = "histograms"; |
| 100 const char kLabsPath[] = "labs"; | |
| 101 const char kMemoryRedirectPath[] = "memory-redirect"; | 99 const char kMemoryRedirectPath[] = "memory-redirect"; |
| 102 const char kMemoryPath[] = "memory"; | 100 const char kMemoryPath[] = "memory"; |
| 103 const char kStatsPath[] = "stats"; | 101 const char kStatsPath[] = "stats"; |
| 104 const char kSyncPath[] = "sync"; | 102 const char kSyncPath[] = "sync"; |
| 105 const char kTasksPath[] = "tasks"; | 103 const char kTasksPath[] = "tasks"; |
| 106 const char kTcmallocPath[] = "tcmalloc"; | 104 const char kTcmallocPath[] = "tcmalloc"; |
| 107 const char kTermsPath[] = "terms"; | 105 const char kTermsPath[] = "terms"; |
| 108 const char kVersionPath[] = "version"; | 106 const char kVersionPath[] = "version"; |
| 109 const char kAboutPath[] = "about"; | 107 const char kAboutPath[] = "about"; |
| 110 // Not about:* pages, but included to make about:about look nicer | 108 // Not about:* pages, but included to make about:about look nicer |
| (...skipping 11 matching lines...) Expand all Loading... |
| 122 const char kSysPath[] = "system"; | 120 const char kSysPath[] = "system"; |
| 123 #endif | 121 #endif |
| 124 | 122 |
| 125 // Add path here to be included in about:about | 123 // Add path here to be included in about:about |
| 126 const char *kAllAboutPaths[] = { | 124 const char *kAllAboutPaths[] = { |
| 127 kAppCacheInternalsPath, | 125 kAppCacheInternalsPath, |
| 128 kCachePath, | 126 kCachePath, |
| 129 kCreditsPath, | 127 kCreditsPath, |
| 130 kDnsPath, | 128 kDnsPath, |
| 131 kHistogramsPath, | 129 kHistogramsPath, |
| 132 kLabsPath, | |
| 133 kMemoryPath, | 130 kMemoryPath, |
| 134 kNetInternalsPath, | 131 kNetInternalsPath, |
| 135 kPluginsPath, | 132 kPluginsPath, |
| 136 kStatsPath, | 133 kStatsPath, |
| 137 kSyncPath, | 134 kSyncPath, |
| 138 kTasksPath, | 135 kTasksPath, |
| 139 kTcmallocPath, | 136 kTcmallocPath, |
| 140 kTermsPath, | 137 kTermsPath, |
| 141 kVersionPath, | 138 kVersionPath, |
| 142 #if defined(OS_LINUX) | 139 #if defined(OS_LINUX) |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 }; | 243 }; |
| 247 #endif | 244 #endif |
| 248 | 245 |
| 249 // Individual about handlers --------------------------------------------------- | 246 // Individual about handlers --------------------------------------------------- |
| 250 | 247 |
| 251 std::string AboutAbout() { | 248 std::string AboutAbout() { |
| 252 std::string html; | 249 std::string html; |
| 253 html.append("<html><head><title>About Pages</title></head><body>\n"); | 250 html.append("<html><head><title>About Pages</title></head><body>\n"); |
| 254 html.append("<h2>List of About pages</h2><ul>\n"); | 251 html.append("<h2>List of About pages</h2><ul>\n"); |
| 255 for (size_t i = 0; i < arraysize(kAllAboutPaths); i++) { | 252 for (size_t i = 0; i < arraysize(kAllAboutPaths); i++) { |
| 256 if (kAllAboutPaths[i] == kLabsPath && !about_labs::IsEnabled()) | 253 if (kAllAboutPaths[i] == kNetInternalsPath || |
| 257 continue; | 254 kAllAboutPaths[i] == kPluginsPath || |
| 258 if (kAllAboutPaths[i] == kAppCacheInternalsPath || | |
| 259 kAllAboutPaths[i] == kCachePath || | 255 kAllAboutPaths[i] == kCachePath || |
| 260 kAllAboutPaths[i] == kLabsPath || | 256 kAllAboutPaths[i] == kAppCacheInternalsPath) |
| 261 kAllAboutPaths[i] == kNetInternalsPath || | |
| 262 kAllAboutPaths[i] == kPluginsPath) { | |
| 263 html.append("<li><a href='chrome://"); | 257 html.append("<li><a href='chrome://"); |
| 264 } else { | 258 else |
| 265 html.append("<li><a href='chrome://about/"); | 259 html.append("<li><a href='chrome://about/"); |
| 266 } | |
| 267 html.append(kAllAboutPaths[i]); | 260 html.append(kAllAboutPaths[i]); |
| 268 html.append("/'>about:"); | 261 html.append("/'>about:"); |
| 269 html.append(kAllAboutPaths[i]); | 262 html.append(kAllAboutPaths[i]); |
| 270 html.append("</a>\n"); | 263 html.append("</a>\n"); |
| 271 } | 264 } |
| 272 const char *debug[] = { "crash", "hang", "shorthang" }; | 265 const char *debug[] = { "crash", "hang", "shorthang" }; |
| 273 html.append("</ul><h2>For Debug</h2>"); | 266 html.append("</ul><h2>For Debug</h2>"); |
| 274 html.append("</ul><p>The following pages are for debugging purposes only. " | 267 html.append("</ul><p>The following pages are for debugging purposes only. " |
| 275 "Because they crash or hang the renderer, they're not linked " | 268 "Because they crash or hang the renderer, they're not linked " |
| 276 "directly; you can type them into the address bar if you need " | 269 "directly; you can type them into the address bar if you need " |
| (...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1125 // Just ignore the about:blank and let the TAB_CONTENTS_WEB handle it. | 1118 // Just ignore the about:blank and let the TAB_CONTENTS_WEB handle it. |
| 1126 if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutBlankURL)) | 1119 if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutBlankURL)) |
| 1127 return false; | 1120 return false; |
| 1128 | 1121 |
| 1129 // Rewrite about:cache/* URLs to chrome://view-http-cache/* | 1122 // Rewrite about:cache/* URLs to chrome://view-http-cache/* |
| 1130 if (StartsWithAboutSpecifier(*url, chrome::kAboutCacheURL)) { | 1123 if (StartsWithAboutSpecifier(*url, chrome::kAboutCacheURL)) { |
| 1131 *url = RemapAboutURL(chrome::kNetworkViewCacheURL, *url); | 1124 *url = RemapAboutURL(chrome::kNetworkViewCacheURL, *url); |
| 1132 return true; | 1125 return true; |
| 1133 } | 1126 } |
| 1134 | 1127 |
| 1135 if (about_labs::IsEnabled()) { | |
| 1136 // Rewrite about:labs and about:vaporware to chrome://labs/. | |
| 1137 if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutLabsURL) || | |
| 1138 LowerCaseEqualsASCII(url->spec(), chrome::kAboutVaporwareURL)) { | |
| 1139 *url = GURL(chrome::kChromeUILabsURL); | |
| 1140 return true; | |
| 1141 } | |
| 1142 } | |
| 1143 | |
| 1144 // Rewrite about:net-internals/* URLs to chrome://net-internals/* | 1128 // Rewrite about:net-internals/* URLs to chrome://net-internals/* |
| 1145 if (StartsWithAboutSpecifier(*url, chrome::kAboutNetInternalsURL)) { | 1129 if (StartsWithAboutSpecifier(*url, chrome::kAboutNetInternalsURL)) { |
| 1146 *url = RemapAboutURL(chrome::kNetworkViewInternalsURL, *url); | 1130 *url = RemapAboutURL(chrome::kNetworkViewInternalsURL, *url); |
| 1147 return true; | 1131 return true; |
| 1148 } | 1132 } |
| 1149 | 1133 |
| 1150 // Rewrite about:appcache-internals/* URLs to chrome://appcache/* | 1134 // Rewrite about:appcache-internals/* URLs to chrome://appcache/* |
| 1151 if (StartsWithAboutSpecifier(*url, chrome::kAboutAppCacheInternalsURL)) { | 1135 if (StartsWithAboutSpecifier(*url, chrome::kAboutAppCacheInternalsURL)) { |
| 1152 *url = RemapAboutURL(chrome::kAppCacheViewInternalsURL, *url); | 1136 *url = RemapAboutURL(chrome::kAppCacheViewInternalsURL, *url); |
| 1153 return true; | 1137 return true; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1208 // Run the dialog. This will re-use the existing one if it's already up. | 1192 // Run the dialog. This will re-use the existing one if it's already up. |
| 1209 AboutIPCDialog::RunDialog(); | 1193 AboutIPCDialog::RunDialog(); |
| 1210 return true; | 1194 return true; |
| 1211 } | 1195 } |
| 1212 #endif | 1196 #endif |
| 1213 | 1197 |
| 1214 #endif // OFFICIAL_BUILD | 1198 #endif // OFFICIAL_BUILD |
| 1215 | 1199 |
| 1216 return false; | 1200 return false; |
| 1217 } | 1201 } |
| OLD | NEW |