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 22 matching lines...) Expand all Loading... |
33 #include "chrome/browser/gpu_process_host_ui_shim.h" | 33 #include "chrome/browser/gpu_process_host_ui_shim.h" |
34 #include "chrome/browser/memory_details.h" | 34 #include "chrome/browser/memory_details.h" |
35 #include "chrome/browser/metrics/histogram_synchronizer.h" | 35 #include "chrome/browser/metrics/histogram_synchronizer.h" |
36 #include "chrome/browser/net/predictor_api.h" | 36 #include "chrome/browser/net/predictor_api.h" |
37 #include "chrome/browser/platform_util.h" | 37 #include "chrome/browser/platform_util.h" |
38 #include "chrome/browser/prefs/pref_service.h" | 38 #include "chrome/browser/prefs/pref_service.h" |
39 #include "chrome/browser/profiles/profile.h" | 39 #include "chrome/browser/profiles/profile.h" |
40 #include "chrome/browser/profiles/profile_manager.h" | 40 #include "chrome/browser/profiles/profile_manager.h" |
41 #include "chrome/browser/renderer_host/render_process_host.h" | 41 #include "chrome/browser/renderer_host/render_process_host.h" |
42 #include "chrome/browser/renderer_host/render_view_host.h" | 42 #include "chrome/browser/renderer_host/render_view_host.h" |
43 #include "chrome/browser/sync/profile_sync_service.h" | |
44 #include "chrome/browser/sync/sync_ui_util.h" | |
45 #include "chrome/common/about_handler.h" | 43 #include "chrome/common/about_handler.h" |
46 #include "chrome/common/chrome_paths.h" | 44 #include "chrome/common/chrome_paths.h" |
47 #include "chrome/common/chrome_version_info.h" | 45 #include "chrome/common/chrome_version_info.h" |
48 #include "chrome/common/gpu_info.h" | 46 #include "chrome/common/gpu_info.h" |
49 #include "chrome/common/jstemplate_builder.h" | 47 #include "chrome/common/jstemplate_builder.h" |
50 #include "chrome/common/net/gaia/google_service_auth_error.h" | 48 #include "chrome/common/net/gaia/google_service_auth_error.h" |
51 #include "chrome/common/render_messages.h" | 49 #include "chrome/common/render_messages.h" |
52 #include "chrome/common/url_constants.h" | 50 #include "chrome/common/url_constants.h" |
53 #include "googleurl/src/gurl.h" | 51 #include "googleurl/src/gurl.h" |
54 #include "grit/browser_resources.h" | 52 #include "grit/browser_resources.h" |
(...skipping 18 matching lines...) Expand all Loading... |
73 #elif defined(OS_MACOSX) | 71 #elif defined(OS_MACOSX) |
74 #include "chrome/browser/ui/cocoa/about_ipc_dialog.h" | 72 #include "chrome/browser/ui/cocoa/about_ipc_dialog.h" |
75 #elif defined(OS_LINUX) | 73 #elif defined(OS_LINUX) |
76 #include "chrome/browser/zygote_host_linux.h" | 74 #include "chrome/browser/zygote_host_linux.h" |
77 #endif | 75 #endif |
78 | 76 |
79 #if defined(USE_TCMALLOC) | 77 #if defined(USE_TCMALLOC) |
80 #include "third_party/tcmalloc/chromium/src/google/malloc_extension.h" | 78 #include "third_party/tcmalloc/chromium/src/google/malloc_extension.h" |
81 #endif | 79 #endif |
82 | 80 |
83 using sync_api::SyncManager; | |
84 | |
85 using base::Time; | 81 using base::Time; |
86 using base::TimeDelta; | 82 using base::TimeDelta; |
87 | 83 |
88 #if defined(USE_TCMALLOC) | 84 #if defined(USE_TCMALLOC) |
89 // static | 85 // static |
90 AboutTcmallocOutputs* AboutTcmallocOutputs::GetInstance() { | 86 AboutTcmallocOutputs* AboutTcmallocOutputs::GetInstance() { |
91 return Singleton<AboutTcmallocOutputs>::get(); | 87 return Singleton<AboutTcmallocOutputs>::get(); |
92 } | 88 } |
93 | 89 |
94 // Glue between the callback task and the method in the singleton. | 90 // Glue between the callback task and the method in the singleton. |
(...skipping 13 matching lines...) Expand all Loading... |
108 #if defined(OS_WIN) | 104 #if defined(OS_WIN) |
109 const char kConflictsPath[] = "conflicts"; | 105 const char kConflictsPath[] = "conflicts"; |
110 #endif | 106 #endif |
111 const char kDnsPath[] = "dns"; | 107 const char kDnsPath[] = "dns"; |
112 const char kFlagsPath[] = "flags"; | 108 const char kFlagsPath[] = "flags"; |
113 const char kGpuPath[] = "gpu"; | 109 const char kGpuPath[] = "gpu"; |
114 const char kHistogramsPath[] = "histograms"; | 110 const char kHistogramsPath[] = "histograms"; |
115 const char kMemoryRedirectPath[] = "memory-redirect"; | 111 const char kMemoryRedirectPath[] = "memory-redirect"; |
116 const char kMemoryPath[] = "memory"; | 112 const char kMemoryPath[] = "memory"; |
117 const char kStatsPath[] = "stats"; | 113 const char kStatsPath[] = "stats"; |
118 const char kSyncPath[] = "sync"; | |
119 const char kTasksPath[] = "tasks"; | 114 const char kTasksPath[] = "tasks"; |
120 const char kTcmallocPath[] = "tcmalloc"; | 115 const char kTcmallocPath[] = "tcmalloc"; |
121 const char kTermsPath[] = "terms"; | 116 const char kTermsPath[] = "terms"; |
122 const char kVersionPath[] = "version"; | 117 const char kVersionPath[] = "version"; |
123 const char kAboutPath[] = "about"; | 118 const char kAboutPath[] = "about"; |
124 // Not about:* pages, but included to make about:about look nicer | 119 // Not about:* pages, but included to make about:about look nicer |
125 const char kNetInternalsPath[] = "net-internals"; | 120 const char kNetInternalsPath[] = "net-internals"; |
126 const char kPluginsPath[] = "plugins"; | 121 const char kPluginsPath[] = "plugins"; |
| 122 const char kSyncInternalsPath[] = "sync-internals"; |
127 | 123 |
128 #if defined(OS_LINUX) | 124 #if defined(OS_LINUX) |
129 const char kLinuxProxyConfigPath[] = "linux-proxy-config"; | 125 const char kLinuxProxyConfigPath[] = "linux-proxy-config"; |
130 const char kSandboxPath[] = "sandbox"; | 126 const char kSandboxPath[] = "sandbox"; |
131 #endif | 127 #endif |
132 | 128 |
133 #if defined(OS_CHROMEOS) | 129 #if defined(OS_CHROMEOS) |
134 const char kNetworkPath[] = "network"; | 130 const char kNetworkPath[] = "network"; |
135 const char kOSCreditsPath[] = "os-credits"; | 131 const char kOSCreditsPath[] = "os-credits"; |
136 #endif | 132 #endif |
137 | 133 |
138 // Add path here to be included in about:about | 134 // Add path here to be included in about:about |
139 const char *kAllAboutPaths[] = { | 135 const char *kAllAboutPaths[] = { |
140 kAppCacheInternalsPath, | 136 kAppCacheInternalsPath, |
141 kBlobInternalsPath, | 137 kBlobInternalsPath, |
142 kCachePath, | 138 kCachePath, |
143 kCreditsPath, | 139 kCreditsPath, |
144 #if defined(OS_WIN) | 140 #if defined(OS_WIN) |
145 kConflictsPath, | 141 kConflictsPath, |
146 #endif | 142 #endif |
147 kDnsPath, | 143 kDnsPath, |
148 kFlagsPath, | 144 kFlagsPath, |
149 kGpuPath, | 145 kGpuPath, |
150 kHistogramsPath, | 146 kHistogramsPath, |
151 kMemoryPath, | 147 kMemoryPath, |
152 kNetInternalsPath, | 148 kNetInternalsPath, |
153 kPluginsPath, | 149 kPluginsPath, |
154 kStatsPath, | 150 kStatsPath, |
155 kSyncPath, | 151 kSyncInternalsPath, |
156 kTasksPath, | 152 kTasksPath, |
157 kTcmallocPath, | 153 kTcmallocPath, |
158 kTermsPath, | 154 kTermsPath, |
159 kVersionPath, | 155 kVersionPath, |
160 #if defined(OS_LINUX) | 156 #if defined(OS_LINUX) |
161 kSandboxPath, | 157 kSandboxPath, |
162 #endif | 158 #endif |
163 #if defined(OS_CHROMEOS) | 159 #if defined(OS_CHROMEOS) |
164 kNetworkPath, | 160 kNetworkPath, |
165 kOSCreditsPath, | 161 kOSCreditsPath, |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 #endif | 677 #endif |
682 | 678 |
683 base::StringPiece version_html( | 679 base::StringPiece version_html( |
684 ResourceBundle::GetSharedInstance().GetRawDataResource( | 680 ResourceBundle::GetSharedInstance().GetRawDataResource( |
685 IDR_ABOUT_VERSION_HTML)); | 681 IDR_ABOUT_VERSION_HTML)); |
686 | 682 |
687 return jstemplate_builder::GetTemplatesHtml( | 683 return jstemplate_builder::GetTemplatesHtml( |
688 version_html, localized_strings, "t" /* template root node id */); | 684 version_html, localized_strings, "t" /* template root node id */); |
689 } | 685 } |
690 | 686 |
691 | |
692 | |
693 std::string AboutSync() { | |
694 FilePath user_data_dir; | |
695 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) | |
696 return std::string(); | |
697 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
698 Profile* profile = profile_manager->GetDefaultProfile(user_data_dir); | |
699 ProfileSyncService* service = profile->GetProfileSyncService(); | |
700 | |
701 DictionaryValue strings; | |
702 if (!service) { | |
703 strings.SetString("summary", "SYNC DISABLED"); | |
704 } else { | |
705 sync_ui_util::ConstructAboutInformation(service, &strings); | |
706 } | |
707 | |
708 static const base::StringPiece sync_html( | |
709 ResourceBundle::GetSharedInstance().GetRawDataResource( | |
710 IDR_ABOUT_SYNC_HTML)); | |
711 | |
712 return jstemplate_builder::GetTemplatesHtml( | |
713 sync_html, &strings , "t" /* template root node id */); | |
714 } | |
715 | |
716 std::string VersionNumberToString(uint32 value) { | 687 std::string VersionNumberToString(uint32 value) { |
717 int hi = (value >> 8) & 0xff; | 688 int hi = (value >> 8) & 0xff; |
718 int low = value & 0xff; | 689 int low = value & 0xff; |
719 return base::IntToString(hi) + "." + base::IntToString(low); | 690 return base::IntToString(hi) + "." + base::IntToString(low); |
720 } | 691 } |
721 | 692 |
722 // AboutSource ----------------------------------------------------------------- | 693 // AboutSource ----------------------------------------------------------------- |
723 | 694 |
724 AboutSource::AboutSource() | 695 AboutSource::AboutSource() |
725 : DataSource(chrome::kAboutScheme, MessageLoop::current()) { | 696 : DataSource(chrome::kAboutScheme, MessageLoop::current()) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 #endif | 765 #endif |
795 } else if (path == kTermsPath) { | 766 } else if (path == kTermsPath) { |
796 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 767 response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
797 IDR_TERMS_HTML).as_string(); | 768 IDR_TERMS_HTML).as_string(); |
798 #if defined(OS_LINUX) | 769 #if defined(OS_LINUX) |
799 } else if (path == kLinuxProxyConfigPath) { | 770 } else if (path == kLinuxProxyConfigPath) { |
800 response = AboutLinuxProxyConfig(); | 771 response = AboutLinuxProxyConfig(); |
801 } else if (path == kSandboxPath) { | 772 } else if (path == kSandboxPath) { |
802 response = AboutSandbox(); | 773 response = AboutSandbox(); |
803 #endif | 774 #endif |
804 } else if (path == kSyncPath) { | |
805 response = AboutSync(); | |
806 } | 775 } |
807 | 776 |
808 FinishDataRequest(response, request_id); | 777 FinishDataRequest(response, request_id); |
809 } | 778 } |
810 | 779 |
811 void AboutSource::FinishDataRequest(const std::string& response, | 780 void AboutSource::FinishDataRequest(const std::string& response, |
812 int request_id) { | 781 int request_id) { |
813 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); | 782 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); |
814 html_bytes->data.resize(response.size()); | 783 html_bytes->data.resize(response.size()); |
815 std::copy(response.begin(), response.end(), html_bytes->data.begin()); | 784 std::copy(response.begin(), response.end(), html_bytes->data.begin()); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 *url = RemapAboutURL(chrome::kGpuInternalsURL, *url); | 1011 *url = RemapAboutURL(chrome::kGpuInternalsURL, *url); |
1043 return true; | 1012 return true; |
1044 } | 1013 } |
1045 | 1014 |
1046 // Rewrite about:appcache-internals/* URLs to chrome://appcache/* | 1015 // Rewrite about:appcache-internals/* URLs to chrome://appcache/* |
1047 if (StartsWithAboutSpecifier(*url, chrome::kAboutAppCacheInternalsURL)) { | 1016 if (StartsWithAboutSpecifier(*url, chrome::kAboutAppCacheInternalsURL)) { |
1048 *url = RemapAboutURL(chrome::kAppCacheViewInternalsURL, *url); | 1017 *url = RemapAboutURL(chrome::kAppCacheViewInternalsURL, *url); |
1049 return true; | 1018 return true; |
1050 } | 1019 } |
1051 | 1020 |
| 1021 // Rewrite about:sync-internals/* URLs (and about:sync, too, for |
| 1022 // legacy reasons) to chrome://sync-internals/* |
| 1023 if (StartsWithAboutSpecifier(*url, chrome::kAboutSyncInternalsURL) || |
| 1024 StartsWithAboutSpecifier(*url, chrome::kAboutSyncURL)) { |
| 1025 *url = RemapAboutURL(chrome::kSyncViewInternalsURL, *url); |
| 1026 return true; |
| 1027 } |
| 1028 |
1052 // Rewrite about:plugins to chrome://plugins/. | 1029 // Rewrite about:plugins to chrome://plugins/. |
1053 if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutPluginsURL)) { | 1030 if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutPluginsURL)) { |
1054 *url = GURL(chrome::kChromeUIPluginsURL); | 1031 *url = GURL(chrome::kChromeUIPluginsURL); |
1055 return true; | 1032 return true; |
1056 } | 1033 } |
1057 | 1034 |
1058 // Handle URL to crash the browser process. | 1035 // Handle URL to crash the browser process. |
1059 if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutBrowserCrash)) { | 1036 if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutBrowserCrash)) { |
1060 // Induce an intentional crash in the browser process. | 1037 // Induce an intentional crash in the browser process. |
1061 int* bad_pointer = NULL; | 1038 int* bad_pointer = NULL; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1118 // Run the dialog. This will re-use the existing one if it's already up. | 1095 // Run the dialog. This will re-use the existing one if it's already up. |
1119 AboutIPCDialog::RunDialog(); | 1096 AboutIPCDialog::RunDialog(); |
1120 return true; | 1097 return true; |
1121 } | 1098 } |
1122 #endif | 1099 #endif |
1123 | 1100 |
1124 #endif // OFFICIAL_BUILD | 1101 #endif // OFFICIAL_BUILD |
1125 | 1102 |
1126 return false; | 1103 return false; |
1127 } | 1104 } |
OLD | NEW |