diff options
31 files changed, 253 insertions, 252 deletions
diff --git a/chrome/app/breakpad_linux.cc b/chrome/app/breakpad_linux.cc index 4d32ac5..42d7b93 100644 --- a/chrome/app/breakpad_linux.cc +++ b/chrome/app/breakpad_linux.cc @@ -187,13 +187,7 @@ pid_t HandleCrashDump(const BreakpadInfo& info) { mime_boundary[28 + 16] = 0; IGNORE_RET(sys_close(ufd)); - // The define for the product version is a wide string, so we need to - // downconvert it. - static const wchar_t version[] = PRODUCT_VERSION; - static const unsigned version_len = sizeof(version) / sizeof(wchar_t); - char version_msg[version_len]; - for (unsigned i = 0; i < version_len; ++i) - version_msg[i] = static_cast<char>(version[i]); + static const char version_msg[] = PRODUCT_VERSION; // The MIME block looks like this: // BOUNDARY \r\n (0, 1) diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc index d65908c..ee05d82 100644 --- a/chrome/app/chrome_dll_main.cc +++ b/chrome/app/chrome_dll_main.cc @@ -38,7 +38,6 @@ #include "base/at_exit.h" #include "base/command_line.h" #include "base/debug_util.h" -#include "base/file_version_info.h" #include "base/i18n/icu_util.h" #include "base/message_loop.h" #include "base/path_service.h" @@ -506,25 +505,25 @@ int ChromeMain(int argc, char** argv) { #endif const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); + const chrome::VersionInfo version_info; -#if defined(OS_POSIX) && !defined(OS_MACOSX) +#if defined(OS_POSIX) + +#if !defined(OS_MACOSX) if (parsed_command_line.HasSwitch(switches::kProductVersion)) { - scoped_ptr<FileVersionInfo> version(chrome::GetChromeVersionInfo()); - printf("%s\n", WideToASCII(version->product_version()).c_str()); + printf("%s\n", version_info.Version().c_str()); return 0; } #endif -#if defined(OS_POSIX) if (parsed_command_line.HasSwitch(switches::kVersion)) { - scoped_ptr<FileVersionInfo> version(chrome::GetChromeVersionInfo()); printf("%s %s %s\n", - WideToUTF8(version->product_name()).c_str(), - WideToASCII(version->product_version()).c_str(), - UTF16ToUTF8(platform_util::GetVersionStringModifier()).c_str()); + version_info.Name().c_str(), + version_info.Version().c_str(), + platform_util::GetVersionStringModifier().c_str()); return 0; } -#endif +#endif // OS_POSIX std::string process_type = parsed_command_line.GetSwitchValueASCII(switches::kProcessType); diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index d432550..cf6b072 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -9,7 +9,6 @@ #include "app/message_box_flags.h" #include "base/callback.h" #include "base/file_path.h" -#include "base/file_version_info.h" #include "base/json/json_reader.h" #include "base/json/json_writer.h" #include "base/json/string_escape.h" @@ -160,14 +159,10 @@ void AutomationProvider::ConnectToChannel(const std::string& channel_id) { automation_resource_message_filter_, g_browser_process->io_thread()->message_loop(), true, g_browser_process->shutdown_event())); - scoped_ptr<FileVersionInfo> version_info(chrome::GetChromeVersionInfo()); - std::string version_string; - if (version_info != NULL) { - version_string = WideToASCII(version_info->file_version()); - } + chrome::VersionInfo version_info; // Send a hello message with our current automation protocol version. - channel_->Send(new AutomationMsg_Hello(0, version_string.c_str())); + channel_->Send(new AutomationMsg_Hello(0, version_info.Version().c_str())); TRACE_EVENT_END("AutomationProvider::ConnectToChannel", 0, ""); } diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc index 4599689..e4ce4cf 100644 --- a/chrome/browser/browser_about_handler.cc +++ b/chrome/browser/browser_about_handler.cc @@ -12,7 +12,6 @@ #include "app/resource_bundle.h" #include "base/callback.h" #include "base/command_line.h" -#include "base/file_version_info.h" #include "base/histogram.h" #include "base/i18n/number_formatting.h" #include "base/path_service.h" @@ -611,11 +610,7 @@ std::string AboutSandbox() { std::string AboutVersion(DictionaryValue* localized_strings) { localized_strings->SetString("title", l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_TITLE)); - scoped_ptr<FileVersionInfo> version_info(chrome::GetChromeVersionInfo()); - if (version_info == NULL) { - DLOG(ERROR) << "Unable to create FileVersionInfo object"; - return std::string(); - } + chrome::VersionInfo version_info; std::string webkit_version = webkit_glue::GetWebKitVersion(); #ifdef CHROME_V8 @@ -628,10 +623,9 @@ std::string AboutVersion(DictionaryValue* localized_strings) { localized_strings->SetString("name", l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); - localized_strings->SetString("version", - WideToUTF16Hack(version_info->file_version())); + localized_strings->SetString("version", version_info.Version()); localized_strings->SetString("version_modifier", - platform_util::GetVersionStringModifier()); + platform_util::GetVersionStringModifier()); localized_strings->SetString("js_engine", js_engine); localized_strings->SetString("js_version", js_version); localized_strings->SetString("webkit_version", webkit_version); @@ -639,15 +633,12 @@ std::string AboutVersion(DictionaryValue* localized_strings) { l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_COMPANY_NAME)); localized_strings->SetString("copyright", l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_COPYRIGHT)); - localized_strings->SetString("cl", - WideToUTF16Hack(version_info->last_change())); - if (version_info->is_official_build()) { - localized_strings->SetString("official", - l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_OFFICIAL)); - } else { - localized_strings->SetString("official", - l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_UNOFFICIAL)); - } + localized_strings->SetString("cl", version_info.LastChange()); + localized_strings->SetString("official", + l10n_util::GetStringUTF16( + version_info.IsOfficialBuild() ? + IDS_ABOUT_VERSION_OFFICIAL + : IDS_ABOUT_VERSION_UNOFFICIAL)); localized_strings->SetString("user_agent_name", l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_USER_AGENT)); localized_strings->SetString("useragent", webkit_glue::GetUserAgent(GURL())); diff --git a/chrome/browser/bug_report_util.cc b/chrome/browser/bug_report_util.cc index 71d8612..04db543 100644 --- a/chrome/browser/bug_report_util.cc +++ b/chrome/browser/bug_report_util.cc @@ -274,17 +274,14 @@ void BugReportUtil::SendReport(Profile* profile, web_data->set_url(page_url_text); // Add the Chrome version - std::string chrome_version; - scoped_ptr<FileVersionInfo> version_info(chrome::GetChromeVersionInfo()); - if (version_info.get()) { - chrome_version = WideToUTF8(version_info->product_name()) + " - " + - WideToUTF8(version_info->file_version()) + - " (" + WideToUTF8(version_info->last_change()) + ")"; - } - - if (!chrome_version.empty()) + chrome::VersionInfo version_info; + if (version_info.is_valid()) { + std::string chrome_version = version_info.Name() + " - " + + version_info.Version() + + " (" + version_info.LastChange() + ")"; AddFeedbackData(&feedback_data, std::string(kChromeVersionTag), chrome_version); + } // Add OS version (eg, for WinXP SP2: "5.1.2600 Service Pack 2"). std::string os_version = ""; diff --git a/chrome/browser/cocoa/about_window_controller.mm b/chrome/browser/cocoa/about_window_controller.mm index f366b61..bb8044c 100644 --- a/chrome/browser/cocoa/about_window_controller.mm +++ b/chrome/browser/cocoa/about_window_controller.mm @@ -133,10 +133,10 @@ static BOOL recentShownUserActionFailedStatus = NO; NSString* versionModifier = @""; NSString* svnRevision = @""; - string16 modifier = platform_util::GetVersionStringModifier(); - if (modifier.length()) + std::string modifier = platform_util::GetVersionStringModifier(); + if (!modifier.empty()) versionModifier = [NSString stringWithFormat:@" %@", - base::SysUTF16ToNSString(modifier)]; + base::SysUTF8ToNSString(modifier)]; #if !defined(GOOGLE_CHROME_BUILD) svnRevision = [NSString stringWithFormat:@" (%@)", diff --git a/chrome/browser/diagnostics/recon_diagnostics.cc b/chrome/browser/diagnostics/recon_diagnostics.cc index bbe23f7..52f2ff0 100644 --- a/chrome/browser/diagnostics/recon_diagnostics.cc +++ b/chrome/browser/diagnostics/recon_diagnostics.cc @@ -7,7 +7,6 @@ #include <string> #include "base/file_util.h" -#include "base/file_version_info.h" #include "base/json/json_reader.h" #include "base/string_util.h" #include "base/string_number_conversions.h" @@ -116,26 +115,23 @@ class VersionTest : public DiagnosticTest { virtual int GetId() { return 0; } virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) { - scoped_ptr<FileVersionInfo> version_info( - chrome::GetChromeVersionInfo()); - if (!version_info.get()) { + chrome::VersionInfo version_info; + if (!version_info.is_valid()) { RecordFailure(ASCIIToUTF16("No Version")); return true; } - string16 current_version = WideToUTF16(version_info->file_version()); + std::string current_version = version_info.Version(); if (current_version.empty()) { RecordFailure(ASCIIToUTF16("Empty Version")); return true; } - string16 version_modifier = platform_util::GetVersionStringModifier(); - if (!version_modifier.empty()) { - current_version += ASCIIToUTF16(" "); - current_version += version_modifier; - } + std::string version_modifier = platform_util::GetVersionStringModifier(); + if (!version_modifier.empty()) + current_version += " " + version_modifier; #if defined(GOOGLE_CHROME_BUILD) - current_version += ASCIIToUTF16(" GCB"); + current_version += " GCB"; #endif // defined(GOOGLE_CHROME_BUILD) - RecordSuccess(current_version); + RecordSuccess(ASCIIToUTF16(current_version)); return true; } diff --git a/chrome/browser/dom_ui/about_page_handler.cc b/chrome/browser/dom_ui/about_page_handler.cc index 6275b7d..750a921 100644 --- a/chrome/browser/dom_ui/about_page_handler.cc +++ b/chrome/browser/dom_ui/about_page_handler.cc @@ -9,7 +9,6 @@ #include "base/basictypes.h" #include "base/callback.h" #include "base/command_line.h" -#include "base/file_version_info.h" #include "base/i18n/time_formatting.h" #include "base/string16.h" #include "base/string_number_conversions.h" @@ -136,21 +135,18 @@ void AboutPageHandler::GetLocalizedValues(DictionaryValue* localized_strings) { // browser version - scoped_ptr<FileVersionInfo> version_info(chrome::GetChromeVersionInfo()); - DCHECK(version_info.get() != NULL); + chrome::VersionInfo version_info; + DCHECK(version_info.is_valid()); - string16 browser_version = WideToUTF16Hack(version_info->file_version()); - - string16 version_modifier = platform_util::GetVersionStringModifier(); - if (version_modifier.length()) { - browser_version += ASCIIToUTF16(" "); - browser_version += version_modifier; - } + std::string browser_version = version_info.Version(); + std::string version_modifier = platform_util::GetVersionStringModifier(); + if (!version_modifier.empty()) + browser_version += " " + version_modifier; #if !defined(GOOGLE_CHROME_BUILD) - browser_version += ASCIIToUTF16(" ("); - browser_version += WideToUTF16Hack(version_info->last_change()); - browser_version += ASCIIToUTF16(")"); + browser_version += " ("; + browser_version += version_info.LastChange(); + browser_version += ")"; #endif localized_strings->SetString("browser_version", browser_version); diff --git a/chrome/browser/dom_ui/net_internals_ui.cc b/chrome/browser/dom_ui/net_internals_ui.cc index 63ad1a2..c10428a 100644 --- a/chrome/browser/dom_ui/net_internals_ui.cc +++ b/chrome/browser/dom_ui/net_internals_ui.cc @@ -13,7 +13,6 @@ #include "app/resource_bundle.h" #include "base/command_line.h" #include "base/file_util.h" -#include "base/file_version_info.h" #include "base/message_loop.h" #include "base/path_service.h" #include "base/singleton.h" @@ -456,25 +455,21 @@ void NetInternalsMessageHandler::IOThreadImpl::OnRendererReady( { DictionaryValue* dict = new DictionaryValue(); - scoped_ptr<FileVersionInfo> version_info( - chrome::GetChromeVersionInfo()); - - if (version_info == NULL) { - DLOG(ERROR) << "Unable to create FileVersionInfo object"; + chrome::VersionInfo version_info; + if (version_info.is_valid()) { + DLOG(ERROR) << "Unable to create chrome::VersionInfo"; } else { // We have everything we need to send the right values. - dict->SetString("version", WideToUTF16Hack(version_info->file_version())); - dict->SetString("cl", WideToUTF16Hack(version_info->last_change())); - dict->SetString("version_mod", platform_util::GetVersionStringModifier()); - - if (version_info->is_official_build()) { - dict->SetString("official", - l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_OFFICIAL)); - } else { - dict->SetString("official", - l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_UNOFFICIAL)); - } + dict->SetString("version", version_info.Version()); + dict->SetString("cl", version_info.LastChange()); + dict->SetString("version_mod", + platform_util::GetVersionStringModifier()); + dict->SetString("official", + l10n_util::GetStringUTF16( + version_info.IsOfficialBuild() ? + IDS_ABOUT_VERSION_OFFICIAL + : IDS_ABOUT_VERSION_UNOFFICIAL)); dict->SetString("command_line", CommandLine::ForCurrentProcess()->command_line_string()); diff --git a/chrome/browser/extensions/extension_updater.cc b/chrome/browser/extensions/extension_updater.cc index 99415b4..2e1b867 100644 --- a/chrome/browser/extensions/extension_updater.cc +++ b/chrome/browser/extensions/extension_updater.cc @@ -9,7 +9,6 @@ #include "base/logging.h" #include "base/file_util.h" -#include "base/file_version_info.h" #include "base/histogram.h" #include "base/rand_util.h" #include "base/sha2.h" @@ -768,11 +767,10 @@ std::vector<int> ExtensionUpdater::DetermineUpdates( if (update->browser_min_version.length() > 0) { // First determine the browser version if we haven't already. if (!browser_version.get()) { - scoped_ptr<FileVersionInfo> version_info( - chrome::GetChromeVersionInfo()); - if (version_info.get()) { + chrome::VersionInfo version_info; + if (version_info.is_valid()) { browser_version.reset(Version::GetVersionFromString( - version_info->product_version())); + version_info.Version())); } } scoped_ptr<Version> browser_min_version( diff --git a/chrome/browser/gtk/about_chrome_dialog.cc b/chrome/browser/gtk/about_chrome_dialog.cc index edfb269..29f9159 100644 --- a/chrome/browser/gtk/about_chrome_dialog.cc +++ b/chrome/browser/gtk/about_chrome_dialog.cc @@ -11,7 +11,6 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" -#include "base/file_version_info.h" #include "base/utf_string_conversions.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/gtk/cairo_cached_surface.h" @@ -108,18 +107,16 @@ gboolean OnEventBoxExpose(GtkWidget* event_box, void ShowAboutDialogForProfile(GtkWindow* parent, Profile* profile) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); static GdkPixbuf* background = rb.GetPixbufNamed(IDR_ABOUT_BACKGROUND); - scoped_ptr<FileVersionInfo> version_info(chrome::GetChromeVersionInfo()); - std::wstring current_version = version_info->file_version(); + chrome::VersionInfo version_info; + std::string current_version = version_info.Version(); #if !defined(GOOGLE_CHROME_BUILD) - current_version += L" ("; - current_version += version_info->last_change(); - current_version += L")"; + current_version += " ("; + current_version += version_info.LastChange(); + current_version += ")"; #endif - string16 version_modifier = platform_util::GetVersionStringModifier(); - if (version_modifier.length()) { - current_version += L" "; - current_version += UTF16ToWide(version_modifier); - } + std::string channel = platform_util::GetVersionStringModifier(); + if (!channel.empty()) + current_version += " " + channel; // Build the dialog. GtkWidget* dialog = gtk_dialog_new_with_buttons( @@ -159,7 +156,7 @@ void ShowAboutDialogForProfile(GtkWindow* parent, Profile* profile) { gtk_widget_modify_fg(product_label, GTK_STATE_NORMAL, &black); gtk_box_pack_start(GTK_BOX(text_vbox), product_label, FALSE, FALSE, 0); - GtkWidget* version_label = gtk_label_new(WideToUTF8(current_version).c_str()); + GtkWidget* version_label = gtk_label_new(current_version.c_str()); gtk_misc_set_alignment(GTK_MISC(version_label), 0.0, 0.5); gtk_label_set_selectable(GTK_LABEL(version_label), TRUE); gtk_widget_modify_fg(version_label, GTK_STATE_NORMAL, &black); diff --git a/chrome/browser/memory_details_mac.cc b/chrome/browser/memory_details_mac.cc index 74a58d9..26b9fbf 100644 --- a/chrome/browser/memory_details_mac.cc +++ b/chrome/browser/memory_details_mac.cc @@ -15,6 +15,7 @@ #include "base/string_util.h" #include "base/process_util.h" #include "base/thread.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/browser_child_process_host.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_thread.h" @@ -198,10 +199,10 @@ void MemoryDetails::CollectProcessDataChrome( else info.type = ChildProcessInfo::UNKNOWN_PROCESS; - scoped_ptr<FileVersionInfo> version_info(chrome::GetChromeVersionInfo()); - if (version_info.get()) { - info.product_name = version_info->product_name(); - info.version = version_info->product_version(); + chrome::VersionInfo version_info; + if (version_info.is_valid()) { + info.product_name = ASCIIToWide(version_info.Name()); + info.version = ASCIIToWide(version_info.Version()); } else { info.product_name = process_data_[CHROME_BROWSER].name; info.version = L""; diff --git a/chrome/browser/memory_details_win.cc b/chrome/browser/memory_details_win.cc index 5871687..1e6d985 100644 --- a/chrome/browser/memory_details_win.cc +++ b/chrome/browser/memory_details_win.cc @@ -8,6 +8,7 @@ #include "app/l10n_util.h" #include "base/file_version_info.h" #include "base/string_util.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/browser_child_process_host.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/renderer_host/backing_store_manager.h" @@ -121,10 +122,9 @@ void MemoryDetails::CollectProcessData( // Get Version Information. TCHAR name[MAX_PATH]; if (index2 == CHROME_BROWSER || index2 == CHROME_NACL_PROCESS) { - scoped_ptr<FileVersionInfo> version_info( - chrome::GetChromeVersionInfo()); - if (version_info != NULL) - info.version = version_info->file_version(); + chrome::VersionInfo version_info; + if (version_info.is_valid()) + info.version = ASCIIToWide(version_info.Version()); // Check if this is one of the child processes whose data we collected // on the IO thread, and if so copy over that data. for (size_t child = 0; child < child_info.size(); child++) { diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc index 9364427..396c533 100644 --- a/chrome/browser/metrics/metrics_log.cc +++ b/chrome/browser/metrics/metrics_log.cc @@ -9,7 +9,6 @@ #include "base/basictypes.h" #include "base/file_util.h" -#include "base/file_version_info.h" #include "base/perftimer.h" #include "base/scoped_ptr.h" #include "base/string_util.h" @@ -70,20 +69,18 @@ std::string MetricsLog::GetInstallDate() const { // static std::string MetricsLog::GetVersionString() { - scoped_ptr<FileVersionInfo> version_info( - chrome::GetChromeVersionInfo()); - if (version_info.get()) { - std::string version = WideToUTF8(version_info->product_version()); - if (!version_extension_.empty()) - version += version_extension_; - if (!version_info->is_official_build()) - version.append("-devel"); - return version; - } else { - NOTREACHED() << "Unable to retrieve version string."; + chrome::VersionInfo version_info; + if (!version_info.is_valid()) { + NOTREACHED() << "Unable to retrieve version info."; + return std::string(); } - return std::string(); + std::string version = version_info.Version(); + if (!version_extension_.empty()) + version += version_extension_; + if (!version_info.IsOfficialBuild()) + version.append("-devel"); + return version; } void MetricsLog::RecordIncrementalStabilityElements() { diff --git a/chrome/browser/platform_util.h b/chrome/browser/platform_util.h index 63b5995..fb82b19 100644 --- a/chrome/browser/platform_util.h +++ b/chrome/browser/platform_util.h @@ -55,7 +55,7 @@ bool SimpleYesNoBox(gfx::NativeWindow parent, // Return a human readable modifier for the version string. For a // branded Chrome (not Chromium), this modifier is the channel (dev, // beta, but "" for stable). -string16 GetVersionStringModifier(); +std::string GetVersionStringModifier(); } diff --git a/chrome/browser/platform_util_common_linux.cc b/chrome/browser/platform_util_common_linux.cc index 43c588f..1f0ea42 100644 --- a/chrome/browser/platform_util_common_linux.cc +++ b/chrome/browser/platform_util_common_linux.cc @@ -108,11 +108,11 @@ bool SimpleYesNoBox(gfx::NativeWindow parent, return g_dialog_response == GTK_RESPONSE_YES; } -/* Warning: this may be either Linux or ChromeOS */ -string16 GetVersionStringModifier() { +// Warning: this may be either Linux or ChromeOS. +std::string GetVersionStringModifier() { char* env = getenv("CHROME_VERSION_EXTRA"); if (!env) - return string16(); + return std::string(); std::string modifier(env); #if defined(GOOGLE_CHROME_BUILD) @@ -128,7 +128,7 @@ string16 GetVersionStringModifier() { } #endif - return ASCIIToUTF16(modifier); + return modifier; } } // namespace platform_util diff --git a/chrome/browser/platform_util_mac.mm b/chrome/browser/platform_util_mac.mm index 7c71950..3ee28b7 100644 --- a/chrome/browser/platform_util_mac.mm +++ b/chrome/browser/platform_util_mac.mm @@ -176,7 +176,7 @@ bool SimpleYesNoBox(gfx::NativeWindow parent, return result == NSAlertFirstButtonReturn; } -string16 GetVersionStringModifier() { +std::string GetVersionStringModifier() { #if defined(GOOGLE_CHROME_BUILD) // Use the main application bundle and not the framework bundle. Keystone // keys don't live in the framework. @@ -196,9 +196,9 @@ string16 GetVersionStringModifier() { channel = @"unknown"; } - return base::SysNSStringToUTF16(channel); + return base::SysNSStringToUTF8(channel); #else - return string16(); + return std::string(); #endif } diff --git a/chrome/browser/platform_util_win.cc b/chrome/browser/platform_util_win.cc index 5157cb4..1c69075 100644 --- a/chrome/browser/platform_util_win.cc +++ b/chrome/browser/platform_util_win.cc @@ -166,7 +166,7 @@ bool SimpleYesNoBox(gfx::NativeWindow parent, MB_YESNO | MB_ICONWARNING | MB_SETFOREGROUND) == IDYES; } -string16 GetVersionStringModifier() { +std::string GetVersionStringModifier() { #if defined(GOOGLE_CHROME_BUILD) FilePath module; string16 channel; @@ -176,9 +176,9 @@ string16 GetVersionStringModifier() { GoogleUpdateSettings::GetChromeChannel(is_system_install, &channel); } - return channel; + return UTF16ToASCII(channel); #else - return string16(); + return std::string(); #endif } diff --git a/chrome/browser/safe_browsing/protocol_manager.cc b/chrome/browser/safe_browsing/protocol_manager.cc index 611349b..340d0ca 100644 --- a/chrome/browser/safe_browsing/protocol_manager.cc +++ b/chrome/browser/safe_browsing/protocol_manager.cc @@ -8,7 +8,6 @@ #include "base/base64.h" #endif #include "base/environment.h" -#include "base/file_version_info.h" #include "base/histogram.h" #include "base/logging.h" #include "base/rand_util.h" @@ -76,11 +75,11 @@ SafeBrowsingProtocolManager::SafeBrowsingProtocolManager( // The first update must happen between 1-5 minutes of start up. next_update_sec_ = base::RandInt(60, kSbTimerStartIntervalSec); - scoped_ptr<FileVersionInfo> version_info(chrome::GetChromeVersionInfo()); - if (!version_info.get()) + chrome::VersionInfo version_info; + if (!version_info.is_valid()) version_ = "0.1"; else - version_ = WideToASCII(version_info->product_version()); + version_ = version_info.Version(); } SafeBrowsingProtocolManager::~SafeBrowsingProtocolManager() { diff --git a/chrome/browser/sync/glue/sync_backend_host.cc b/chrome/browser/sync/glue/sync_backend_host.cc index 40782ec..6903ecd 100644 --- a/chrome/browser/sync/glue/sync_backend_host.cc +++ b/chrome/browser/sync/glue/sync_backend_host.cc @@ -7,7 +7,6 @@ #include <algorithm> #include "base/file_util.h" -#include "base/file_version_info.h" #include "base/task.h" #include "base/utf_string_conversions.h" #include "chrome/browser/chrome_thread.h" @@ -393,15 +392,15 @@ std::string MakeUserAgentForSyncapi() { #elif defined(OS_MACOSX) user_agent += "MAC "; #endif - scoped_ptr<FileVersionInfo> version_info(chrome::GetChromeVersionInfo()); - if (version_info == NULL) { - DLOG(ERROR) << "Unable to create FileVersionInfo object"; + chrome::VersionInfo version_info; + if (!version_info.is_valid()) { + DLOG(ERROR) << "Unable to create chrome::VersionInfo object"; return user_agent; } - user_agent += WideToUTF8(version_info->product_version()); - user_agent += " (" + WideToUTF8(version_info->last_change()) + ")"; - if (!version_info->is_official_build()) + user_agent += version_info.Version(); + user_agent += " (" + version_info.LastChange() + ")"; + if (!version_info.IsOfficialBuild()) user_agent += "-devel"; return user_agent; } diff --git a/chrome/browser/upgrade_detector.cc b/chrome/browser/upgrade_detector.cc index 38e5a49..ae21a23 100644 --- a/chrome/browser/upgrade_detector.cc +++ b/chrome/browser/upgrade_detector.cc @@ -7,7 +7,6 @@ #include <string> #include "base/command_line.h" -#include "base/file_version_info.h" #include "base/scoped_ptr.h" #include "base/time.h" #include "base/task.h" @@ -102,14 +101,13 @@ class DetectUpgradeTask : public Task { #endif // Get the version of the currently *running* instance of Chrome. - scoped_ptr<FileVersionInfo> version(chrome::GetChromeVersionInfo()); - if (version.get() == NULL) { + chrome::VersionInfo version_info; + if (!version_info.is_valid()) { NOTREACHED() << "Failed to get current file version"; return; } - scoped_ptr<Version> running_version( - Version::GetVersionFromString(WideToUTF16(version->file_version()))); + Version::GetVersionFromString(ASCIIToUTF16(version_info.Version()))); if (running_version.get() == NULL) { NOTREACHED() << "Failed to parse version info"; return; diff --git a/chrome/browser/views/about_chrome_view.cc b/chrome/browser/views/about_chrome_view.cc index ff1b7d1..0863d5c 100644 --- a/chrome/browser/views/about_chrome_view.cc +++ b/chrome/browser/views/about_chrome_view.cc @@ -11,7 +11,6 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/callback.h" -#include "base/file_version_info.h" #include "base/i18n/rtl.h" #include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" @@ -142,23 +141,21 @@ void AboutChromeView::Init() { text_direction_is_rtl_ = base::i18n::IsRTL(); ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - scoped_ptr<FileVersionInfo> version_info(chrome::GetChromeVersionInfo()); - if (version_info.get() == NULL) { + chrome::VersionInfo version_info; + if (!version_info.is_valid()) { NOTREACHED() << L"Failed to initialize about window"; return; } - current_version_ = version_info->file_version(); + current_version_ = ASCIIToWide(version_info.Version()); - string16 version_modifier = platform_util::GetVersionStringModifier(); - if (version_modifier.length()) { - version_details_ += L" "; - version_details_ += UTF16ToWide(version_modifier); - } + std::string version_modifier = platform_util::GetVersionStringModifier(); + if (!version_modifier.empty()) + version_details_ += L" " + ASCIIToWide(version_modifier); #if !defined(GOOGLE_CHROME_BUILD) version_details_ += L" ("; - version_details_ += version_info->last_change(); + version_details_ += ASCIIToWide(version_info.LastChange()); version_details_ += L")"; #endif diff --git a/chrome/common/chrome_version_info.cc b/chrome/common/chrome_version_info.cc index 1b1d479..a26f81f 100644 --- a/chrome/common/chrome_version_info.cc +++ b/chrome/common/chrome_version_info.cc @@ -6,47 +6,82 @@ #include "base/basictypes.h" #include "base/file_version_info.h" +#include "base/string_util.h" #include "build/build_config.h" -#if defined(OS_POSIX) && !defined(OS_MACOSX) -#include "chrome/common/chrome_version_info_posix.h" - -// Posix files don't have per-file version information, so we get chrome -// version information from chrome_version_info_posix.h, a generated header. -class ChromeVersionInfoPosix : public FileVersionInfo { - public: - ChromeVersionInfoPosix() {} - - virtual std::wstring company_name() { return COMPANY_NAME; } - virtual std::wstring company_short_name() { return COMPANY_SHORT_NAME; } - virtual std::wstring product_name() { return PRODUCT_NAME; } - virtual std::wstring product_short_name() { return PRODUCT_SHORT_NAME; } - virtual std::wstring internal_name() { return INTERNAL_NAME; } - virtual std::wstring product_version() { return PRODUCT_VERSION; } - virtual std::wstring private_build() { return PRIVATE_BUILD; } - virtual std::wstring special_build() { return SPECIAL_BUILD; } - virtual std::wstring comments() { return COMMENTS; } - virtual std::wstring original_filename() { return ORIGINAL_FILENAME; } - virtual std::wstring file_description() { return FILE_DESCRIPTION; } - virtual std::wstring file_version() { return FILE_VERSION; } - virtual std::wstring legal_copyright() { return LEGAL_COPYRIGHT; } - virtual std::wstring legal_trademarks() { return LEGAL_TRADEMARKS; } - virtual std::wstring last_change() { return LAST_CHANGE; } - virtual bool is_official_build() { return OFFICIAL_BUILD; } - - private: - DISALLOW_COPY_AND_ASSIGN(ChromeVersionInfoPosix); -}; -#endif - namespace chrome { -FileVersionInfo* GetChromeVersionInfo() { #if defined(OS_WIN) || defined(OS_MACOSX) - return FileVersionInfo::CreateFileVersionInfoForCurrentModule(); +// On Windows and Mac, we get the Chrome version info by querying +// FileVersionInfo for the current module. + +VersionInfo::VersionInfo() { + version_info_.reset(FileVersionInfo::CreateFileVersionInfoForCurrentModule()); +} + +VersionInfo::~VersionInfo() { +} + +bool VersionInfo::is_valid() const { + return version_info_.get() != NULL; +} + +std::string VersionInfo::Name() const { + if (!is_valid()) + return std::string(); + return WideToASCII(version_info_->product_name()); +} + +std::string VersionInfo::Version() const { + if (!is_valid()) + return std::string(); + return WideToASCII(version_info_->product_version()); +} + +std::string VersionInfo::LastChange() const { + if (!is_valid()) + return std::string(); + return WideToASCII(version_info_->last_change()); +} + +bool VersionInfo::IsOfficialBuild() const { + if (!is_valid()) + return false; + return version_info_->is_official_build(); +} + #elif defined(OS_POSIX) - return new ChromeVersionInfoPosix(); -#endif +// We get chrome version information from chrome_version_info_posix.h, +// a generated header. + +#include "chrome/common/chrome_version_info_posix.h" + +VersionInfo::VersionInfo() { +} + +VersionInfo::~VersionInfo() { +} + +bool VersionInfo::is_valid() const { + return true; +} + +std::string VersionInfo::Name() const { + return PRODUCT_NAME; +} + +std::string VersionInfo::Version() const { + return PRODUCT_VERSION; +} + +std::string VersionInfo::LastChange() const { + return LAST_CHANGE; } +bool VersionInfo::IsOfficialBuild() const { + return OFFICIAL_BUILD; +} + +#endif + } // namespace chrome diff --git a/chrome/common/chrome_version_info.h b/chrome/common/chrome_version_info.h index a539130..0ec911e 100644 --- a/chrome/common/chrome_version_info.h +++ b/chrome/common/chrome_version_info.h @@ -6,13 +6,49 @@ #define CHROME_COMMON_CHROME_VERSION_INFO_H_ #pragma once +#include <string> + +#include "base/basictypes.h" +#include "base/scoped_ptr.h" + class FileVersionInfo; namespace chrome { -// Creates a FileVersionInfo for the app, Chrome. Returns NULL in case of -// error. The returned object should be deleted when you are done with it. -FileVersionInfo* GetChromeVersionInfo(); +// An instance of chrome::VersionInfo has information about the +// current running build of Chrome. +class VersionInfo { + public: + VersionInfo(); + ~VersionInfo(); + + // In the rare case where we fail to get the version info, + // is_valid() will return false. The other functions will return + // the empty string in this case, so it's not harmful if you don't + // check is_valid(). + bool is_valid() const; + + // E.g. "Chromium" or "Google Chrome". + std::string Name() const; + + // Version number, e.g. "6.0.490.1". + std::string Version() const; + + // The SVN revision of this release. E.g. "55800". + std::string LastChange() const; + + // Whether this is an "official" release of the current Version(): + // whether knowing Version() is enough to completely determine what + // LastChange() is. + bool IsOfficialBuild() const; + + private: +#if defined(OS_WIN) || defined(OS_MACOSX) + scoped_ptr<FileVersionInfo> version_info_; +#endif + + DISALLOW_COPY_AND_ASSIGN(VersionInfo); +}; } // namespace chrome diff --git a/chrome/common/chrome_version_info_posix.h.version b/chrome/common/chrome_version_info_posix.h.version index 56a8fea..670dc8c 100644 --- a/chrome/common/chrome_version_info_posix.h.version +++ b/chrome/common/chrome_version_info_posix.h.version @@ -5,22 +5,9 @@ #ifndef CHROME_COMMON_CHROME_VERSION_INFO_POSIX_H_ #define CHROME_COMMON_CHROME_VERSION_INFO_POSIX_H_ -#define COMPANY_NAME L"@COMPANY_FULLNAME@" -#define FILE_DESCRIPTION L"@PRODUCT_FULLNAME@" -#define FILE_VERSION L"@MAJOR@.@MINOR@.@BUILD@.@PATCH@" -#define LEGAL_COPYRIGHT L"@COPYRIGHT@" -#define PRODUCT_NAME L"@PRODUCT_FULLNAME@" -#define PRODUCT_VERSION L"@MAJOR@.@MINOR@.@BUILD@.@PATCH@" -#define COMPANY_SHORT_NAME L"@COMPANY_SHORTNAME@" -#define PRODUCT_SHORT_NAME L"@PRODUCT_SHORTNAME@" -#define LAST_CHANGE L"@LASTCHANGE@" +#define PRODUCT_NAME "@PRODUCT_FULLNAME@" +#define PRODUCT_VERSION "@MAJOR@.@MINOR@.@BUILD@.@PATCH@" +#define LAST_CHANGE "@LASTCHANGE@" #define OFFICIAL_BUILD @OFFICIAL_BUILD@ -// TODO(mmoss) Do these have values for Linux? -#define INTERNAL_NAME L"" -#define ORIGINAL_FILENAME L"" -#define PRIVATE_BUILD L"" -#define SPECIAL_BUILD L"" -#define COMMENTS L"" -#define LEGAL_TRADEMARKS L"" #endif // CHROME_COMMON_CHROME_VERSION_INFO_POSIX_H_ diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index 4dfe74c..728006c 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -12,7 +12,6 @@ #include "base/command_line.h" #include "base/file_path.h" #include "base/file_util.h" -#include "base/file_version_info.h" #include "base/i18n/rtl.h" #include "base/logging.h" #include "base/stl_util-inl.h" @@ -1059,15 +1058,14 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key, return false; } - scoped_ptr<FileVersionInfo> current_version_info( - chrome::GetChromeVersionInfo()); - if (!current_version_info.get()) { - DCHECK(false); + chrome::VersionInfo current_version_info; + if (!current_version_info.is_valid()) { + NOTREACHED(); return false; } scoped_ptr<Version> current_version( - Version::GetVersionFromString(current_version_info->file_version())); + Version::GetVersionFromString(current_version_info.Version())); if (!current_version.get()) { DCHECK(false); return false; diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc index 9691d58..9469e8c 100644 --- a/chrome/renderer/renderer_glue.cc +++ b/chrome/renderer/renderer_glue.cc @@ -15,7 +15,6 @@ #include "app/clipboard/clipboard.h" #include "app/resource_bundle.h" #include "base/command_line.h" -#include "base/file_version_info.h" #include "base/ref_counted.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" @@ -301,10 +300,10 @@ void ClearCache() { } std::string GetProductVersion() { - scoped_ptr<FileVersionInfo> version_info(chrome::GetChromeVersionInfo()); + chrome::VersionInfo version_info; std::string product("Chrome/"); - product += version_info.get() ? WideToASCII(version_info->product_version()) - : "0.0.0.0"; + product += version_info.is_valid() ? version_info.Version() + : "0.0.0.0"; return product; } diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index 8e30bbc..b08529b 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -40,7 +40,7 @@ IPC_BEGIN_MESSAGES(Automation) // in the app (the app is not fully up at this point). The parameter to this // message is the version string of the automation provider. This parameter // is defined to be the version string as returned by - // FileVersionInfo::file_version(). + // chrome::VersionInfo::Version(). // The client can choose to use this version string to decide whether or not // it can talk to the provider. IPC_MESSAGE_ROUTED1(AutomationMsg_Hello, std::string) diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc index 31e339b..3f6eb64 100644 --- a/chrome/test/automation/automation_proxy.cc +++ b/chrome/test/automation/automation_proxy.cc @@ -9,7 +9,6 @@ #include <sstream> #include "base/basictypes.h" -#include "base/file_version_info.h" #include "base/logging.h" #include "base/platform_thread.h" #include "base/process_util.h" @@ -174,16 +173,13 @@ AutomationLaunchResult AutomationProxy::WaitForAppLaunch() { if (perform_version_check_) { // Obtain our own version number and compare it to what the automation // provider sent. - scoped_ptr<FileVersionInfo> file_version_info( - chrome::GetChromeVersionInfo()); - DCHECK(file_version_info != NULL); - std::string version_string( - WideToASCII(file_version_info->file_version())); + chrome::VersionInfo version_info; + DCHECK(version_info.is_valid()); // Note that we use a simple string comparison since we expect the version // to be a punctuated numeric string. Consider using base/Version if we // ever need something more complicated here. - if (server_version_ != version_string) { + if (server_version_ != version_info.Version()) { result = AUTOMATION_VERSION_MISMATCH; } } diff --git a/chrome/test/reliability/page_load_test.cc b/chrome/test/reliability/page_load_test.cc index d5344bb..a903032 100644 --- a/chrome/test/reliability/page_load_test.cc +++ b/chrome/test/reliability/page_load_test.cc @@ -158,21 +158,23 @@ class PageLoadTest : public UITest { g_test_log_path = FilePath(FILE_PATH_LITERAL("test_log.log")); test_log.open(g_test_log_path.value().c_str()); + // Get the version of Chrome we're running. + std::string last_change; +#if defined(OS_WIN) // Check file version info for chrome dll. scoped_ptr<FileVersionInfo> file_info; -#if defined(OS_WIN) file_info.reset(FileVersionInfo::CreateFileVersionInfo(kChromeDll)); + last_change = WideToASCII(file_info->last_change()); #elif defined(OS_LINUX) || defined(OS_MACOSX) // TODO(fmeawad): On Mac, the version retrieved here belongs to the test // module and not the chrome binary, need to be changed to chrome binary // instead. - file_info.reset(chrome::GetChromeVersionInfo()); + chrome::VersionInfo version_info; + last_change = version_info.LastChange(); #endif // !defined(OS_WIN) - std::wstring last_change = file_info->last_change(); test_log << "Last Change: "; test_log << last_change << std::endl; - // Log timestamp for test start. base::Time time_now = base::Time::Now(); double time_start = time_now.ToDoubleT(); diff --git a/chrome_frame/metrics_service.cc b/chrome_frame/metrics_service.cc index bac5005..9258112 100644 --- a/chrome_frame/metrics_service.cc +++ b/chrome_frame/metrics_service.cc @@ -462,14 +462,13 @@ bool MetricsService::UploadData() { // static std::string MetricsService::GetVersionString() { - scoped_ptr<FileVersionInfo> version_info( - chrome::GetChromeVersionInfo()); - if (version_info.get()) { - std::string version = WideToUTF8(version_info->product_version()); + chrome::VersionInfo version_info; + if (version_info.is_valid()) { + std::string version = version_info.Version(); // Add the -F extensions to ensure that UMA data uploaded by ChromeFrame // lands in the ChromeFrame bucket. version += "-F"; - if (!version_info->is_official_build()) + if (!version_info.IsOfficialBuild()) version.append("-devel"); return version; } else { |