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