Index: chrome/browser/browser_about_handler.cc |
diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc |
index d03c14948a4958e8297bdd7fa5b82a2a460ce4b6..d2ae314f669f2e9c3df26110d6239344a5852710 100644 |
--- a/chrome/browser/browser_about_handler.cc |
+++ b/chrome/browser/browser_about_handler.cc |
@@ -190,6 +190,7 @@ class AboutSource : public ChromeURLDataManager::DataSource { |
public: |
// Creates our datasource. |
AboutSource(); |
+ explicit AboutSource(Profile* profile); |
// Called when the network layer has requested a resource underneath |
// the path we registered. |
@@ -204,9 +205,13 @@ class AboutSource : public ChromeURLDataManager::DataSource { |
// Send the response data. |
void FinishDataRequest(const std::string& html, int request_id); |
+ Profile* GetProfile() { return profile_; } |
+ |
private: |
virtual ~AboutSource(); |
+ Profile* profile_; |
+ |
DISALLOW_COPY_AND_ASSIGN(AboutSource); |
}; |
@@ -903,7 +908,7 @@ std::string AboutSandbox() { |
} |
#endif |
-std::string AboutVersion(DictionaryValue* localized_strings) { |
+std::string AboutVersion(DictionaryValue* localized_strings, Profile* profile) { |
localized_strings->SetString("title", |
l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_TITLE)); |
chrome::VersionInfo version_info; |
@@ -922,9 +927,17 @@ std::string AboutVersion(DictionaryValue* localized_strings) { |
localized_strings->SetString("version", version_info.Version()); |
localized_strings->SetString("version_modifier", |
platform_util::GetVersionStringModifier()); |
+ localized_strings->SetString("os_name", |
+ l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_OS)); |
+ localized_strings->SetString("os_type", version_info.OSType()); |
+ localized_strings->SetString("webkit_name", |
+ l10n_util::GetStringUTF16( |
+ IDS_ABOUT_VERSION_WEBKIT)); |
+ localized_strings->SetString("webkit_version", webkit_version); |
+ localized_strings->SetString("js_name", |
+ l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_JS)); |
localized_strings->SetString("js_engine", js_engine); |
localized_strings->SetString("js_version", js_version); |
- localized_strings->SetString("webkit_version", webkit_version); |
localized_strings->SetString("company", |
l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_COMPANY_NAME)); |
localized_strings->SetString("copyright", |
@@ -955,6 +968,30 @@ std::string AboutVersion(DictionaryValue* localized_strings) { |
localized_strings->SetString("command_line", command_line); |
#endif |
+ // Allow IO temporarily since the following operation will complete quickly |
+ bool io_allowed = base::ThreadRestrictions::SetIOAllowed(true); |
Evan Martin
2011/04/22 22:36:41
I don't like this. Why not just not call Absolute
|
+ localized_strings->SetString("executable_path_name", |
+ l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_EXECUTABLE_PATH)); |
+ FilePath executable_path = CommandLine::ForCurrentProcess()->GetProgram(); |
+ if (file_util::AbsolutePath(&executable_path)) { |
+ localized_strings->SetString("executable_path", executable_path.value()); |
+ } else { |
+ localized_strings->SetString("executable_path", "No such file"); |
+ } |
+ localized_strings->SetString("profile_path_name", |
+ l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_PROFILE_PATH)); |
+ if (profile) { |
+ FilePath profile_path = profile->GetPath(); |
+ if (file_util::AbsolutePath(&profile_path)) { |
+ localized_strings->SetString("profile_path", profile_path.value()); |
+ } else { |
+ localized_strings->SetString("profile_path", "No such file"); |
+ } |
+ } else { |
+ localized_strings->SetString("profile_path", "No such file"); |
+ } |
+ base::ThreadRestrictions::SetIOAllowed(io_allowed); |
+ |
base::StringPiece version_html( |
ResourceBundle::GetSharedInstance().GetRawDataResource( |
IDR_ABOUT_VERSION_HTML)); |
@@ -975,6 +1012,11 @@ AboutSource::AboutSource() |
: DataSource(chrome::kAboutScheme, MessageLoop::current()) { |
} |
+AboutSource::AboutSource(Profile* profile) |
+ : DataSource(chrome::kAboutScheme, MessageLoop::current()), |
+ profile_(profile) { |
+} |
+ |
AboutSource::~AboutSource() { |
} |
@@ -1015,8 +1057,9 @@ void AboutSource::StartDataRequest(const std::string& path_raw, |
new ChromeOSAboutVersionHandler(this, request_id); |
return; |
#else |
- DictionaryValue value; |
- response = AboutVersion(&value); |
+ DictionaryValue localized_strings; |
+ localized_strings.SetString("os_version", ""); |
+ response = AboutVersion(&localized_strings, profile_); |
#endif |
} else if (path == kCreditsPath) { |
response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
@@ -1206,11 +1249,9 @@ void ChromeOSAboutVersionHandler::OnVersion( |
chromeos::VersionLoader::Handle handle, |
std::string version) { |
DictionaryValue localized_strings; |
- localized_strings.SetString("os_name", |
- l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME)); |
localized_strings.SetString("os_version", version); |
- localized_strings.SetBoolean("is_chrome_os", true); |
- source_->FinishDataRequest(AboutVersion(&localized_strings), request_id_); |
+ source_->FinishDataRequest(AboutVersion(&localized_strings, |
+ source_->GetProfile()), request_id_); |
// CancelableRequestProvider isn't happy when it's deleted and servicing a |
// task, so we delay the deletion. |
@@ -1356,7 +1397,7 @@ bool WillHandleBrowserAboutURL(GURL* url, Profile* profile) { |
} |
void InitializeAboutDataSource(Profile* profile) { |
- profile->GetChromeURLDataManager()->AddDataSource(new AboutSource()); |
+ profile->GetChromeURLDataManager()->AddDataSource(new AboutSource(profile)); |
} |
// This function gets called with the fixed-up chrome: URLs, so we have to |