summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-17 00:28:03 +0000
committersanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-17 00:28:03 +0000
commit680d201ec4f79642cca4073145fdb86e809eb03c (patch)
tree2d90a0f932cffb68277d65152eedd7c6e5f35d4f
parentbf94d1a4cee4be0648778022f27100f8a074e34a (diff)
downloadchromium_src-680d201ec4f79642cca4073145fdb86e809eb03c.zip
chromium_src-680d201ec4f79642cca4073145fdb86e809eb03c.tar.gz
chromium_src-680d201ec4f79642cca4073145fdb86e809eb03c.tar.bz2
Revert 69490 - base/version: remove wstring version
And fix callers. BUG=23581 TEST=trybots Review URL: http://codereview.chromium.org/5848005 TBR=evan@chromium.org Review URL: http://codereview.chromium.org/5905006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69491 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/version.cc7
-rw-r--r--base/version.h4
-rw-r--r--chrome/app/client_util.cc22
-rw-r--r--chrome/browser/enumerate_modules_model_win.cc2
-rw-r--r--chrome/browser/extensions/external_registry_extension_provider_win.cc9
-rw-r--r--chrome/browser/gpu_blacklist.cc3
-rw-r--r--chrome/browser/ui/views/about_chrome_view.cc14
-rw-r--r--chrome/browser/ui/views/about_chrome_view.h4
-rw-r--r--chrome/common/extensions/extension.cc3
-rw-r--r--chrome_frame/dll_redirector.cc3
-rw-r--r--webkit/glue/plugins/plugin_group.cc4
11 files changed, 38 insertions, 37 deletions
diff --git a/base/version.cc b/base/version.cc
index c25b293..fe224eb 100644
--- a/base/version.cc
+++ b/base/version.cc
@@ -11,6 +11,13 @@
#include "base/utf_string_conversions.h"
// static
+Version* Version::GetVersionFromString(const std::wstring& version_str) {
+ if (!IsStringASCII(version_str))
+ return NULL;
+ return GetVersionFromString(WideToUTF8(version_str));
+}
+
+// static
Version* Version::GetVersionFromString(const std::string& version_str) {
Version* vers = new Version();
if (vers->InitFromString(version_str)) {
diff --git a/base/version.h b/base/version.h
index 33f4af5..2b182bb 100644
--- a/base/version.h
+++ b/base/version.h
@@ -12,14 +12,12 @@
#include "base/basictypes.h"
#include "base/gtest_prod_util.h"
-// Version represents a dotted version number, like "1.2.3.4", supporting
-// parsing and comparison.
-// Each component is limited to a uint16.
class Version {
public:
// The version string must be made up of 1 or more uint16's separated
// by '.'. Returns NULL if string is not in this format.
// Caller is responsible for freeing the Version object once done.
+ static Version* GetVersionFromString(const std::wstring& version_str);
static Version* GetVersionFromString(const std::string& version_str);
// Exposed only so that a Version can be stored in STL containers;
diff --git a/chrome/app/client_util.cc b/chrome/app/client_util.cc
index 263ed8b..0c1a8ac 100644
--- a/chrome/app/client_util.cc
+++ b/chrome/app/client_util.cc
@@ -11,7 +11,6 @@
#include "base/file_util.h"
#include "base/logging.h"
#include "base/scoped_ptr.h"
-#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "base/version.h"
#include "chrome/app/breakpad_win.h"
@@ -214,25 +213,26 @@ HMODULE MainDllLoader::Load(std::wstring* out_version, std::wstring* out_file) {
if (dll)
return dll;
- std::wstring version_string;
+ std::wstring version_env_string;
scoped_ptr<Version> version;
const CommandLine& cmd_line = *CommandLine::ForCurrentProcess();
if (cmd_line.HasSwitch(switches::kChromeVersion)) {
- version_string = cmd_line.GetSwitchValueNative(switches::kChromeVersion);
- version.reset(Version::GetVersionFromString(WideToASCII(version_string)));
+ version_env_string = cmd_line.GetSwitchValueNative(
+ switches::kChromeVersion);
+ version.reset(Version::GetVersionFromString(version_env_string));
if (!version.get()) {
// If a bogus command line flag was given, then abort.
LOG(ERROR) << "Invalid version string received on command line: "
- << version_string;
+ << version_env_string;
return NULL;
}
}
if (!version.get()) {
if (EnvQueryStr(ASCIIToWide(chrome::kChromeVersionEnvVar).c_str(),
- &version_string)) {
- version.reset(Version::GetVersionFromString(WideToASCII(version_string)));
+ &version_env_string)) {
+ version.reset(Version::GetVersionFromString(version_env_string));
}
}
@@ -241,13 +241,13 @@ HMODULE MainDllLoader::Load(std::wstring* out_version, std::wstring* out_file) {
// Look into the registry to find the latest version. We don't validate
// this by building a Version object to avoid harming normal case startup
// time.
- version_string.clear();
- GetVersion(dir.c_str(), reg_path.c_str(), &version_string);
+ version_env_string.clear();
+ GetVersion(dir.c_str(), reg_path.c_str(), &version_env_string);
}
- if (version.get() || !version_string.empty()) {
+ if (version.get() || !version_env_string.empty()) {
*out_file = dir;
- *out_version = version_string;
+ *out_version = version_env_string;
out_file->append(*out_version).append(L"\\");
return LoadChromeWithDirectory(out_file);
} else {
diff --git a/chrome/browser/enumerate_modules_model_win.cc b/chrome/browser/enumerate_modules_model_win.cc
index 83dc535..9de5c76 100644
--- a/chrome/browser/enumerate_modules_model_win.cc
+++ b/chrome/browser/enumerate_modules_model_win.cc
@@ -266,7 +266,7 @@ ModuleEnumerator::ModuleStatus ModuleEnumerator::Match(
// We have a name match against the blacklist (and possibly location match
// also), so check version.
scoped_ptr<Version> module_version(
- Version::GetVersionFromString(UTF16ToASCII(module.version)));
+ Version::GetVersionFromString(module.version));
scoped_ptr<Version> version_min(
Version::GetVersionFromString(blacklisted.version_from));
scoped_ptr<Version> version_max(
diff --git a/chrome/browser/extensions/external_registry_extension_provider_win.cc b/chrome/browser/extensions/external_registry_extension_provider_win.cc
index 16b107f..daf3d99 100644
--- a/chrome/browser/extensions/external_registry_extension_provider_win.cc
+++ b/chrome/browser/extensions/external_registry_extension_provider_win.cc
@@ -58,8 +58,7 @@ void ExternalRegistryExtensionProvider::VisitRegisteredExtension(
StringToLowerASCII(&id);
scoped_ptr<Version> version;
- version.reset(Version::GetVersionFromString(
- WideToASCII(extension_version)));
+ version.reset(Version::GetVersionFromString(extension_version));
if (!version.get()) {
LOG(ERROR) << "Invalid version value " << extension_version
<< " for key " << key_path;
@@ -104,10 +103,8 @@ bool ExternalRegistryExtensionProvider::GetExtensionDetails(
if (!key.ReadValue(kRegistryExtensionVersion, &extension_version))
return false;
- if (version) {
- version->reset(Version::GetVersionFromString(
- WideToASCII(extension_version)));
- }
+ if (version)
+ version->reset(Version::GetVersionFromString(extension_version));
if (location)
*location = Extension::EXTERNAL_REGISTRY;
diff --git a/chrome/browser/gpu_blacklist.cc b/chrome/browser/gpu_blacklist.cc
index 85063a8..fe246d6 100644
--- a/chrome/browser/gpu_blacklist.cc
+++ b/chrome/browser/gpu_blacklist.cc
@@ -7,7 +7,6 @@
#include "base/json/json_reader.h"
#include "base/logging.h"
#include "base/string_number_conversions.h"
-#include "base/string_util.h"
#include "base/stringprintf.h"
#include "base/sys_info.h"
#include "base/values.h"
@@ -370,7 +369,7 @@ GpuFeatureFlags GpuBlacklist::DetermineGpuFeatureFlags(
if (gpu_info.progress() == GPUInfo::kUninitialized)
return flags;
scoped_ptr<Version> driver_version(
- Version::GetVersionFromString(WideToASCII(gpu_info.driver_version())));
+ Version::GetVersionFromString(gpu_info.driver_version()));
if (driver_version.get() == NULL)
return flags;
diff --git a/chrome/browser/ui/views/about_chrome_view.cc b/chrome/browser/ui/views/about_chrome_view.cc
index 215c6f0..9e58f04 100644
--- a/chrome/browser/ui/views/about_chrome_view.cc
+++ b/chrome/browser/ui/views/about_chrome_view.cc
@@ -156,16 +156,16 @@ void AboutChromeView::Init() {
return;
}
- current_version_ = version_info.Version();
+ current_version_ = ASCIIToWide(version_info.Version());
std::string version_modifier = platform_util::GetVersionStringModifier();
if (!version_modifier.empty())
- version_details_ += " " + version_modifier;
+ version_details_ += L" " + ASCIIToWide(version_modifier);
#if !defined(GOOGLE_CHROME_BUILD)
- version_details_ += " (";
- version_details_ += version_info.LastChange();
- version_details_ += ")";
+ version_details_ += L" (";
+ version_details_ += ASCIIToWide(version_info.LastChange());
+ version_details_ += L")";
#endif
// Views we will add to the *parent* of this dialog, since it will display
@@ -210,7 +210,7 @@ void AboutChromeView::Init() {
// This is a text field so people can copy the version number from the dialog.
version_label_ = new views::Textfield();
- version_label_->SetText(ASCIIToUTF16(current_version_ + version_details_));
+ version_label_->SetText(WideToUTF16Hack(current_version_ + version_details_));
version_label_->SetReadOnly(true);
version_label_->RemoveBorder();
version_label_->SetTextColor(SK_ColorBLACK);
@@ -763,7 +763,7 @@ void AboutChromeView::UpdateStatus(GoogleUpdateUpgradeResult result,
std::wstring update_label_text =
l10n_util::GetStringF(IDS_UPGRADE_ALREADY_UP_TO_DATE,
l10n_util::GetString(IDS_PRODUCT_NAME),
- ASCIIToUTF16(current_version_));
+ current_version_);
#endif
if (base::i18n::IsRTL()) {
update_label_text.push_back(
diff --git a/chrome/browser/ui/views/about_chrome_view.h b/chrome/browser/ui/views/about_chrome_view.h
index ab287be..a2ed439 100644
--- a/chrome/browser/ui/views/about_chrome_view.h
+++ b/chrome/browser/ui/views/about_chrome_view.h
@@ -146,10 +146,10 @@ class AboutChromeView : public views::View,
#endif
// Our current version.
- std::string current_version_;
+ std::wstring current_version_;
// Additional information about the version (channel and build number).
- std::string version_details_;
+ std::wstring version_details_;
// The version Google Update reports is available to us.
std::wstring new_version_available_;
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index ed957c4..687d3f4 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -1267,7 +1267,8 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key,
*error = errors::kInvalidVersion;
return false;
}
- version_.reset(Version::GetVersionFromString(version_str));
+ version_.reset(
+ Version::GetVersionFromString(version_str));
if (!version_.get() ||
version_->components().size() > 4) {
*error = errors::kInvalidVersion;
diff --git a/chrome_frame/dll_redirector.cc b/chrome_frame/dll_redirector.cc
index 822e474..97143a7 100644
--- a/chrome_frame/dll_redirector.cc
+++ b/chrome_frame/dll_redirector.cc
@@ -14,7 +14,6 @@
#include "base/logging.h"
#include "base/path_service.h"
#include "base/shared_memory.h"
-#include "base/string_util.h"
#include "base/sys_info.h"
#include "base/utf_string_conversions.h"
#include "base/version.h"
@@ -248,7 +247,7 @@ Version* DllRedirector::GetCurrentModuleVersion() {
Version* current_version = NULL;
if (file_version_info.get()) {
current_version = Version::GetVersionFromString(
- WideToASCII(file_version_info->file_version()));
+ file_version_info->file_version());
DCHECK(current_version);
}
diff --git a/webkit/glue/plugins/plugin_group.cc b/webkit/glue/plugins/plugin_group.cc
index af3ff27..548e624 100644
--- a/webkit/glue/plugins/plugin_group.cc
+++ b/webkit/glue/plugins/plugin_group.cc
@@ -183,7 +183,7 @@ bool PluginGroup::Match(const WebPluginInfo& plugin) const {
// There's at least one version range, the plugin's version must be in it.
scoped_ptr<Version> plugin_version(
- Version::GetVersionFromString(UTF16ToASCII(plugin.version)));
+ Version::GetVersionFromString(UTF16ToWide(plugin.version)));
if (plugin_version.get() == NULL) {
// No version could be extracted, assume we don't match the range.
return false;
@@ -209,7 +209,7 @@ Version* PluginGroup::CreateVersionFromString(const string16& version_string) {
std::replace(version.begin(), version.end(), ',', '.');
std::replace(version.begin(), version.end(), '(', '.');
- return Version::GetVersionFromString(WideToASCII(version));
+ return Version::GetVersionFromString(version);
}
void PluginGroup::UpdateActivePlugin(const WebPluginInfo& plugin) {