Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: chrome/browser/browser_about_handler.cc

Issue 6894037: Add more information to about:version and "About Chromium" dialog (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Replace "a/an" with "the", Put OS_CHROMEOS with OS_LINUX, etc Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/resources/about_version.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // time that about memory is being computed. 186 // time that about memory is being computed.
187 std::string GetAboutMemoryRedirectResponse() { 187 std::string GetAboutMemoryRedirectResponse() {
188 return "<meta http-equiv=\"refresh\" " 188 return "<meta http-equiv=\"refresh\" "
189 "content=\"0;chrome://about/memory\">"; 189 "content=\"0;chrome://about/memory\">";
190 } 190 }
191 191
192 class AboutSource : public ChromeURLDataManager::DataSource { 192 class AboutSource : public ChromeURLDataManager::DataSource {
193 public: 193 public:
194 // Creates our datasource. 194 // Creates our datasource.
195 AboutSource(); 195 AboutSource();
196 explicit AboutSource(Profile* profile);
196 197
197 // Called when the network layer has requested a resource underneath 198 // Called when the network layer has requested a resource underneath
198 // the path we registered. 199 // the path we registered.
199 virtual void StartDataRequest(const std::string& path, 200 virtual void StartDataRequest(const std::string& path,
200 bool is_incognito, 201 bool is_incognito,
201 int request_id); 202 int request_id);
202 203
203 virtual std::string GetMimeType(const std::string&) const { 204 virtual std::string GetMimeType(const std::string&) const {
204 return "text/html"; 205 return "text/html";
205 } 206 }
206 207
207 // Send the response data. 208 // Send the response data.
208 void FinishDataRequest(const std::string& html, int request_id); 209 void FinishDataRequest(const std::string& html, int request_id);
209 210
211 Profile* GetProfile() { return profile_; }
212
210 private: 213 private:
211 virtual ~AboutSource(); 214 virtual ~AboutSource();
212 215
216 Profile* profile_;
217
213 DISALLOW_COPY_AND_ASSIGN(AboutSource); 218 DISALLOW_COPY_AND_ASSIGN(AboutSource);
214 }; 219 };
215 220
216 // Handling about:memory is complicated enough to encapsulate its related 221 // Handling about:memory is complicated enough to encapsulate its related
217 // methods into a single class. The user should create it (on the heap) and call 222 // methods into a single class. The user should create it (on the heap) and call
218 // its |StartFetch()| method. 223 // its |StartFetch()| method.
219 class AboutMemoryHandler : public MemoryDetails { 224 class AboutMemoryHandler : public MemoryDetails {
220 public: 225 public:
221 AboutMemoryHandler(AboutSource* source, int request_id) 226 AboutMemoryHandler(AboutSource* source, int request_id)
222 : source_(source), request_id_(request_id) {} 227 : source_(source), request_id_(request_id) {}
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 data.append("<p style=\"color: red\">"); 904 data.append("<p style=\"color: red\">");
900 data.append(l10n_util::GetStringUTF8(IDS_ABOUT_SANDBOX_BAD)); 905 data.append(l10n_util::GetStringUTF8(IDS_ABOUT_SANDBOX_BAD));
901 } 906 }
902 data.append("</p>"); 907 data.append("</p>");
903 908
904 data.append("</body></html>\n"); 909 data.append("</body></html>\n");
905 return data; 910 return data;
906 } 911 }
907 #endif 912 #endif
908 913
909 std::string AboutVersion(DictionaryValue* localized_strings) { 914 std::string AboutVersion(DictionaryValue* localized_strings, Profile* profile) {
910 localized_strings->SetString("title", 915 localized_strings->SetString("title",
911 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_TITLE)); 916 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_TITLE));
912 chrome::VersionInfo version_info; 917 chrome::VersionInfo version_info;
913 918
914 std::string webkit_version = webkit_glue::GetWebKitVersion(); 919 std::string webkit_version = webkit_glue::GetWebKitVersion();
915 #ifdef CHROME_V8 920 #ifdef CHROME_V8
916 std::string js_version(v8::V8::GetVersion()); 921 std::string js_version(v8::V8::GetVersion());
917 std::string js_engine = "V8"; 922 std::string js_engine = "V8";
918 #else 923 #else
919 std::string js_version = webkit_version; 924 std::string js_version = webkit_version;
920 std::string js_engine = "JavaScriptCore"; 925 std::string js_engine = "JavaScriptCore";
921 #endif 926 #endif
922 927
923 localized_strings->SetString("name", 928 localized_strings->SetString("name",
924 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 929 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
925 localized_strings->SetString("version", version_info.Version()); 930 localized_strings->SetString("version", version_info.Version());
926 // Bug 79458: Need to evaluate the use of getting the version string on 931 // Bug 79458: Need to evaluate the use of getting the version string on
927 // this thread. 932 // this thread.
928 base::ThreadRestrictions::ScopedAllowIO allow_io; 933 base::ThreadRestrictions::ScopedAllowIO allow_io;
929 localized_strings->SetString("version_modifier", 934 localized_strings->SetString("version_modifier",
930 platform_util::GetVersionStringModifier()); 935 platform_util::GetVersionStringModifier());
936 localized_strings->SetString("os_name",
937 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_OS));
938 localized_strings->SetString("os_type", version_info.OSType());
939 localized_strings->SetString("webkit_version", webkit_version);
931 localized_strings->SetString("js_engine", js_engine); 940 localized_strings->SetString("js_engine", js_engine);
932 localized_strings->SetString("js_version", js_version); 941 localized_strings->SetString("js_version", js_version);
933 942
934 // Obtain the version of the first enabled Flash plugin. 943 // Obtain the version of the first enabled Flash plugin.
935 std::vector<webkit::npapi::WebPluginInfo> info_array; 944 std::vector<webkit::npapi::WebPluginInfo> info_array;
936 webkit::npapi::PluginList::Singleton()->GetPluginInfoArray( 945 webkit::npapi::PluginList::Singleton()->GetPluginInfoArray(
937 GURL(), "application/x-shockwave-flash", false, &info_array, NULL); 946 GURL(), "application/x-shockwave-flash", false, &info_array, NULL);
938 string16 flash_version = 947 string16 flash_version =
939 l10n_util::GetStringUTF16(IDS_PLUGINS_DISABLED_PLUGIN); 948 l10n_util::GetStringUTF16(IDS_PLUGINS_DISABLED_PLUGIN);
940 for (size_t i = 0; i < info_array.size(); ++i) { 949 for (size_t i = 0; i < info_array.size(); ++i) {
(...skipping 28 matching lines...) Expand all
969 std::string command_line = ""; 978 std::string command_line = "";
970 typedef std::vector<std::string> ArgvList; 979 typedef std::vector<std::string> ArgvList;
971 const ArgvList& argv = CommandLine::ForCurrentProcess()->argv(); 980 const ArgvList& argv = CommandLine::ForCurrentProcess()->argv();
972 for (ArgvList::const_iterator iter = argv.begin(); iter != argv.end(); iter++) 981 for (ArgvList::const_iterator iter = argv.begin(); iter != argv.end(); iter++)
973 command_line += " " + *iter; 982 command_line += " " + *iter;
974 // TODO(viettrungluu): |command_line| could really have any encoding, whereas 983 // TODO(viettrungluu): |command_line| could really have any encoding, whereas
975 // below we assumes it's UTF-8. 984 // below we assumes it's UTF-8.
976 localized_strings->SetString("command_line", command_line); 985 localized_strings->SetString("command_line", command_line);
977 #endif 986 #endif
978 987
988 localized_strings->SetString("executable_path_name",
989 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_EXECUTABLE_PATH));
990 FilePath executable_path = CommandLine::ForCurrentProcess()->GetProgram();
991 #if defined(OS_WIN)
992 wchar_t path_buf[MAX_PATH];
993 if (_wfullpath(path_buf, executable_path.value().c_str(), MAX_PATH)) {
Evan Martin 2011/05/03 01:16:24 It appears you didn't upload the change with Absol
994 localized_strings->SetString("executable_path", path_buf);
995 } else {
996 localized_strings->SetString("executable_path", "No such file");
997 }
998 #elif defined(OS_POSIX)
999 char path_buf[PATH_MAX];
1000 if (realpath(executable_path.value().c_str(), path_buf) != NULL) {
1001 localized_strings->SetString("executable_path", path_buf);
1002 } else {
1003 localized_strings->SetString("executable_path", "No such file");
1004 }
1005 #else
1006 localized_strings->SetString("executable_path", "No such file");
1007 #endif
1008
1009 localized_strings->SetString("profile_path_name",
1010 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_PROFILE_PATH));
1011 if (profile) {
1012 FilePath profile_path = profile->GetPath();
1013 #if defined(OS_WIN)
1014 if (_wfullpath(path_buf, profile_path.value().c_str(), MAX_PATH)) {
1015 localized_strings->SetString("profile_path", path_buf);
1016 } else {
1017 localized_strings->SetString("profile_path", "No such file");
1018 }
1019 #elif defined(OS_POSIX)
1020 if (realpath(profile_path.value().c_str(), path_buf) != NULL) {
1021 localized_strings->SetString("profile_path", path_buf);
1022 } else {
1023 localized_strings->SetString("profile_path", "No such file");
1024 }
1025 #else
1026 localized_strings->SetString("profile_path", "No such file");
1027 #endif
1028 } else {
1029 localized_strings->SetString("profile_path", "No such file");
1030 }
1031
979 base::StringPiece version_html( 1032 base::StringPiece version_html(
980 ResourceBundle::GetSharedInstance().GetRawDataResource( 1033 ResourceBundle::GetSharedInstance().GetRawDataResource(
981 IDR_ABOUT_VERSION_HTML)); 1034 IDR_ABOUT_VERSION_HTML));
982 1035
983 return jstemplate_builder::GetTemplatesHtml( 1036 return jstemplate_builder::GetTemplatesHtml(
984 version_html, localized_strings, "t" /* template root node id */); 1037 version_html, localized_strings, "t" /* template root node id */);
985 } 1038 }
986 1039
987 std::string VersionNumberToString(uint32 value) { 1040 std::string VersionNumberToString(uint32 value) {
988 int hi = (value >> 8) & 0xff; 1041 int hi = (value >> 8) & 0xff;
989 int low = value & 0xff; 1042 int low = value & 0xff;
990 return base::IntToString(hi) + "." + base::IntToString(low); 1043 return base::IntToString(hi) + "." + base::IntToString(low);
991 } 1044 }
992 1045
993 // AboutSource ----------------------------------------------------------------- 1046 // AboutSource -----------------------------------------------------------------
994 1047
995 AboutSource::AboutSource() 1048 AboutSource::AboutSource()
996 : DataSource(chrome::kAboutScheme, MessageLoop::current()) { 1049 : DataSource(chrome::kAboutScheme, MessageLoop::current()) {
997 } 1050 }
998 1051
1052 AboutSource::AboutSource(Profile* profile)
1053 : DataSource(chrome::kAboutScheme, MessageLoop::current()),
1054 profile_(profile) {
1055 }
1056
999 AboutSource::~AboutSource() { 1057 AboutSource::~AboutSource() {
1000 } 1058 }
1001 1059
1002 void AboutSource::StartDataRequest(const std::string& path_raw, 1060 void AboutSource::StartDataRequest(const std::string& path_raw,
1003 bool is_incognito, int request_id) { 1061 bool is_incognito, int request_id) {
1004 std::string path = path_raw; 1062 std::string path = path_raw;
1005 std::string info; 1063 std::string info;
1006 if (path.find("/") != std::string::npos) { 1064 if (path.find("/") != std::string::npos) {
1007 size_t pos = path.find("/"); 1065 size_t pos = path.find("/");
1008 info = path.substr(pos + 1, path.length() - (pos + 1)); 1066 info = path.substr(pos + 1, path.length() - (pos + 1));
(...skipping 20 matching lines...) Expand all
1029 response = AboutStats(info); 1087 response = AboutStats(info);
1030 #if defined(USE_TCMALLOC) 1088 #if defined(USE_TCMALLOC)
1031 } else if (path == kTcmallocPath) { 1089 } else if (path == kTcmallocPath) {
1032 response = AboutTcmalloc(info); 1090 response = AboutTcmalloc(info);
1033 #endif 1091 #endif
1034 } else if (path == kVersionPath || path.empty()) { 1092 } else if (path == kVersionPath || path.empty()) {
1035 #if defined(OS_CHROMEOS) 1093 #if defined(OS_CHROMEOS)
1036 new ChromeOSAboutVersionHandler(this, request_id); 1094 new ChromeOSAboutVersionHandler(this, request_id);
1037 return; 1095 return;
1038 #else 1096 #else
1039 DictionaryValue value; 1097 DictionaryValue localized_strings;
1040 response = AboutVersion(&value); 1098 localized_strings.SetString("os_version", "");
1099 response = AboutVersion(&localized_strings, profile_);
1041 #endif 1100 #endif
1042 } else if (path == kCreditsPath) { 1101 } else if (path == kCreditsPath) {
1043 response = ResourceBundle::GetSharedInstance().GetRawDataResource( 1102 response = ResourceBundle::GetSharedInstance().GetRawDataResource(
1044 IDR_CREDITS_HTML).as_string(); 1103 IDR_CREDITS_HTML).as_string();
1045 } else if (path == kAboutPath) { 1104 } else if (path == kAboutPath) {
1046 response = AboutAbout(); 1105 response = AboutAbout();
1047 #if defined(OS_CHROMEOS) 1106 #if defined(OS_CHROMEOS)
1048 } else if (path == kOSCreditsPath) { 1107 } else if (path == kOSCreditsPath) {
1049 response = ResourceBundle::GetSharedInstance().GetRawDataResource( 1108 response = ResourceBundle::GetSharedInstance().GetRawDataResource(
1050 IDR_OS_CREDITS_HTML).as_string(); 1109 IDR_OS_CREDITS_HTML).as_string();
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 request_id_(request_id) { 1279 request_id_(request_id) {
1221 loader_.GetVersion(&consumer_, 1280 loader_.GetVersion(&consumer_,
1222 NewCallback(this, &ChromeOSAboutVersionHandler::OnVersion), 1281 NewCallback(this, &ChromeOSAboutVersionHandler::OnVersion),
1223 chromeos::VersionLoader::VERSION_FULL); 1282 chromeos::VersionLoader::VERSION_FULL);
1224 } 1283 }
1225 1284
1226 void ChromeOSAboutVersionHandler::OnVersion( 1285 void ChromeOSAboutVersionHandler::OnVersion(
1227 chromeos::VersionLoader::Handle handle, 1286 chromeos::VersionLoader::Handle handle,
1228 std::string version) { 1287 std::string version) {
1229 DictionaryValue localized_strings; 1288 DictionaryValue localized_strings;
1230 localized_strings.SetString("os_name",
1231 l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME));
1232 localized_strings.SetString("os_version", version); 1289 localized_strings.SetString("os_version", version);
1233 localized_strings.SetBoolean("is_chrome_os", true); 1290 source_->FinishDataRequest(AboutVersion(&localized_strings,
1234 source_->FinishDataRequest(AboutVersion(&localized_strings), request_id_); 1291 source_->GetProfile()), request_id_);
1235 1292
1236 // CancelableRequestProvider isn't happy when it's deleted and servicing a 1293 // CancelableRequestProvider isn't happy when it's deleted and servicing a
1237 // task, so we delay the deletion. 1294 // task, so we delay the deletion.
1238 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 1295 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
1239 } 1296 }
1240 1297
1241 #endif 1298 #endif
1242 1299
1243 // Returns true if |url|'s spec starts with |about_specifier|, and is 1300 // Returns true if |url|'s spec starts with |about_specifier|, and is
1244 // terminated by the start of a path. 1301 // terminated by the start of a path.
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 // Rewrite the about URL to use chrome:. WebKit treats all about URLS the 1427 // Rewrite the about URL to use chrome:. WebKit treats all about URLS the
1371 // same (blank page), so if we want to display content, we need another 1428 // same (blank page), so if we want to display content, we need another
1372 // scheme. 1429 // scheme.
1373 std::string about_url = "chrome://about/"; 1430 std::string about_url = "chrome://about/";
1374 about_url.append(url->path()); 1431 about_url.append(url->path());
1375 *url = GURL(about_url); 1432 *url = GURL(about_url);
1376 return true; 1433 return true;
1377 } 1434 }
1378 1435
1379 void InitializeAboutDataSource(Profile* profile) { 1436 void InitializeAboutDataSource(Profile* profile) {
1380 profile->GetChromeURLDataManager()->AddDataSource(new AboutSource()); 1437 profile->GetChromeURLDataManager()->AddDataSource(new AboutSource(profile));
1381 } 1438 }
1382 1439
1383 // This function gets called with the fixed-up chrome: URLs, so we have to 1440 // This function gets called with the fixed-up chrome: URLs, so we have to
1384 // compare against those instead of "about:blah". 1441 // compare against those instead of "about:blah".
1385 bool HandleNonNavigationAboutURL(const GURL& url) { 1442 bool HandleNonNavigationAboutURL(const GURL& url) {
1386 // about:ipc is currently buggy, so we disable it for official builds. 1443 // about:ipc is currently buggy, so we disable it for official builds.
1387 #if !defined(OFFICIAL_BUILD) 1444 #if !defined(OFFICIAL_BUILD)
1388 1445
1389 #if (defined(OS_MACOSX) || defined(OS_WIN)) && defined(IPC_MESSAGE_LOG_ENABLED) 1446 #if (defined(OS_MACOSX) || defined(OS_WIN)) && defined(IPC_MESSAGE_LOG_ENABLED)
1390 if (LowerCaseEqualsASCII(url.spec(), chrome::kChromeUIIPCURL)) { 1447 if (LowerCaseEqualsASCII(url.spec(), chrome::kChromeUIIPCURL)) {
1391 // Run the dialog. This will re-use the existing one if it's already up. 1448 // Run the dialog. This will re-use the existing one if it's already up.
1392 browser::ShowAboutIPCDialog(); 1449 browser::ShowAboutIPCDialog();
1393 return true; 1450 return true;
1394 } 1451 }
1395 #endif 1452 #endif
1396 1453
1397 #endif // OFFICIAL_BUILD 1454 #endif // OFFICIAL_BUILD
1398 1455
1399 return false; 1456 return false;
1400 } 1457 }
1401 1458
1402 std::vector<std::string> AboutPaths() { 1459 std::vector<std::string> AboutPaths() {
1403 std::vector<std::string> paths; 1460 std::vector<std::string> paths;
1404 paths.reserve(arraysize(kAllAboutPaths)); 1461 paths.reserve(arraysize(kAllAboutPaths));
1405 for (size_t i = 0; i < arraysize(kAllAboutPaths); i++) 1462 for (size_t i = 0; i < arraysize(kAllAboutPaths); i++)
1406 paths.push_back(kAllAboutPaths[i]); 1463 paths.push_back(kAllAboutPaths[i]);
1407 return paths; 1464 return paths;
1408 } 1465 }
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/resources/about_version.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698