| 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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 16 #include "base/i18n/number_formatting.h" | 16 #include "base/i18n/number_formatting.h" |
| 17 #include "base/json/json_writer.h" | 17 #include "base/json/json_writer.h" |
| 18 #include "base/memory/singleton.h" | 18 #include "base/memory/singleton.h" |
| 19 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
| 20 #include "base/metrics/stats_table.h" | 20 #include "base/metrics/stats_table.h" |
| 21 #include "base/path_service.h" | 21 #include "base/path_service.h" |
| 22 #include "base/string_number_conversions.h" | 22 #include "base/string_number_conversions.h" |
| 23 #include "base/string_piece.h" | 23 #include "base/string_piece.h" |
| 24 #include "base/string_util.h" | 24 #include "base/string_util.h" |
| 25 #include "base/stringprintf.h" | 25 #include "base/stringprintf.h" |
| 26 #include "base/threading/thread.h" | 26 #include "base/threading/thread.h" |
| 27 #include "base/tracked_objects.h" | |
| 28 #include "base/utf_string_conversions.h" | 27 #include "base/utf_string_conversions.h" |
| 29 #include "base/values.h" | 28 #include "base/values.h" |
| 30 #include "chrome/browser/about_flags.h" | 29 #include "chrome/browser/about_flags.h" |
| 31 #include "chrome/browser/browser_process.h" | 30 #include "chrome/browser/browser_process.h" |
| 32 #include "chrome/browser/defaults.h" | 31 #include "chrome/browser/defaults.h" |
| 33 #include "chrome/browser/memory_details.h" | 32 #include "chrome/browser/memory_details.h" |
| 34 #include "chrome/browser/metrics/histogram_synchronizer.h" | 33 #include "chrome/browser/metrics/histogram_synchronizer.h" |
| 35 #include "chrome/browser/net/predictor.h" | 34 #include "chrome/browser/net/predictor.h" |
| 36 #include "chrome/browser/net/url_fixer_upper.h" | 35 #include "chrome/browser/net/url_fixer_upper.h" |
| 37 #include "chrome/browser/plugin_prefs.h" | 36 #include "chrome/browser/plugin_prefs.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 chrome::kChromeUIPrintHost, | 138 chrome::kChromeUIPrintHost, |
| 140 chrome::kChromeUIQuotaInternalsHost, | 139 chrome::kChromeUIQuotaInternalsHost, |
| 141 chrome::kChromeUISessionsHost, | 140 chrome::kChromeUISessionsHost, |
| 142 chrome::kChromeUISettingsHost, | 141 chrome::kChromeUISettingsHost, |
| 143 chrome::kChromeUIStatsHost, | 142 chrome::kChromeUIStatsHost, |
| 144 chrome::kChromeUISyncInternalsHost, | 143 chrome::kChromeUISyncInternalsHost, |
| 145 chrome::kChromeUITaskManagerHost, | 144 chrome::kChromeUITaskManagerHost, |
| 146 chrome::kChromeUITCMallocHost, | 145 chrome::kChromeUITCMallocHost, |
| 147 chrome::kChromeUITermsHost, | 146 chrome::kChromeUITermsHost, |
| 148 chrome::kChromeUITracingHost, | 147 chrome::kChromeUITracingHost, |
| 149 chrome::kChromeUITrackingHost, | |
| 150 chrome::kChromeUIVersionHost, | 148 chrome::kChromeUIVersionHost, |
| 151 chrome::kChromeUIWorkersHost, | 149 chrome::kChromeUIWorkersHost, |
| 152 #if defined(OS_WIN) | 150 #if defined(OS_WIN) |
| 153 chrome::kChromeUIConflictsHost, | 151 chrome::kChromeUIConflictsHost, |
| 154 #endif | 152 #endif |
| 155 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 153 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
| 156 chrome::kChromeUILinuxProxyConfigHost, | 154 chrome::kChromeUILinuxProxyConfigHost, |
| 157 chrome::kChromeUISandboxHost, | 155 chrome::kChromeUISandboxHost, |
| 158 #endif | 156 #endif |
| 159 #if defined(OS_CHROMEOS) | 157 #if defined(OS_CHROMEOS) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 176 const char* const kAboutSourceNames[] = { | 174 const char* const kAboutSourceNames[] = { |
| 177 chrome::kChromeUIChromeURLsHost, | 175 chrome::kChromeUIChromeURLsHost, |
| 178 chrome::kChromeUICreditsHost, | 176 chrome::kChromeUICreditsHost, |
| 179 chrome::kChromeUIDNSHost, | 177 chrome::kChromeUIDNSHost, |
| 180 chrome::kChromeUIHistogramsHost, | 178 chrome::kChromeUIHistogramsHost, |
| 181 chrome::kChromeUIMemoryHost, | 179 chrome::kChromeUIMemoryHost, |
| 182 chrome::kChromeUIMemoryRedirectHost, | 180 chrome::kChromeUIMemoryRedirectHost, |
| 183 chrome::kChromeUIStatsHost, | 181 chrome::kChromeUIStatsHost, |
| 184 chrome::kChromeUITaskManagerHost, | 182 chrome::kChromeUITaskManagerHost, |
| 185 chrome::kChromeUITermsHost, | 183 chrome::kChromeUITermsHost, |
| 186 chrome::kChromeUITrackingHost, | |
| 187 chrome::kChromeUIVersionHost, | 184 chrome::kChromeUIVersionHost, |
| 188 #if defined(USE_TCMALLOC) | 185 #if defined(USE_TCMALLOC) |
| 189 chrome::kChromeUITCMallocHost, | 186 chrome::kChromeUITCMallocHost, |
| 190 #endif | 187 #endif |
| 191 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 188 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
| 192 chrome::kChromeUILinuxProxyConfigHost, | 189 chrome::kChromeUILinuxProxyConfigHost, |
| 193 chrome::kChromeUISandboxHost, | 190 chrome::kChromeUISandboxHost, |
| 194 #endif | 191 #endif |
| 195 #if defined(OS_CHROMEOS) | 192 #if defined(OS_CHROMEOS) |
| 196 chrome::kChromeUICryptohomeHost, | 193 chrome::kChromeUICryptohomeHost, |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 handler(new AboutMemoryHandler(source, request_id)); | 877 handler(new AboutMemoryHandler(source, request_id)); |
| 881 handler->StartFetch(); | 878 handler->StartFetch(); |
| 882 } else { | 879 } else { |
| 883 source->FinishDataRequest( | 880 source->FinishDataRequest( |
| 884 ResourceBundle::GetSharedInstance().GetRawDataResource( | 881 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 885 path == kMemoryJsPath ? IDR_ABOUT_MEMORY_JS : | 882 path == kMemoryJsPath ? IDR_ABOUT_MEMORY_JS : |
| 886 IDR_ABOUT_MEMORY_HTML).as_string(), request_id); | 883 IDR_ABOUT_MEMORY_HTML).as_string(), request_id); |
| 887 } | 884 } |
| 888 } | 885 } |
| 889 | 886 |
| 890 static std::string AboutTracking(const std::string& query) { | |
| 891 std::string unescaped_title("About Tracking"); | |
| 892 if (!query.empty()) { | |
| 893 unescaped_title += " - "; | |
| 894 unescaped_title += net::UnescapeURLComponent(query, | |
| 895 net::UnescapeRule::NORMAL); | |
| 896 } | |
| 897 std::string data; | |
| 898 AppendHeader(&data, 0, unescaped_title); | |
| 899 AppendBody(&data); | |
| 900 tracked_objects::ThreadData::WriteHTML(query, &data); | |
| 901 AppendFooter(&data); | |
| 902 return data; | |
| 903 } | |
| 904 | |
| 905 // Handler for filling in the "about:stats" page, as called by the browser's | 887 // Handler for filling in the "about:stats" page, as called by the browser's |
| 906 // About handler processing. | 888 // About handler processing. |
| 907 // |query| is roughly the query string of the about:stats URL. | 889 // |query| is roughly the query string of the about:stats URL. |
| 908 // Returns a string containing the HTML to render for the about:stats page. | 890 // Returns a string containing the HTML to render for the about:stats page. |
| 909 // Conditional Output: | 891 // Conditional Output: |
| 910 // if |query| is "json", returns a JSON format of all counters. | 892 // if |query| is "json", returns a JSON format of all counters. |
| 911 // if |query| is "raw", returns plain text of counter deltas. | 893 // if |query| is "raw", returns plain text of counter deltas. |
| 912 // otherwise, returns HTML with pretty JS/HTML to display the data. | 894 // otherwise, returns HTML with pretty JS/HTML to display the data. |
| 913 std::string AboutStats(const std::string& query) { | 895 std::string AboutStats(const std::string& query) { |
| 914 // We keep the DictionaryValue tree live so that we can do delta | 896 // We keep the DictionaryValue tree live so that we can do delta |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1464 } else if (host == chrome::kChromeUIOSCreditsHost) { | 1446 } else if (host == chrome::kChromeUIOSCreditsHost) { |
| 1465 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 1447 response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 1466 IDR_OS_CREDITS_HTML).as_string(); | 1448 IDR_OS_CREDITS_HTML).as_string(); |
| 1467 #endif | 1449 #endif |
| 1468 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 1450 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
| 1469 } else if (host == chrome::kChromeUISandboxHost) { | 1451 } else if (host == chrome::kChromeUISandboxHost) { |
| 1470 response = AboutSandbox(); | 1452 response = AboutSandbox(); |
| 1471 #endif | 1453 #endif |
| 1472 } else if (host == chrome::kChromeUIStatsHost) { | 1454 } else if (host == chrome::kChromeUIStatsHost) { |
| 1473 response = AboutStats(path); | 1455 response = AboutStats(path); |
| 1474 } else if (host == chrome::kChromeUITrackingHost) { | |
| 1475 response = AboutTracking(path); | |
| 1476 #if defined(USE_TCMALLOC) | 1456 #if defined(USE_TCMALLOC) |
| 1477 } else if (host == chrome::kChromeUITCMallocHost) { | 1457 } else if (host == chrome::kChromeUITCMallocHost) { |
| 1478 response = AboutTcmalloc(); | 1458 response = AboutTcmalloc(); |
| 1479 #endif | 1459 #endif |
| 1480 } else if (host == chrome::kChromeUITermsHost) { | 1460 } else if (host == chrome::kChromeUITermsHost) { |
| 1481 #if defined(OS_CHROMEOS) | 1461 #if defined(OS_CHROMEOS) |
| 1482 ChromeOSTermsHandler::Start(this, path, request_id); | 1462 ChromeOSTermsHandler::Start(this, path, request_id); |
| 1483 return; | 1463 return; |
| 1484 #else | 1464 #else |
| 1485 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 1465 response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1632 return false; | 1612 return false; |
| 1633 } | 1613 } |
| 1634 | 1614 |
| 1635 std::vector<std::string> ChromePaths() { | 1615 std::vector<std::string> ChromePaths() { |
| 1636 std::vector<std::string> paths; | 1616 std::vector<std::string> paths; |
| 1637 paths.reserve(arraysize(kChromePaths)); | 1617 paths.reserve(arraysize(kChromePaths)); |
| 1638 for (size_t i = 0; i < arraysize(kChromePaths); i++) | 1618 for (size_t i = 0; i < arraysize(kChromePaths); i++) |
| 1639 paths.push_back(kChromePaths[i]); | 1619 paths.push_back(kChromePaths[i]); |
| 1640 return paths; | 1620 return paths; |
| 1641 } | 1621 } |
| OLD | NEW |