Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 void AboutTcmallocRendererCallback(base::ProcessId pid, | 100 void AboutTcmallocRendererCallback(base::ProcessId pid, |
| 101 const std::string& output) { | 101 const std::string& output) { |
| 102 AboutTcmallocOutputs::GetInstance()->RendererCallback(pid, output); | 102 AboutTcmallocOutputs::GetInstance()->RendererCallback(pid, output); |
| 103 } | 103 } |
| 104 #endif | 104 #endif |
| 105 | 105 |
| 106 namespace { | 106 namespace { |
| 107 | 107 |
| 108 // Add paths here to be included in chrome://chrome-urls/. | 108 // Add paths here to be included in chrome://chrome-urls/. |
| 109 // These paths will also be suggested by BuiltinProvider. | 109 // These paths will also be suggested by BuiltinProvider. |
| 110 const char* kChromePaths[] = { | 110 const char* const kChromePaths[] = { |
| 111 chrome::kChromeUIAppCacheInternalsHost, | 111 chrome::kChromeUIAppCacheInternalsHost, |
| 112 chrome::kChromeUIBlobInternalsHost, | 112 chrome::kChromeUIBlobInternalsHost, |
| 113 chrome::kChromeUIChromeURLsHost, | 113 chrome::kChromeUIChromeURLsHost, |
| 114 chrome::kChromeUICrashesHost, | 114 chrome::kChromeUICrashesHost, |
| 115 chrome::kChromeUICreditsHost, | 115 chrome::kChromeUICreditsHost, |
| 116 chrome::kChromeUIDNSHost, | 116 chrome::kChromeUIDNSHost, |
| 117 chrome::kChromeUIFlagsHost, | 117 chrome::kChromeUIFlagsHost, |
| 118 chrome::kChromeUIFlashHost, | 118 chrome::kChromeUIFlashHost, |
| 119 chrome::kChromeUIGpuInternalsHost, | 119 chrome::kChromeUIGpuInternalsHost, |
| 120 chrome::kChromeUIHistogramsHost, | 120 chrome::kChromeUIHistogramsHost, |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 139 #endif | 139 #endif |
| 140 #if defined(OS_CHROMEOS) | 140 #if defined(OS_CHROMEOS) |
| 141 chrome::kChromeUINetworkHost, | 141 chrome::kChromeUINetworkHost, |
| 142 chrome::kChromeUICryptohomeHost, | 142 chrome::kChromeUICryptohomeHost, |
| 143 chrome::kChromeUIOSCreditsHost, | 143 chrome::kChromeUIOSCreditsHost, |
| 144 #endif | 144 #endif |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 // Debug paths, presented without links in chrome://about. | 147 // Debug paths, presented without links in chrome://about. |
| 148 // These paths will not be suggested by BuiltinProvider. | 148 // These paths will not be suggested by BuiltinProvider. |
| 149 const char* kDebugChromePaths[] = { | 149 const char* const kDebugChromePaths[] = { |
| 150 chrome::kChromeUICrashHost, | 150 chrome::kChromeUICrashHost, |
| 151 chrome::kChromeUIKillHost, | 151 chrome::kChromeUIKillHost, |
| 152 chrome::kChromeUIHangHost, | 152 chrome::kChromeUIHangHost, |
| 153 chrome::kChromeUIShorthangHost, | 153 chrome::kChromeUIShorthangHost, |
| 154 chrome::kChromeUIGpuCleanHost, | 154 chrome::kChromeUIGpuCleanHost, |
| 155 chrome::kChromeUIGpuCrashHost, | 155 chrome::kChromeUIGpuCrashHost, |
| 156 chrome::kChromeUIGpuHangHost | 156 chrome::kChromeUIGpuHangHost |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 // AboutSource handles these chrome:// paths. | 159 // AboutSource handles these chrome:// paths. |
| 160 const char *kAboutSourceNames[] = { | 160 const char* const kAboutSourceNames[] = { |
| 161 chrome::kChromeUIChromeURLsHost, | 161 chrome::kChromeUIChromeURLsHost, |
| 162 chrome::kChromeUICreditsHost, | 162 chrome::kChromeUICreditsHost, |
| 163 chrome::kChromeUIDNSHost, | 163 chrome::kChromeUIDNSHost, |
| 164 chrome::kChromeUIHistogramsHost, | 164 chrome::kChromeUIHistogramsHost, |
| 165 chrome::kChromeUIMemoryHost, | 165 chrome::kChromeUIMemoryHost, |
| 166 chrome::kChromeUIMemoryRedirectHost, | 166 chrome::kChromeUIMemoryRedirectHost, |
| 167 chrome::kChromeUIStatsHost, | 167 chrome::kChromeUIStatsHost, |
| 168 chrome::kChromeUITermsHost, | 168 chrome::kChromeUITermsHost, |
| 169 chrome::kChromeUIVersionHost, | 169 chrome::kChromeUIVersionHost, |
| 170 #ifdef TRACK_ALL_TASK_OBJECTS | 170 #ifdef TRACK_ALL_TASK_OBJECTS |
| 171 chrome::kChromeUITasksHost, | 171 chrome::kChromeUITasksHost, |
| 172 #endif | 172 #endif |
| 173 #if defined(USE_TCMALLOC) | 173 #if defined(USE_TCMALLOC) |
| 174 chrome::kChromeUITCMallocHost, | 174 chrome::kChromeUITCMallocHost, |
| 175 #endif | 175 #endif |
| 176 #if defined(OS_LINUX) | 176 #if defined(OS_LINUX) |
| 177 chrome::kChromeUILinuxProxyConfigHost, | 177 chrome::kChromeUILinuxProxyConfigHost, |
| 178 chrome::kChromeUISandboxHost, | 178 chrome::kChromeUISandboxHost, |
| 179 #endif | 179 #endif |
| 180 #if defined(OS_CHROMEOS) | 180 #if defined(OS_CHROMEOS) |
| 181 chrome::kChromeUINetworkHost, | 181 chrome::kChromeUINetworkHost, |
| 182 chrome::kChromeUICryptohomeHost, | 182 chrome::kChromeUICryptohomeHost, |
| 183 chrome::kChromeUIOSCreditsHost, | 183 chrome::kChromeUIOSCreditsHost, |
| 184 #endif | 184 #endif |
| 185 }; | 185 }; |
| 186 | 186 |
| 187 const char kCreditsJsPath[] = "credits.js"; | |
| 188 const char kMemoryJsPath[] = "memory.js"; | |
| 189 const char kStatsJsPath[] = "stats.js"; | |
| 190 const char kStringsJsPath[] = "strings.js"; | |
| 191 const char kVersionJsPath[] = "version.js"; | |
| 192 | |
| 193 } // namespace | |
| 194 | |
| 187 class AboutSource : public ChromeURLDataManager::DataSource { | 195 class AboutSource : public ChromeURLDataManager::DataSource { |
| 188 public: | 196 public: |
| 189 // Construct a data source for the specified |source_name|. | 197 // Construct a data source for the specified |source_name|. |
| 190 AboutSource(const std::string& source_name, Profile* profile); | 198 AboutSource(const std::string& source_name, Profile* profile); |
| 191 | 199 |
| 192 // Called when the network layer has requested a resource underneath | 200 // Called when the network layer has requested a resource underneath |
| 193 // the path we registered. | 201 // the path we registered. |
| 194 virtual void StartDataRequest(const std::string& path, | 202 virtual void StartDataRequest(const std::string& path, |
| 195 bool is_incognito, | 203 bool is_incognito, |
| 196 int request_id) OVERRIDE; | 204 int request_id) OVERRIDE; |
| 197 | 205 |
| 198 virtual std::string GetMimeType(const std::string&) const OVERRIDE { | 206 virtual std::string GetMimeType(const std::string& path) const OVERRIDE; |
| 199 return "text/html"; | |
| 200 } | |
| 201 | 207 |
| 202 // Send the response data. | 208 // Send the response data. |
| 203 void FinishDataRequest(const std::string& html, int request_id); | 209 void FinishDataRequest(const std::string& html, int request_id); |
| 204 | 210 |
| 205 Profile* profile() { return profile_; } | 211 Profile* profile() { return profile_; } |
| 206 | 212 |
| 207 private: | 213 private: |
| 208 virtual ~AboutSource(); | 214 virtual ~AboutSource(); |
| 209 | 215 |
| 210 Profile* profile_; | 216 Profile* profile_; |
| 211 | 217 |
| 212 DISALLOW_COPY_AND_ASSIGN(AboutSource); | 218 DISALLOW_COPY_AND_ASSIGN(AboutSource); |
| 213 }; | 219 }; |
| 214 | 220 |
| 221 namespace { | |
| 222 | |
| 215 // Register a data source for a known source name. Safe to call multiple times. | 223 // Register a data source for a known source name. Safe to call multiple times. |
| 216 // |name| may be an unkown host (e.g. "chrome://foo/"); only handle known hosts. | 224 // |name| may be an unkown host (e.g. "chrome://foo/"); only handle known hosts. |
| 217 void InitializeAboutDataSource(const std::string& name, Profile* profile) { | 225 void InitializeAboutDataSource(const std::string& name, Profile* profile) { |
| 218 ChromeURLDataManager* manager = profile->GetChromeURLDataManager(); | 226 ChromeURLDataManager* manager = profile->GetChromeURLDataManager(); |
| 219 for (size_t i = 0; i < arraysize(kAboutSourceNames); i++) { | 227 for (size_t i = 0; i < arraysize(kAboutSourceNames); i++) { |
| 220 if (name == kAboutSourceNames[i]) { | 228 if (name == kAboutSourceNames[i]) { |
| 221 manager->AddDataSource(new AboutSource(name, profile)); | 229 manager->AddDataSource(new AboutSource(name, profile)); |
| 222 return; | 230 return; |
| 223 } | 231 } |
| 224 } | 232 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 353 | 361 |
| 354 std::string contents_; | 362 std::string contents_; |
| 355 | 363 |
| 356 DISALLOW_COPY_AND_ASSIGN(ChromeOSTermsHandler); | 364 DISALLOW_COPY_AND_ASSIGN(ChromeOSTermsHandler); |
| 357 }; | 365 }; |
| 358 | 366 |
| 359 #endif | 367 #endif |
| 360 | 368 |
| 361 // Individual about handlers --------------------------------------------------- | 369 // Individual about handlers --------------------------------------------------- |
| 362 | 370 |
| 371 namespace { | |
| 372 | |
| 373 void AppendHeader(std::string* output, int refresh, | |
| 374 const std::string& unescaped_title) { | |
| 375 output->append("<!DOCTYPE HTML>\n<html>\n<head>\n"); | |
| 376 if (!unescaped_title.empty()) { | |
| 377 output->append("<title>"); | |
| 378 output->append(EscapeForHTML(unescaped_title)); | |
| 379 output->append("</title>\n"); | |
| 380 } | |
| 381 output->append( | |
| 382 "<meta charset=\"utf-8\">\n<meta http-equiv=\"X-WebKit-CSP\" " | |
| 383 "content=\"object-src 'none'; script-src 'self'\">\n"); | |
| 384 if (refresh > 0) { | |
| 385 output->append("<meta http-equiv=\"refresh\" content=\""); | |
| 386 output->append(base::IntToString(refresh)); | |
| 387 output->append("\"/>\n"); | |
| 388 } | |
| 389 } | |
| 390 | |
| 391 void AppendBody(std::string *output) { | |
| 392 output->append("</head>\n<body>\n"); | |
| 393 } | |
| 394 | |
| 395 void AppendFooter(std::string *output) { | |
| 396 output->append("</body>\n</html>\n"); | |
| 397 } | |
| 398 | |
| 363 std::string ChromeURLs() { | 399 std::string ChromeURLs() { |
| 364 std::string html("<html><head><title>Chrome URLs</title></head>\n" | 400 std::string html; |
| 365 "<body><h2>List of Chrome URLs</h2>\n<ul>"); | 401 AppendHeader(&html, 0, "Chrome URLs"); |
| 402 AppendBody(&html); | |
| 403 html += "<h2>List of Chrome URLs</h2>\n<ul>\n"; | |
| 366 std::vector<std::string> paths(ChromePaths()); | 404 std::vector<std::string> paths(ChromePaths()); |
| 367 for (std::vector<std::string>::const_iterator i = paths.begin(); | 405 for (std::vector<std::string>::const_iterator i = paths.begin(); |
| 368 i != paths.end(); ++i) | 406 i != paths.end(); ++i) |
| 369 html += "<li><a href='chrome://" + *i + "/'>chrome://" + *i + "</a></li>\n"; | 407 html += "<li><a href='chrome://" + *i + "/'>chrome://" + *i + "</a></li>\n"; |
| 370 html += "</ul>\n<h2>For Debug</h2>\n" | 408 html += "</ul>\n<h2>For Debug</h2>\n" |
| 371 "<p>The following pages are for debugging purposes only. Because they " | 409 "<p>The following pages are for debugging purposes only. Because they " |
| 372 "crash or hang the renderer, they're not linked directly; you can type " | 410 "crash or hang the renderer, they're not linked directly; you can type " |
| 373 "them into the address bar if you need them.</p>\n<ul>"; | 411 "them into the address bar if you need them.</p>\n<ul>"; |
| 374 for (size_t i = 0; i < arraysize(kDebugChromePaths); i++) | 412 for (size_t i = 0; i < arraysize(kDebugChromePaths); i++) |
| 375 html += "<li>chrome://" + std::string(kDebugChromePaths[i]) + "</li>\n"; | 413 html += "<li>chrome://" + std::string(kDebugChromePaths[i]) + "</li>\n"; |
| 376 html += "</ul>\n</body></html>"; | 414 html += "</ul>\n"; |
| 415 AppendFooter(&html); | |
| 377 return html; | 416 return html; |
| 378 } | 417 } |
| 379 | 418 |
| 380 #if defined(OS_CHROMEOS) | 419 #if defined(OS_CHROMEOS) |
| 381 | 420 |
| 382 namespace { | |
| 383 // Html output helper functions | 421 // Html output helper functions |
| 384 // TODO(stevenjb): L10N this. | 422 // TODO(stevenjb): L10N this. |
| 385 | 423 |
| 386 // Helper function to wrap Html with <th> tag. | 424 // Helper function to wrap Html with <th> tag. |
| 387 std::string WrapWithTH(const std::string& text) { | 425 std::string WrapWithTH(const std::string& text) { |
| 388 return "<th>" + text + "</th>"; | 426 return "<th>" + text + "</th>"; |
| 389 } | 427 } |
| 390 | 428 |
| 391 // Helper function to wrap Html with <td> tag. | 429 // Helper function to wrap Html with <td> tag. |
| 392 std::string WrapWithTD(const std::string& text) { | 430 std::string WrapWithTD(const std::string& text) { |
| 393 return "<td>" + text + "</td>"; | 431 return "<td>" + text + "</td>"; |
| 394 } | 432 } |
| 395 | 433 |
| 396 // Helper function to wrap Html with <tr> tag. | 434 // Helper function to wrap Html with <tr> tag. |
| 397 std::string WrapWithTR(const std::string& text) { | 435 std::string WrapWithTR(const std::string& text) { |
| 398 return "<tr>" + text + "</tr>"; | 436 return "<tr>" + text + "</tr>"; |
| 399 } | 437 } |
| 400 | 438 |
| 401 std::string AboutHeader(int refresh, const std::string& name) { | 439 void AppendRefresh(std::string *output, int refresh, const std::string& name) { |
| 402 std::string output; | |
| 403 output.append("<head>"); | |
| 404 output.append("<title>About " + name + "</title>"); | |
| 405 if (refresh > 0) | |
| 406 output.append("<meta http-equiv=\"refresh\" content=\"" + | |
| 407 base::IntToString(refresh) + "\"/>"); | |
| 408 output.append("</head>"); | |
| 409 return output; | |
| 410 } | |
| 411 | |
| 412 std::string AboutRefresh(int refresh, const std::string& name) { | |
| 413 std::string output; | |
| 414 if (refresh > 0) { | 440 if (refresh > 0) { |
| 415 output.append("(Auto-refreshing page every " + | 441 output->append("(Auto-refreshing page every "); |
| 416 base::IntToString(refresh) + "s)"); | 442 output->append(base::IntToString(refresh)); |
| 443 output->append("s)"); | |
| 417 } else { | 444 } else { |
| 418 output.append("(To auto-refresh this page: about:" + name | 445 output->append("(To auto-refresh this page: about:"); |
| 419 + "/<secs>)"); | 446 output->append(name); |
| 447 output->append("/<secs>)"); | |
| 420 } | 448 } |
| 421 return output; | |
| 422 } | 449 } |
| 423 | 450 |
| 424 // Helper function to create an Html table header for a Network. | 451 // Helper function to create an Html table header for a Network. |
| 425 std::string ToHtmlTableHeader(const chromeos::Network* network) { | 452 std::string ToHtmlTableHeader(const chromeos::Network* network) { |
| 426 std::string str = | 453 std::string str = |
| 427 WrapWithTH("Name") + | 454 WrapWithTH("Name") + |
| 428 WrapWithTH("Active") + | 455 WrapWithTH("Active") + |
| 429 WrapWithTH("State"); | 456 WrapWithTH("State"); |
| 430 if (network->type() == chromeos::TYPE_WIFI || | 457 if (network->type() == chromeos::TYPE_WIFI || |
| 431 network->type() == chromeos::TYPE_CELLULAR) { | 458 network->type() == chromeos::TYPE_CELLULAR) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 } | 520 } |
| 494 str += WrapWithTD(network->failed() ? network->GetErrorString() : ""); | 521 str += WrapWithTD(network->failed() ? network->GetErrorString() : ""); |
| 495 str += WrapWithTD(network->ip_address()); | 522 str += WrapWithTD(network->ip_address()); |
| 496 return WrapWithTR(str); | 523 return WrapWithTR(str); |
| 497 } | 524 } |
| 498 | 525 |
| 499 std::string GetNetworkHtmlInfo(int refresh) { | 526 std::string GetNetworkHtmlInfo(int refresh) { |
| 500 chromeos::NetworkLibrary* cros = | 527 chromeos::NetworkLibrary* cros = |
| 501 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 528 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| 502 std::string output; | 529 std::string output; |
| 503 output.append("<html>"); | 530 AppendHeader(&output, refresh, "About Network"); |
| 504 output.append(AboutHeader(refresh, "Network")); | 531 AppendBody(&output); |
| 505 output.append("<body>"); | 532 AppendRefresh(&output, refresh, "network"); |
| 506 output.append(AboutRefresh(refresh, "network")); | |
| 507 | 533 |
| 508 if (cros->ethernet_enabled()) { | 534 if (cros->ethernet_enabled()) { |
| 509 output.append("<h3>Ethernet:</h3><table border=1>"); | 535 output.append("<h3>Ethernet:</h3><table border=1>"); |
| 510 const chromeos::EthernetNetwork* ethernet = cros->ethernet_network(); | 536 const chromeos::EthernetNetwork* ethernet = cros->ethernet_network(); |
| 511 if (ethernet) { | 537 if (ethernet) { |
| 512 output.append(ToHtmlTableHeader(ethernet)); | 538 output.append(ToHtmlTableHeader(ethernet)); |
| 513 output.append(ToHtmlTableRow(ethernet)); | 539 output.append(ToHtmlTableRow(ethernet)); |
| 514 } | 540 } |
| 515 } | 541 } |
| 516 | 542 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 552 const chromeos::WifiNetworkVector& remembered_wifi_networks = | 578 const chromeos::WifiNetworkVector& remembered_wifi_networks = |
| 553 cros->remembered_wifi_networks(); | 579 cros->remembered_wifi_networks(); |
| 554 for (size_t i = 0; i < remembered_wifi_networks.size(); ++i) { | 580 for (size_t i = 0; i < remembered_wifi_networks.size(); ++i) { |
| 555 if (i == 0) | 581 if (i == 0) |
| 556 output.append( | 582 output.append( |
| 557 ToHtmlTableHeader(remembered_wifi_networks[i])); | 583 ToHtmlTableHeader(remembered_wifi_networks[i])); |
| 558 output.append(ToHtmlTableRow(remembered_wifi_networks[i])); | 584 output.append(ToHtmlTableRow(remembered_wifi_networks[i])); |
| 559 } | 585 } |
| 560 } | 586 } |
| 561 | 587 |
| 562 output.append("</table></body></html>"); | 588 output.append("</table>"); |
| 589 AppendFooter(&output); | |
| 563 return output; | 590 return output; |
| 564 } | 591 } |
| 565 | 592 |
| 566 std::string AboutNetwork(const std::string& query) { | 593 std::string AboutNetwork(const std::string& query) { |
| 567 int refresh; | 594 int refresh; |
| 568 base::StringToInt(query, &refresh); | 595 base::StringToInt(query, &refresh); |
| 569 return GetNetworkHtmlInfo(refresh); | 596 return GetNetworkHtmlInfo(refresh); |
| 570 } | 597 } |
| 571 | 598 |
| 572 std::string AddBoolRow(const std::string& name, bool value) { | 599 std::string AddBoolRow(const std::string& name, bool value) { |
| 573 std::string row; | 600 std::string row; |
| 574 row.append(WrapWithTD(name)); | 601 row.append(WrapWithTD(name)); |
| 575 row.append(WrapWithTD(value ? "true" : "false")); | 602 row.append(WrapWithTD(value ? "true" : "false")); |
| 576 return WrapWithTR(row); | 603 return WrapWithTR(row); |
| 577 } | 604 } |
| 578 | 605 |
| 579 std::string AddStringRow(const std::string& name, const std::string& value) { | 606 std::string AddStringRow(const std::string& name, const std::string& value) { |
| 580 std::string row; | 607 std::string row; |
| 581 row.append(WrapWithTD(name)); | 608 row.append(WrapWithTD(name)); |
| 582 row.append(WrapWithTD(value)); | 609 row.append(WrapWithTD(value)); |
| 583 return WrapWithTR(row); | 610 return WrapWithTR(row); |
| 584 } | 611 } |
| 585 | 612 |
| 586 std::string GetCryptohomeHtmlInfo(int refresh) { | 613 std::string GetCryptohomeHtmlInfo(int refresh) { |
| 587 chromeos::CryptohomeLibrary* cryptohome = | 614 chromeos::CryptohomeLibrary* cryptohome = |
| 588 chromeos::CrosLibrary::Get()->GetCryptohomeLibrary(); | 615 chromeos::CrosLibrary::Get()->GetCryptohomeLibrary(); |
| 589 std::string output; | 616 std::string output; |
| 590 output.append("<html>"); | 617 AppendHeader(&output, refresh, "About Cryptohome"); |
| 591 output.append(AboutHeader(refresh, "Cryptohome")); | 618 AppendBody(&output); |
| 592 output.append("<body>"); | 619 AppendRefresh(&output, refresh, "cryptohome"); |
| 593 output.append(AboutRefresh(refresh, "cryptohome")); | |
| 594 | 620 |
| 595 output.append("<h3>CryptohomeLibrary:</h3>"); | 621 output.append("<h3>CryptohomeLibrary:</h3>"); |
| 596 output.append("<table>"); | 622 output.append("<table>"); |
| 597 output.append(AddBoolRow("IsMounted", cryptohome->IsMounted())); | 623 output.append(AddBoolRow("IsMounted", cryptohome->IsMounted())); |
| 598 output.append(AddBoolRow("TpmIsReady", cryptohome->TpmIsReady())); | 624 output.append(AddBoolRow("TpmIsReady", cryptohome->TpmIsReady())); |
| 599 output.append(AddBoolRow("TpmIsEnabled", cryptohome->TpmIsEnabled())); | 625 output.append(AddBoolRow("TpmIsEnabled", cryptohome->TpmIsEnabled())); |
| 600 output.append(AddBoolRow("TpmIsOwned", cryptohome->TpmIsOwned())); | 626 output.append(AddBoolRow("TpmIsOwned", cryptohome->TpmIsOwned())); |
| 601 output.append(AddBoolRow("TpmIsBeingOwned", cryptohome->TpmIsBeingOwned())); | 627 output.append(AddBoolRow("TpmIsBeingOwned", cryptohome->TpmIsBeingOwned())); |
| 602 output.append(AddBoolRow("Pkcs11IsTpmTokenReady", | 628 output.append(AddBoolRow("Pkcs11IsTpmTokenReady", |
| 603 cryptohome->Pkcs11IsTpmTokenReady())); | 629 cryptohome->Pkcs11IsTpmTokenReady())); |
| 604 output.append("</table>"); | 630 output.append("</table>"); |
| 605 | 631 |
| 606 std::string token_name, user_pin; | 632 std::string token_name, user_pin; |
| 607 crypto::GetTPMTokenInfo(&token_name, &user_pin); | 633 crypto::GetTPMTokenInfo(&token_name, &user_pin); |
| 608 output.append("<h3>crypto:</h3>"); | 634 output.append("<h3>crypto:</h3>"); |
| 609 output.append("<table>"); | 635 output.append("<table>"); |
| 610 output.append(AddBoolRow("IsTPMTokenReady", crypto::IsTPMTokenReady())); | 636 output.append(AddBoolRow("IsTPMTokenReady", crypto::IsTPMTokenReady())); |
| 611 output.append(AddStringRow("token_name", token_name)); | 637 output.append(AddStringRow("token_name", token_name)); |
| 612 output.append(AddStringRow("user_pin", std::string(user_pin.length(), '*'))); | 638 output.append(AddStringRow("user_pin", std::string(user_pin.length(), '*'))); |
| 613 output.append("</table>"); | 639 output.append("</table>"); |
| 640 AppendFooter(&output); | |
| 614 | 641 |
| 615 output.append("</body>"); | |
| 616 output.append("</html>"); | |
| 617 return output; | 642 return output; |
| 618 } | 643 } |
| 619 | 644 |
| 620 std::string AboutCryptohome(const std::string& query) { | 645 std::string AboutCryptohome(const std::string& query) { |
| 621 int refresh; | 646 int refresh; |
| 622 base::StringToInt(query, &refresh); | 647 base::StringToInt(query, &refresh); |
| 623 return GetCryptohomeHtmlInfo(refresh); | 648 return GetCryptohomeHtmlInfo(refresh); |
| 624 } | 649 } |
| 625 | 650 |
| 651 #endif // OS_CHROMEOS | |
| 652 | |
| 626 } // namespace | 653 } // namespace |
| 627 #endif | |
| 628 | 654 |
| 629 // AboutDnsHandler bounces the request back to the IO thread to collect | 655 // AboutDnsHandler bounces the request back to the IO thread to collect |
| 630 // the DNS information. | 656 // the DNS information. |
| 631 class AboutDnsHandler : public base::RefCountedThreadSafe<AboutDnsHandler> { | 657 class AboutDnsHandler : public base::RefCountedThreadSafe<AboutDnsHandler> { |
| 632 public: | 658 public: |
| 633 static void Start(AboutSource* source, int request_id) { | 659 static void Start(AboutSource* source, int request_id) { |
| 634 scoped_refptr<AboutDnsHandler> handler( | 660 scoped_refptr<AboutDnsHandler> handler( |
| 635 new AboutDnsHandler(source, request_id)); | 661 new AboutDnsHandler(source, request_id)); |
| 636 handler->StartOnUIThread(); | 662 handler->StartOnUIThread(); |
| 637 } | 663 } |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 648 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 674 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 649 BrowserThread::PostTask( | 675 BrowserThread::PostTask( |
| 650 BrowserThread::IO, FROM_HERE, | 676 BrowserThread::IO, FROM_HERE, |
| 651 NewRunnableMethod(this, &AboutDnsHandler::StartOnIOThread)); | 677 NewRunnableMethod(this, &AboutDnsHandler::StartOnIOThread)); |
| 652 } | 678 } |
| 653 | 679 |
| 654 void StartOnIOThread() { | 680 void StartOnIOThread() { |
| 655 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 681 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 656 | 682 |
| 657 std::string data; | 683 std::string data; |
| 684 AppendHeader(&data, 0, "About DNS"); | |
| 685 AppendBody(&data); | |
| 658 chrome_browser_net::PredictorGetHtmlInfo(&data); | 686 chrome_browser_net::PredictorGetHtmlInfo(&data); |
| 687 AppendFooter(&data); | |
| 659 | 688 |
| 660 BrowserThread::PostTask( | 689 BrowserThread::PostTask( |
| 661 BrowserThread::UI, FROM_HERE, | 690 BrowserThread::UI, FROM_HERE, |
| 662 NewRunnableMethod(this, &AboutDnsHandler::FinishOnUIThread, data)); | 691 NewRunnableMethod(this, &AboutDnsHandler::FinishOnUIThread, data)); |
| 663 } | 692 } |
| 664 | 693 |
| 665 void FinishOnUIThread(const std::string& data) { | 694 void FinishOnUIThread(const std::string& data) { |
| 666 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 695 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 667 source_->FinishDataRequest(data, request_id_); | 696 source_->FinishDataRequest(data, request_id_); |
| 668 } | 697 } |
| 669 | 698 |
| 670 // Where the results are fed to. | 699 // Where the results are fed to. |
| 671 scoped_refptr<AboutSource> source_; | 700 scoped_refptr<AboutSource> source_; |
| 672 | 701 |
| 673 // ID identifying the request. | 702 // ID identifying the request. |
| 674 int request_id_; | 703 int request_id_; |
| 675 | 704 |
| 676 DISALLOW_COPY_AND_ASSIGN(AboutDnsHandler); | 705 DISALLOW_COPY_AND_ASSIGN(AboutDnsHandler); |
| 677 }; | 706 }; |
| 678 | 707 |
| 679 #if defined(USE_TCMALLOC) | 708 #if defined(USE_TCMALLOC) |
| 680 std::string AboutTcmalloc() { | 709 std::string AboutTcmalloc() { |
| 681 std::string data; | 710 std::string data; |
| 682 AboutTcmallocOutputsType* outputs = | 711 AboutTcmallocOutputsType* outputs = |
| 683 AboutTcmallocOutputs::GetInstance()->outputs(); | 712 AboutTcmallocOutputs::GetInstance()->outputs(); |
| 684 | 713 |
| 685 // Display any stats for which we sent off requests the last time. | 714 // Display any stats for which we sent off requests the last time. |
| 686 data.append("<html><head><title>About tcmalloc</title></head><body>\n"); | 715 AppendHeader(&data, 0, "About tcmalloc"); |
| 716 AppendBody(&data); | |
| 687 data.append("<p>Stats as of last page load;"); | 717 data.append("<p>Stats as of last page load;"); |
| 688 data.append("reload to get stats as of this page load.</p>\n"); | 718 data.append("reload to get stats as of this page load.</p>\n"); |
| 689 data.append("<table width=\"100%\">\n"); | 719 data.append("<table width=\"100%\">\n"); |
| 690 for (AboutTcmallocOutputsType::const_iterator oit = outputs->begin(); | 720 for (AboutTcmallocOutputsType::const_iterator oit = outputs->begin(); |
| 691 oit != outputs->end(); | 721 oit != outputs->end(); |
| 692 oit++) { | 722 oit++) { |
| 693 data.append("<tr><td bgcolor=\"yellow\">"); | 723 data.append("<tr><td bgcolor=\"yellow\">"); |
| 694 data.append(oit->first); | 724 data.append(oit->first); |
| 695 data.append("</td></tr>\n"); | 725 data.append("</td></tr>\n"); |
| 696 data.append("<tr><td><pre>\n"); | 726 data.append("<tr><td><pre>\n"); |
| 697 data.append(oit->second); | 727 data.append(oit->second); |
| 698 data.append("</pre></td></tr>\n"); | 728 data.append("</pre></td></tr>\n"); |
| 699 } | 729 } |
| 700 data.append("</table>\n"); | 730 data.append("</table>\n"); |
| 701 data.append("</body></html>\n"); | 731 AppendFooter(&data); |
| 702 | 732 |
| 703 // Reset our collector singleton. | 733 // Reset our collector singleton. |
| 704 outputs->clear(); | 734 outputs->clear(); |
| 705 | 735 |
| 706 // Populate the collector with stats from the local browser process | 736 // Populate the collector with stats from the local browser process |
| 707 // and send off requests to all the renderer processes. | 737 // and send off requests to all the renderer processes. |
| 708 char buffer[1024 * 32]; | 738 char buffer[1024 * 32]; |
| 709 MallocExtension::instance()->GetStats(buffer, sizeof(buffer)); | 739 MallocExtension::instance()->GetStats(buffer, sizeof(buffer)); |
| 710 std::string browser("Browser"); | 740 std::string browser("Browser"); |
| 711 AboutTcmallocOutputs::GetInstance()->SetOutput(browser, buffer); | 741 AboutTcmallocOutputs::GetInstance()->SetOutput(browser, buffer); |
| 712 RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator()); | 742 RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator()); |
| 713 while (!it.IsAtEnd()) { | 743 while (!it.IsAtEnd()) { |
| 714 it.GetCurrentValue()->Send(new ViewMsg_GetRendererTcmalloc); | 744 it.GetCurrentValue()->Send(new ViewMsg_GetRendererTcmalloc); |
| 715 it.Advance(); | 745 it.Advance(); |
| 716 } | 746 } |
| 717 | 747 |
| 718 return data; | 748 return data; |
| 719 } | 749 } |
| 720 #endif | 750 #endif |
| 721 | 751 |
| 722 std::string AboutHistograms(const std::string& query) { | 752 std::string AboutHistograms(const std::string& query) { |
| 723 TimeDelta wait_time = TimeDelta::FromMilliseconds(10000); | 753 TimeDelta wait_time = TimeDelta::FromMilliseconds(10000); |
| 724 | 754 |
| 725 HistogramSynchronizer* current_synchronizer = | 755 HistogramSynchronizer* current_synchronizer = |
| 726 HistogramSynchronizer::CurrentSynchronizer(); | 756 HistogramSynchronizer::CurrentSynchronizer(); |
| 727 DCHECK(current_synchronizer != NULL); | 757 DCHECK(current_synchronizer != NULL); |
| 728 current_synchronizer->FetchRendererHistogramsSynchronously(wait_time); | 758 current_synchronizer->FetchRendererHistogramsSynchronously(wait_time); |
| 729 | 759 |
| 760 std::string unescaped_query; | |
| 761 std::string unescaped_title("About Histograms"); | |
| 762 if (!query.empty()) | |
|
Evan Martin
2011/06/24 18:05:32
curly on same line as if
| |
| 763 { | |
| 764 unescaped_query = UnescapeURLComponent(query, UnescapeRule::NORMAL); | |
| 765 unescaped_title += " - " + unescaped_query; | |
| 766 } | |
| 767 | |
| 730 std::string data; | 768 std::string data; |
| 731 base::StatisticsRecorder::WriteHTMLGraph(query, &data); | 769 AppendHeader(&data, 0, unescaped_title); |
| 770 AppendBody(&data); | |
| 771 base::StatisticsRecorder::WriteHTMLGraph(unescaped_query, &data); | |
| 772 AppendFooter(&data); | |
| 732 return data; | 773 return data; |
| 733 } | 774 } |
| 734 | 775 |
| 735 void AboutMemory(AboutSource* source, int request_id) { | 776 void AboutMemory(const std::string& path, AboutSource* source, int request_id) { |
| 736 // The AboutMemoryHandler cleans itself up, but |StartFetch()| will want the | 777 if (path == kStringsJsPath) { |
| 737 // refcount to be greater than 0. | 778 // The AboutMemoryHandler cleans itself up, but |StartFetch()| will want the |
| 738 scoped_refptr<AboutMemoryHandler> | 779 // refcount to be greater than 0. |
| 739 handler(new AboutMemoryHandler(source, request_id)); | 780 scoped_refptr<AboutMemoryHandler> |
| 740 handler->StartFetch(); | 781 handler(new AboutMemoryHandler(source, request_id)); |
| 782 handler->StartFetch(); | |
| 783 } else { | |
| 784 source->FinishDataRequest( | |
| 785 ResourceBundle::GetSharedInstance().GetRawDataResource( | |
| 786 path == kMemoryJsPath ? IDR_ABOUT_MEMORY_JS : | |
| 787 IDR_ABOUT_MEMORY_HTML).as_string(), request_id); | |
| 788 } | |
| 741 } | 789 } |
| 742 | 790 |
| 743 #ifdef TRACK_ALL_TASK_OBJECTS | 791 #ifdef TRACK_ALL_TASK_OBJECTS |
| 744 static std::string AboutObjects(const std::string& query) { | 792 static std::string AboutObjects(const std::string& query) { |
| 793 std::string unescaped_title("About Histograms"); | |
| 794 if (!query.empty()) { | |
| 795 unescaped_title += " - "; | |
| 796 unescaped_title += UnescapeURLComponent(query, UnescapeRule::NORMAL); | |
| 797 } | |
| 745 std::string data; | 798 std::string data; |
| 799 AppendHeader(&data, 0, unescaped_title); | |
| 800 AppendBody(&data); | |
| 746 tracked_objects::ThreadData::WriteHTML(query, &data); | 801 tracked_objects::ThreadData::WriteHTML(query, &data); |
| 802 AppendFooter(&data); | |
| 747 return data; | 803 return data; |
| 748 } | 804 } |
| 749 #endif // TRACK_ALL_TASK_OBJECTS | 805 #endif // TRACK_ALL_TASK_OBJECTS |
| 750 | 806 |
| 751 // Handler for filling in the "about:stats" page, as called by the browser's | 807 // Handler for filling in the "about:stats" page, as called by the browser's |
| 752 // About handler processing. | 808 // About handler processing. |
| 753 // |query| is roughly the query string of the about:stats URL. | 809 // |query| is roughly the query string of the about:stats URL. |
| 754 // Returns a string containing the HTML to render for the about:stats page. | 810 // Returns a string containing the HTML to render for the about:stats page. |
| 755 // Conditional Output: | 811 // Conditional Output: |
| 756 // if |query| is "json", returns a JSON format of all counters. | 812 // if |query| is "json", returns a JSON format of all counters. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 846 // Store this on the timers list as well. | 902 // Store this on the timers list as well. |
| 847 timers->Append(counter); | 903 timers->Append(counter); |
| 848 } | 904 } |
| 849 break; | 905 break; |
| 850 default: | 906 default: |
| 851 NOTREACHED(); | 907 NOTREACHED(); |
| 852 } | 908 } |
| 853 } | 909 } |
| 854 | 910 |
| 855 std::string data; | 911 std::string data; |
| 856 if (query == "json") { | 912 if (query == "json" || query == kStringsJsPath) { |
| 857 base::JSONWriter::WriteWithOptionalEscape(&root, true, false, &data); | 913 base::JSONWriter::WriteWithOptionalEscape(&root, true, false, &data); |
| 914 if (query == kStringsJsPath) | |
| 915 data = "var templateData = " + data + ";"; | |
| 858 } else if (query == "raw") { | 916 } else if (query == "raw") { |
| 859 // Dump the raw counters which have changed in text format. | 917 // Dump the raw counters which have changed in text format. |
| 860 data = "<pre>"; | 918 data = "<pre>"; |
| 861 data.append(StringPrintf("Counter changes in the last %ldms\n", | 919 data.append(StringPrintf("Counter changes in the last %ldms\n", |
| 862 static_cast<long int>(time_since_last_sample.InMilliseconds()))); | 920 static_cast<long int>(time_since_last_sample.InMilliseconds()))); |
| 863 for (size_t i = 0; i < counters->GetSize(); ++i) { | 921 for (size_t i = 0; i < counters->GetSize(); ++i) { |
| 864 Value* entry = NULL; | 922 Value* entry = NULL; |
| 865 bool rv = counters->Get(i, &entry); | 923 bool rv = counters->Get(i, &entry); |
| 866 if (!rv) | 924 if (!rv) |
| 867 continue; // None of these should fail. | 925 continue; // None of these should fail. |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 880 if (!rv) | 938 if (!rv) |
| 881 continue; | 939 continue; |
| 882 data.append(name); | 940 data.append(name); |
| 883 data.append(":"); | 941 data.append(":"); |
| 884 data.append(base::IntToString(delta)); | 942 data.append(base::IntToString(delta)); |
| 885 data.append("\n"); | 943 data.append("\n"); |
| 886 } | 944 } |
| 887 } | 945 } |
| 888 data.append("</pre>"); | 946 data.append("</pre>"); |
| 889 } else { | 947 } else { |
| 890 // Get about_stats.html and process a pretty page. | 948 // Get about_stats.html/js from resource bundle. |
| 891 static const base::StringPiece stats_html( | 949 data = ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 892 ResourceBundle::GetSharedInstance().GetRawDataResource( | 950 (query == kStatsJsPath ? IDR_ABOUT_STATS_JS : IDR_ABOUT_STATS_HTML)). |
| 893 IDR_ABOUT_STATS_HTML)); | 951 as_string(); |
| 894 | 952 |
| 895 // Create jstemplate and return. | 953 if (query != kStatsJsPath) { |
| 896 data = jstemplate_builder::GetTemplateHtml( | 954 // Clear the timer list since we stored the data in the timers list |
| 897 stats_html, &root, "t" /* template root node id */); | 955 // as well. |
| 898 | 956 for (int index = static_cast<int>(timers->GetSize())-1; index >= 0; |
| 899 // Clear the timer list since we stored the data in the timers list as well. | 957 index--) { |
| 900 for (int index = static_cast<int>(timers->GetSize())-1; index >= 0; | 958 Value* value; |
| 901 index--) { | 959 timers->Remove(index, &value); |
| 902 Value* value; | 960 // We don't care about the value pointer; it's still tracked |
| 903 timers->Remove(index, &value); | 961 // on the counters list. |
| 904 // We don't care about the value pointer; it's still tracked | 962 } |
| 905 // on the counters list. | |
| 906 } | 963 } |
| 907 } | 964 } |
| 908 | 965 |
| 909 return data; | 966 return data; |
| 910 } | 967 } |
| 911 | 968 |
| 912 #if defined(OS_LINUX) | 969 #if defined(OS_LINUX) |
| 913 std::string AboutLinuxProxyConfig() { | 970 std::string AboutLinuxProxyConfig() { |
| 914 std::string data; | 971 std::string data; |
| 915 data.append("<!DOCTYPE HTML>\n"); | 972 AppendHeader(&data, 0, |
| 916 data.append("<html><head><meta charset=\"utf-8\"><title>"); | 973 l10n_util::GetStringUTF8(IDS_ABOUT_LINUX_PROXY_CONFIG_TITLE)); |
| 917 data.append(l10n_util::GetStringUTF8(IDS_ABOUT_LINUX_PROXY_CONFIG_TITLE)); | |
| 918 data.append("</title>"); | |
| 919 data.append("<style>body { max-width: 70ex; padding: 2ex 5ex; }</style>"); | 974 data.append("<style>body { max-width: 70ex; padding: 2ex 5ex; }</style>"); |
| 920 data.append("</head><body>\n"); | 975 AppendBody(&data); |
| 921 FilePath binary = CommandLine::ForCurrentProcess()->GetProgram(); | 976 FilePath binary = CommandLine::ForCurrentProcess()->GetProgram(); |
| 922 data.append(l10n_util::GetStringFUTF8( | 977 data.append(l10n_util::GetStringFUTF8( |
| 923 IDS_ABOUT_LINUX_PROXY_CONFIG_BODY, | 978 IDS_ABOUT_LINUX_PROXY_CONFIG_BODY, |
| 924 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), | 979 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), |
| 925 ASCIIToUTF16(binary.BaseName().value()))); | 980 ASCIIToUTF16(binary.BaseName().value()))); |
| 926 data.append("</body></html>\n"); | 981 AppendFooter(&data); |
| 927 return data; | 982 return data; |
| 928 } | 983 } |
| 929 | 984 |
| 930 void AboutSandboxRow(std::string* data, const std::string& prefix, int name_id, | 985 void AboutSandboxRow(std::string* data, const std::string& prefix, int name_id, |
| 931 bool good) { | 986 bool good) { |
| 932 data->append("<tr><td>"); | 987 data->append("<tr><td>"); |
| 933 data->append(prefix); | 988 data->append(prefix); |
| 934 data->append(l10n_util::GetStringUTF8(name_id)); | 989 data->append(l10n_util::GetStringUTF8(name_id)); |
| 935 if (good) { | 990 if (good) { |
| 936 data->append("</td><td style=\"color: green;\">"); | 991 data->append("</td><td style=\"color: green;\">"); |
| 937 data->append( | 992 data->append( |
| 938 l10n_util::GetStringUTF8(IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL)); | 993 l10n_util::GetStringUTF8(IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL)); |
| 939 } else { | 994 } else { |
| 940 data->append("</td><td style=\"color: red;\">"); | 995 data->append("</td><td style=\"color: red;\">"); |
| 941 data->append( | 996 data->append( |
| 942 l10n_util::GetStringUTF8(IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL)); | 997 l10n_util::GetStringUTF8(IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL)); |
| 943 } | 998 } |
| 944 data->append("</td></tr>"); | 999 data->append("</td></tr>"); |
| 945 } | 1000 } |
| 946 | 1001 |
| 947 std::string AboutSandbox() { | 1002 std::string AboutSandbox() { |
| 948 std::string data; | 1003 std::string data; |
| 949 data.append("<!DOCTYPE HTML>\n"); | 1004 AppendHeader(&data, 0, l10n_util::GetStringUTF8(IDS_ABOUT_SANDBOX_TITLE)); |
| 950 data.append("<html><head><meta charset=\"utf-8\"><title>"); | 1005 AppendBody(&data); |
| 951 data.append(l10n_util::GetStringUTF8(IDS_ABOUT_SANDBOX_TITLE)); | |
| 952 data.append("</title>"); | |
| 953 data.append("</head><body>\n"); | |
| 954 data.append("<h1>"); | 1006 data.append("<h1>"); |
| 955 data.append(l10n_util::GetStringUTF8(IDS_ABOUT_SANDBOX_TITLE)); | 1007 data.append(l10n_util::GetStringUTF8(IDS_ABOUT_SANDBOX_TITLE)); |
| 956 data.append("</h1>"); | 1008 data.append("</h1>"); |
| 957 | 1009 |
| 958 const int status = ZygoteHost::GetInstance()->sandbox_status(); | 1010 const int status = ZygoteHost::GetInstance()->sandbox_status(); |
| 959 | 1011 |
| 960 data.append("<table>"); | 1012 data.append("<table>"); |
| 961 | 1013 |
| 962 AboutSandboxRow(&data, "", IDS_ABOUT_SANDBOX_SUID_SANDBOX, | 1014 AboutSandboxRow(&data, "", IDS_ABOUT_SANDBOX_SUID_SANDBOX, |
| 963 status & ZygoteHost::kSandboxSUID); | 1015 status & ZygoteHost::kSandboxSUID); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 975 (status & ZygoteHost::kSandboxSeccomp); | 1027 (status & ZygoteHost::kSandboxSeccomp); |
| 976 if (good) { | 1028 if (good) { |
| 977 data.append("<p style=\"color: green\">"); | 1029 data.append("<p style=\"color: green\">"); |
| 978 data.append(l10n_util::GetStringUTF8(IDS_ABOUT_SANDBOX_OK)); | 1030 data.append(l10n_util::GetStringUTF8(IDS_ABOUT_SANDBOX_OK)); |
| 979 } else { | 1031 } else { |
| 980 data.append("<p style=\"color: red\">"); | 1032 data.append("<p style=\"color: red\">"); |
| 981 data.append(l10n_util::GetStringUTF8(IDS_ABOUT_SANDBOX_BAD)); | 1033 data.append(l10n_util::GetStringUTF8(IDS_ABOUT_SANDBOX_BAD)); |
| 982 } | 1034 } |
| 983 data.append("</p>"); | 1035 data.append("</p>"); |
| 984 | 1036 |
| 985 data.append("</body></html>\n"); | 1037 AppendFooter(&data); |
| 986 return data; | 1038 return data; |
| 987 } | 1039 } |
| 988 #endif | 1040 #endif |
| 989 | 1041 |
| 990 std::string AboutVersion(DictionaryValue* localized_strings, Profile* profile) { | 1042 std::string AboutVersion(const std::string& query, |
| 1043 DictionaryValue* localized_strings, | |
| 1044 Profile* profile) { | |
| 1045 if (query != kStringsJsPath) { | |
| 1046 int idr = (query == kVersionJsPath) ? | |
| 1047 IDR_ABOUT_VERSION_JS : IDR_ABOUT_VERSION_HTML; | |
| 1048 return ResourceBundle::GetSharedInstance().GetRawDataResource( | |
| 1049 idr).as_string(); | |
| 1050 } | |
| 1051 | |
| 991 localized_strings->SetString("title", | 1052 localized_strings->SetString("title", |
| 992 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_TITLE)); | 1053 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_TITLE)); |
| 993 chrome::VersionInfo version_info; | 1054 chrome::VersionInfo version_info; |
| 994 | 1055 |
| 995 std::string webkit_version = webkit_glue::GetWebKitVersion(); | 1056 std::string webkit_version = webkit_glue::GetWebKitVersion(); |
| 996 #ifdef CHROME_V8 | 1057 #ifdef CHROME_V8 |
| 997 std::string js_version(v8::V8::GetVersion()); | 1058 std::string js_version(v8::V8::GetVersion()); |
| 998 std::string js_engine = "V8"; | 1059 std::string js_engine = "V8"; |
| 999 #else | 1060 #else |
| 1000 std::string js_version = webkit_version; | 1061 std::string js_version = webkit_version; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1080 localized_strings->SetString("profile_path", profile_path.value()); | 1141 localized_strings->SetString("profile_path", profile_path.value()); |
| 1081 } else { | 1142 } else { |
| 1082 localized_strings->SetString("profile_path", | 1143 localized_strings->SetString("profile_path", |
| 1083 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_PATH_NOTFOUND)); | 1144 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_PATH_NOTFOUND)); |
| 1084 } | 1145 } |
| 1085 } else { | 1146 } else { |
| 1086 localized_strings->SetString("profile_path", | 1147 localized_strings->SetString("profile_path", |
| 1087 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_PATH_NOTFOUND)); | 1148 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_PATH_NOTFOUND)); |
| 1088 } | 1149 } |
| 1089 | 1150 |
| 1090 base::StringPiece version_html( | 1151 std::string data; |
| 1091 ResourceBundle::GetSharedInstance().GetRawDataResource( | 1152 jstemplate_builder::AppendJsonJS(localized_strings, &data); |
| 1092 IDR_ABOUT_VERSION_HTML)); | 1153 return data; |
| 1154 } | |
| 1093 | 1155 |
| 1094 return jstemplate_builder::GetTemplatesHtml( | 1156 } // namespace |
| 1095 version_html, localized_strings, "t" /* template root node id */); | |
| 1096 } | |
| 1097 | 1157 |
| 1098 // AboutSource ----------------------------------------------------------------- | 1158 // AboutSource ----------------------------------------------------------------- |
| 1099 | 1159 |
| 1100 AboutSource::AboutSource(const std::string& source_name, Profile* profile) | 1160 AboutSource::AboutSource(const std::string& source_name, Profile* profile) |
| 1101 : DataSource(source_name, MessageLoop::current()), | 1161 : DataSource(source_name, MessageLoop::current()), |
| 1102 profile_(profile) { | 1162 profile_(profile) { |
| 1103 } | 1163 } |
| 1104 | 1164 |
| 1105 AboutSource::~AboutSource() { | 1165 AboutSource::~AboutSource() { |
| 1106 } | 1166 } |
| 1107 | 1167 |
| 1108 void AboutSource::StartDataRequest(const std::string& path, | 1168 void AboutSource::StartDataRequest(const std::string& path, |
| 1109 bool is_incognito, | 1169 bool is_incognito, |
| 1110 int request_id) { | 1170 int request_id) { |
| 1111 std::string response; | 1171 std::string response; |
| 1112 std::string host = source_name(); | 1172 std::string host = source_name(); |
| 1113 if (host == chrome::kChromeUIDNSHost) { | 1173 if (host == chrome::kChromeUIDNSHost) { |
| 1114 AboutDnsHandler::Start(this, request_id); | 1174 AboutDnsHandler::Start(this, request_id); |
| 1115 return; | 1175 return; |
| 1116 } else if (host == chrome::kChromeUIHistogramsHost) { | 1176 } else if (host == chrome::kChromeUIHistogramsHost) { |
| 1117 response = AboutHistograms(path); | 1177 response = AboutHistograms(path); |
| 1118 } else if (host == chrome::kChromeUIMemoryHost) { | 1178 } else if (host == chrome::kChromeUIMemoryHost) { |
| 1119 response = GetAboutMemoryRedirectResponse(profile()); | 1179 response = GetAboutMemoryRedirectResponse(profile()); |
| 1120 } else if (host == chrome::kChromeUIMemoryRedirectHost) { | 1180 } else if (host == chrome::kChromeUIMemoryRedirectHost) { |
| 1121 AboutMemory(this, request_id); | 1181 AboutMemory(path, this, request_id); |
| 1122 return; | 1182 return; |
| 1123 #ifdef TRACK_ALL_TASK_OBJECTS | 1183 #ifdef TRACK_ALL_TASK_OBJECTS |
| 1124 } else if (host == chrome::kChromeUITasksHost) { | 1184 } else if (host == chrome::kChromeUITasksHost) { |
| 1125 response = AboutObjects(path); | 1185 response = AboutObjects(path); |
| 1126 #endif | 1186 #endif |
| 1127 } else if (host == chrome::kChromeUIStatsHost) { | 1187 } else if (host == chrome::kChromeUIStatsHost) { |
| 1128 response = AboutStats(path); | 1188 response = AboutStats(path); |
| 1129 #if defined(USE_TCMALLOC) | 1189 #if defined(USE_TCMALLOC) |
| 1130 } else if (host == chrome::kChromeUITCMallocHost) { | 1190 } else if (host == chrome::kChromeUITCMallocHost) { |
| 1131 response = AboutTcmalloc(); | 1191 response = AboutTcmalloc(); |
| 1132 #endif | 1192 #endif |
| 1133 } else if (host == chrome::kChromeUIVersionHost) { | 1193 } else if (host == chrome::kChromeUIVersionHost) { |
| 1134 #if defined(OS_CHROMEOS) | 1194 #if defined(OS_CHROMEOS) |
| 1135 new ChromeOSAboutVersionHandler(this, request_id); | 1195 new ChromeOSAboutVersionHandler(this, request_id); |
| 1136 return; | 1196 return; |
| 1137 #else | 1197 #else |
| 1138 DictionaryValue localized_strings; | 1198 DictionaryValue localized_strings; |
| 1139 localized_strings.SetString("os_version", ""); | 1199 localized_strings.SetString("os_version", ""); |
| 1140 response = AboutVersion(&localized_strings, profile_); | 1200 response = AboutVersion(path, &localized_strings, profile_); |
| 1141 #endif | 1201 #endif |
| 1142 } else if (host == chrome::kChromeUICreditsHost) { | 1202 } else if (host == chrome::kChromeUICreditsHost) { |
| 1203 int idr = (path == kCreditsJsPath) ? IDR_CREDITS_JS : IDR_CREDITS_HTML; | |
| 1143 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 1204 response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 1144 IDR_CREDITS_HTML).as_string(); | 1205 idr).as_string(); |
| 1145 } else if (host == chrome::kChromeUIChromeURLsHost) { | 1206 } else if (host == chrome::kChromeUIChromeURLsHost) { |
| 1146 response = ChromeURLs(); | 1207 response = ChromeURLs(); |
| 1147 #if defined(OS_CHROMEOS) | 1208 #if defined(OS_CHROMEOS) |
| 1148 } else if (host == chrome::kChromeUIOSCreditsHost) { | 1209 } else if (host == chrome::kChromeUIOSCreditsHost) { |
| 1149 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 1210 response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 1150 IDR_OS_CREDITS_HTML).as_string(); | 1211 IDR_OS_CREDITS_HTML).as_string(); |
| 1151 } else if (host == chrome::kChromeUINetworkHost) { | 1212 } else if (host == chrome::kChromeUINetworkHost) { |
| 1152 response = AboutNetwork(path); | 1213 response = AboutNetwork(path); |
| 1153 } else if (host == chrome::kChromeUICryptohomeHost) { | 1214 } else if (host == chrome::kChromeUICryptohomeHost) { |
| 1154 response = AboutCryptohome(path); | 1215 response = AboutCryptohome(path); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1172 FinishDataRequest(response, request_id); | 1233 FinishDataRequest(response, request_id); |
| 1173 } | 1234 } |
| 1174 | 1235 |
| 1175 void AboutSource::FinishDataRequest(const std::string& html, int request_id) { | 1236 void AboutSource::FinishDataRequest(const std::string& html, int request_id) { |
| 1176 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); | 1237 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); |
| 1177 html_bytes->data.resize(html.size()); | 1238 html_bytes->data.resize(html.size()); |
| 1178 std::copy(html.begin(), html.end(), html_bytes->data.begin()); | 1239 std::copy(html.begin(), html.end(), html_bytes->data.begin()); |
| 1179 SendResponse(request_id, html_bytes); | 1240 SendResponse(request_id, html_bytes); |
| 1180 } | 1241 } |
| 1181 | 1242 |
| 1243 std::string AboutSource::GetMimeType(const std::string& path) const OVERRIDE { | |
| 1244 if (path == kCreditsJsPath || | |
| 1245 path == kStatsJsPath || | |
| 1246 path == kStringsJsPath || | |
| 1247 path == kVersionJsPath || | |
| 1248 path == kMemoryJsPath) { | |
| 1249 return "application/javascript"; | |
| 1250 } | |
| 1251 return "text/html"; | |
| 1252 } | |
| 1253 | |
| 1254 namespace { | |
| 1255 | |
| 1182 // AboutMemoryHandler ---------------------------------------------------------- | 1256 // AboutMemoryHandler ---------------------------------------------------------- |
| 1183 | 1257 |
| 1184 // Helper for AboutMemory to bind results from a ProcessMetrics object | 1258 // Helper for AboutMemory to bind results from a ProcessMetrics object |
| 1185 // to a DictionaryValue. Fills ws_usage and comm_usage so that the objects | 1259 // to a DictionaryValue. Fills ws_usage and comm_usage so that the objects |
| 1186 // can be used in caller's scope (e.g for appending to a net total). | 1260 // can be used in caller's scope (e.g for appending to a net total). |
| 1187 void AboutMemoryHandler::BindProcessMetrics(DictionaryValue* data, | 1261 void AboutMemoryHandler::BindProcessMetrics(DictionaryValue* data, |
| 1188 ProcessMemoryInformation* info) { | 1262 ProcessMemoryInformation* info) { |
| 1189 DCHECK(data && info); | 1263 DCHECK(data && info); |
| 1190 | 1264 |
| 1191 // Bind metrics to dictionary. | 1265 // Bind metrics to dictionary. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1293 for (size_t index = 0; index < process.processes.size(); index++) { | 1367 for (size_t index = 0; index < process.processes.size(); index++) { |
| 1294 if (process.processes[index].type == ChildProcessInfo::BROWSER_PROCESS) | 1368 if (process.processes[index].type == ChildProcessInfo::BROWSER_PROCESS) |
| 1295 BindProcessMetrics(browser_data, &process.processes[index]); | 1369 BindProcessMetrics(browser_data, &process.processes[index]); |
| 1296 else | 1370 else |
| 1297 AppendProcess(child_data, &process.processes[index]); | 1371 AppendProcess(child_data, &process.processes[index]); |
| 1298 } | 1372 } |
| 1299 | 1373 |
| 1300 root.SetBoolean("show_other_browsers", | 1374 root.SetBoolean("show_other_browsers", |
| 1301 browser_defaults::kShowOtherBrowsersInAboutMemory); | 1375 browser_defaults::kShowOtherBrowsersInAboutMemory); |
| 1302 | 1376 |
| 1303 // Get about_memory.html | 1377 std::string data; |
| 1304 static const base::StringPiece memory_html( | 1378 jstemplate_builder::AppendJsonJS(&root, &data); |
| 1305 ResourceBundle::GetSharedInstance().GetRawDataResource( | 1379 source_->FinishDataRequest(data, request_id_); |
| 1306 IDR_ABOUT_MEMORY_HTML)); | |
| 1307 | |
| 1308 // Create jstemplate and return. | |
| 1309 std::string template_html = jstemplate_builder::GetTemplateHtml( | |
| 1310 memory_html, &root, "t" /* template root node id */); | |
| 1311 | |
| 1312 source_->FinishDataRequest(template_html, request_id_); | |
| 1313 } | 1380 } |
| 1314 | 1381 |
| 1315 #if defined(OS_CHROMEOS) | 1382 #if defined(OS_CHROMEOS) |
| 1316 // ChromeOSAboutVersionHandler ----------------------------------------------- | 1383 // ChromeOSAboutVersionHandler ----------------------------------------------- |
| 1317 | 1384 |
| 1318 ChromeOSAboutVersionHandler::ChromeOSAboutVersionHandler(AboutSource* source, | 1385 ChromeOSAboutVersionHandler::ChromeOSAboutVersionHandler(AboutSource* source, |
| 1319 int request_id) | 1386 int request_id) |
| 1320 : source_(source), | 1387 : source_(source), |
| 1321 request_id_(request_id) { | 1388 request_id_(request_id) { |
| 1322 loader_.EnablePlatformVersions(true); | 1389 loader_.EnablePlatformVersions(true); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1416 return false; | 1483 return false; |
| 1417 } | 1484 } |
| 1418 | 1485 |
| 1419 std::vector<std::string> ChromePaths() { | 1486 std::vector<std::string> ChromePaths() { |
| 1420 std::vector<std::string> paths; | 1487 std::vector<std::string> paths; |
| 1421 paths.reserve(arraysize(kChromePaths)); | 1488 paths.reserve(arraysize(kChromePaths)); |
| 1422 for (size_t i = 0; i < arraysize(kChromePaths); i++) | 1489 for (size_t i = 0; i < arraysize(kChromePaths); i++) |
| 1423 paths.push_back(kChromePaths[i]); | 1490 paths.push_back(kChromePaths[i]); |
| 1424 return paths; | 1491 return paths; |
| 1425 } | 1492 } |
| OLD | NEW |