bool HandleVersionSwitches(const base::CommandLine& command_line) {
#if !BUILDFLAG(IS_MAC)
if (command_line.HasSwitch(switches::kProductVersion)) {
- printf("%s\n", version_info::GetVersionNumber().c_str());
+ printf("%s\n", version_info::GetVersionNumber().data());
return true;
}
#endif
if (command_line.HasSwitch(switches::kVersion)) {
- printf("%s %s %s\n", version_info::GetProductName().c_str(),
- version_info::GetVersionNumber().c_str(),
+ printf("%s %s %s\n", version_info::GetProductName().data(),
+ version_info::GetVersionNumber().data(),
chrome::GetChannelName(chrome::WithExtendedStable(true)).c_str());
return true;
}
std::unique_ptr<webapk::WebApk> webapk = std::make_unique<webapk::WebApk>();
webapk->set_manifest_url(registrar.GetAppManifestUrl(app_id_).spec());
webapk->set_requester_application_package(kRequesterPackageName);
- webapk->set_requester_application_version(version_info::GetVersionNumber());
+ webapk->set_requester_application_version(
+ std::string(version_info::GetVersionNumber()));
LoadWebApkInfo(std::move(webapk));
}
}
webapk->set_requester_application_package(kRequesterPackageName);
- webapk->set_requester_application_version(version_info::GetVersionNumber());
+ webapk->set_requester_application_version(
+ std::string(version_info::GetVersionNumber()));
LoadWebApkInfo(std::move(webapk));
}
#include "base/memory/raw_ptr.h"
#include "base/process/process.h"
#include "base/run_loop.h"
+#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
-#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
static std::string DescribeParams(
const testing::TestParamInfo<ParamType>& info) {
- return base::StringPrintf("NewWindow%s",
- info.param ? "Restricted" : "Legacy");
+ return info.param ? "NewWindowRestricted" : "NewWindowLegacy";
}
bool IsNewWindowRestricted() { return GetParam(); }
void SetUpCommandLine(base::CommandLine* command_line) override {
WebViewTest::SetUpCommandLine(command_line);
command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor,
- base::StringPrintf("%f", scale()));
+ base::NumberToString(scale()));
}
static float scale() { return 2.0f; }
static std::string DescribeParams(
const testing::TestParamInfo<ParamType>& info) {
- bool use_interstitials = info.param;
- return base::StringPrintf("Use%s",
- use_interstitials ? "Interstitial" : "ErrorPage");
+ return info.param ? "UseInterstitial" : "UseErrorPage";
}
bool UseInterstitials() { return GetParam(); }
WebViewChannelTest,
MAYBE_Shim_TestRulesRegistryIDAreRemovedAfterWebViewIsGone) {
ASSERT_EQ(extensions::GetCurrentChannel(), GetChannelParam());
- SCOPED_TRACE(base::StringPrintf(
- "Testing Channel %s",
- version_info::GetChannelString(GetChannelParam()).c_str()));
+ SCOPED_TRACE(base::StrCat(
+ {"Testing Channel ", version_info::GetChannelString(GetChannelParam())}));
LoadAppWithGuest("web_view/rules_registry");
IN_PROC_BROWSER_TEST_P(WebViewChannelTest,
Shim_WebViewWebRequestRegistryHasNoPersistentCache) {
ASSERT_EQ(extensions::GetCurrentChannel(), GetChannelParam());
- SCOPED_TRACE(base::StringPrintf(
- "Testing Channel %s",
- version_info::GetChannelString(GetChannelParam()).c_str()));
+ SCOPED_TRACE(base::StrCat(
+ {"Testing Channel ", version_info::GetChannelString(GetChannelParam())}));
LoadAppWithGuest("web_view/rules_registry");
static std::string DescribeParams(
const testing::TestParamInfo<ParamType>& info) {
- bool is_scroll_disabled = info.param;
- return base::StringPrintf("Scroll%s",
- is_scroll_disabled ? "Disabled" : "Enabled");
+ return info.param ? "ScrollDisabled" : "ScrollEnabled";
}
};
// Check minimum browser version.
if (!min_browser_version.empty() &&
- !ShouldUpdateForHigherVersion(min_browser_version,
- version_info::GetVersionNumber(), true)) {
+ !ShouldUpdateForHigherVersion(
+ min_browser_version, std::string(version_info::GetVersionNumber()),
+ true)) {
external_updates_[app_id].error = l10n_util::GetStringFUTF16(
IDS_KIOSK_EXTERNAL_UPDATE_REQUIRE_HIGHER_BROWSER_VERSION,
base::UTF8ToUTF16(min_browser_version));
metadata.set_locale(ChromeContentBrowserClient().GetApplicationLocale());
metadata.set_device_os_version(base::GetLinuxDistro());
metadata.set_device_os_version_code(SoftwareVersionCodeAsInt64());
- metadata.set_device_os_release(version_info::GetVersionNumber());
- metadata.set_device_os_codename(version_info::GetProductName());
+ metadata.set_device_os_release(std::string(version_info::GetVersionNumber()));
+ metadata.set_device_os_codename(std::string(version_info::GetProductName()));
// device_display_diagonal_mils is unused because it only applies to
// phones/tablets.
int64_t ClientAppMetadataProviderService::SoftwareVersionCodeAsInt64() {
static const int64_t version_code =
- ConvertVersionCodeToInt64(version_info::GetVersionNumber());
+ ConvertVersionCodeToInt64(std::string(version_info::GetVersionNumber()));
return version_code;
}
const {
static const base::NoDestructor<cryptauth::GcmDeviceInfo> gcm_device_info([] {
static const google::protobuf::int64 kSoftwareVersionCode =
- HashStringToInt64(version_info::GetLastChange());
+ HashStringToInt64(std::string(version_info::GetLastChange()));
cryptauth::GcmDeviceInfo gcm_device_info;
CryptAuthDeviceIdProviderImpl::GetInstance()->GetDeviceId());
gcm_device_info.set_device_type(cryptauth::CHROME);
gcm_device_info.set_device_software_version(
- version_info::GetVersionNumber());
+ std::string(version_info::GetVersionNumber()));
gcm_device_info.set_device_software_version_code(kSoftwareVersionCode);
gcm_device_info.set_locale(
ChromeContentBrowserClient().GetApplicationLocale());
record.set_current_os_version(os_version.value_or("0.0.0.0"));
record.set_current_channel(
- version_info::GetChannelString(chrome::GetChannel()));
+ std::string(version_info::GetChannelString(chrome::GetChannel())));
record.set_event_timestamp_sec(base::Time::Now().ToTimeT());
bool DeviceStatusCollector::GetVersionInfo(
em::DeviceStatusReportRequest* status) {
status->set_os_version(os_version_);
- status->set_browser_version(version_info::GetVersionNumber());
+ status->set_browser_version(std::string(version_info::GetVersionNumber()));
status->set_is_lacros_primary_browser(
crosapi::browser_util::IsLacrosPrimaryBrowser());
status->set_channel(ConvertToProtoChannel(chrome::GetChannel()));
builder.SetProfileName("user@gmail.com");
std::unique_ptr<TestingProfile> profile = builder.Build();
// Set profile creation version, otherwise it defaults to 1.0.0.0.
- ChromeVersionService::SetVersion(profile->GetPrefs(),
- version_info::GetVersionNumber());
+ ChromeVersionService::SetVersion(
+ profile->GetPrefs(), std::string(version_info::GetVersionNumber()));
return profile;
}
std::unique_ptr<TestingProfile> CreateChildProfile() {
std::unique_ptr<TestingProfile> profile = CreateRegularProfile();
- ChromeVersionService::SetVersion(profile->GetPrefs(),
- version_info::GetVersionNumber());
+ ChromeVersionService::SetVersion(
+ profile->GetPrefs(), std::string(version_info::GetVersionNumber()));
profile->SetIsSupervisedProfile();
return profile;
}
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <string>
+
#include "base/base64url.h"
#include "base/base_switches.h"
#include "base/command_line.h"
"</script>";
AutofillPageQueryRequest query;
- query.set_client_version(GetProductNameAndVersionForUserAgent());
+ query.set_client_version(std::string(GetProductNameAndVersionForUserAgent()));
auto* query_form = query.add_forms();
query_form->set_signature(15916856893790176210U);
AutofillUploadRequest request;
AutofillUploadContents* upload = request.mutable_upload();
upload->set_submission(true);
- upload->set_client_version(GetProductNameAndVersionForUserAgent());
+ upload->set_client_version(
+ std::string(GetProductNameAndVersionForUserAgent()));
upload->set_form_signature(15916856893790176210U);
upload->set_autofill_used(false);
"</form>";
AutofillPageQueryRequest query;
- query.set_client_version(GetProductNameAndVersionForUserAgent());
+ query.set_client_version(std::string(GetProductNameAndVersionForUserAgent()));
auto* query_form = query.add_forms();
query_form->set_signature(8900697631820480876U);
local_state->GetString(prefs::kShortcutMigrationVersion));
if (!last_version_migrated.IsValid() ||
last_version_migrated < kLastVersionNeedingMigration) {
- shell_integration::win::MigrateTaskbarPins(base::BindOnce(
- &PrefService::SetString, base::Unretained(local_state),
- prefs::kShortcutMigrationVersion, version_info::GetVersionNumber()));
+ shell_integration::win::MigrateTaskbarPins(
+ base::BindOnce(&PrefService::SetString, base::Unretained(local_state),
+ prefs::kShortcutMigrationVersion,
+ std::string(version_info::GetVersionNumber())));
}
}
}
}
std::string ChromeContentBrowserClient::GetProduct() {
- return version_info::GetProductNameAndVersionForUserAgent();
+ return std::string(version_info::GetProductNameAndVersionForUserAgent());
}
std::string ChromeContentBrowserClient::GetUserAgent() {
VersionTest& operator=(const VersionTest&) = delete;
bool ExecuteImpl(DiagnosticsModel::Observer* observer) override {
- std::string current_version = version_info::GetVersionNumber();
+ std::string current_version(version_info::GetVersionNumber());
if (current_version.empty()) {
RecordFailure(DIAG_RECON_EMPTY_VERSION, "Empty Version");
return true;
base::FilePath browser_id;
if (base::PathService::Get(base::DIR_EXE, &browser_id))
browser_proto->set_browser_id(browser_id.AsUTF8Unsafe());
- browser_proto->set_chrome_version(version_info::GetVersionNumber());
+ browser_proto->set_chrome_version(
+ std::string(version_info::GetVersionNumber()));
if (include_device_info)
browser_proto->set_machine_user(policy::GetOSUsername());
}
}
absl::optional<ReportingSettings> settings =
reporting_client->GetReportingSettings();
- const std::string version = version_info::GetVersionNumber();
- const std::string channel =
- version_info::GetChannelString(chrome::GetChannel());
- const std::string platform = version_info::GetOSType();
+ const std::string version(version_info::GetVersionNumber());
+ const std::string channel(
+ version_info::GetChannelString(chrome::GetChannel()));
+ const std::string platform(version_info::GetOSType());
int64_t latest_creation_time = -1;
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
+#include "base/strings/strcat.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/metrics/histogram_tester.h"
CreateScheduler();
g_browser_process->GetBuildState()->SetUpdate(
BuildState::UpdateType::kNormalUpdate,
- base::Version("1" + version_info::GetVersionNumber()), absl::nullopt);
+ base::Version(base::StrCat({"1", version_info::GetVersionNumber()})),
+ absl::nullopt);
task_environment_.RunUntilIdle();
// The timestamp should not have been updated, since a periodic report was not
CreateScheduler();
g_browser_process->GetBuildState()->SetUpdate(
BuildState::UpdateType::kNormalUpdate,
- base::Version("1" + version_info::GetVersionNumber()), absl::nullopt);
+ base::Version(base::StrCat({"1", version_info::GetVersionNumber()})),
+ absl::nullopt);
task_environment_.RunUntilIdle();
// The timestamp should not have been updated, since a periodic report was not
// The report should be stopped in case of persistent error.
g_browser_process->GetBuildState()->SetUpdate(
BuildState::UpdateType::kNormalUpdate,
- base::Version("2" + version_info::GetVersionNumber()), absl::nullopt);
+ base::Version(base::StrCat({"2", version_info::GetVersionNumber()})),
+ absl::nullopt);
histogram_tester_.ExpectUniqueSample(kUploadTriggerMetricName, 2, 1);
}
g_browser_process->GetBuildState()->SetUpdate(
BuildState::UpdateType::kNormalUpdate,
- base::Version("1" + version_info::GetVersionNumber()), absl::nullopt);
+ base::Version(base::StrCat({"1", version_info::GetVersionNumber()})),
+ absl::nullopt);
task_environment_.RunUntilIdle();
::testing::Mock::VerifyAndClearExpectations(generator_);
::testing::Mock::VerifyAndClearExpectations(uploader_);
#include "base/functional/bind.h"
#include "base/run_loop.h"
-#include "base/strings/stringprintf.h"
+#include "base/strings/strcat.h"
#include "base/values.h"
#include "chrome/test/base/testing_profile.h"
#include "components/version_info/channel.h"
};
for (const auto& test_case : test_cases) {
- SCOPED_TRACE(base::StringPrintf(
- "Testing Channel %s",
- version_info::GetChannelString(test_case.channel).c_str()));
+ SCOPED_TRACE(
+ base::StrCat({"Testing Channel ",
+ version_info::GetChannelString(test_case.channel)}));
ScopedCurrentChannel scoped_channel(test_case.channel);
ASSERT_EQ(test_case.expect_api_enabled,
}
std::string GetOAuth2MintTokenFlowVersion() {
- return version_info::GetVersionNumber();
+ return std::string(version_info::GetVersionNumber());
}
std::string GetOAuth2MintTokenFlowChannel() {
- return version_info::GetChannelString(chrome::GetChannel());
+ return std::string(version_info::GetChannelString(chrome::GetChannel()));
}
void RecordFunctionResult(const IdentityGetAuthTokenError& error,
last_version = base::Version(last_version_str);
}
- std::string current_version_str = version_info::GetVersionNumber();
+ std::string current_version_str(version_info::GetVersionNumber());
const base::Version& current_version = version_info::GetVersion();
pref_service->SetString(pref_names::kLastChromeVersion, current_version_str);
// Pre-installed apps are only installed on profile creation or a new
// chrome download.
bool is_new_profile = profile_->WasCreatedByVersionOrLater(
- version_info::GetVersionNumber());
+ std::string(version_info::GetVersionNumber()));
if (is_new_profile && preinstalled_apps_enabled_) {
new_install_state = kAlreadyInstalledPreinstalledApps;
perform_new_installation_ = true;
#include <algorithm>
#include <set>
+#include <string>
#include <utility>
#include <vector>
"USER-AGENT: %s/%s %s\r\n"
"\r\n",
kDialRequestAddress, kDialRequestPort, kDialMaxResponseDelaySecs,
- kDialSearchType, version_info::GetProductName().c_str(),
- version_info::GetVersionNumber().c_str(),
- version_info::GetOSType().c_str()));
+ kDialSearchType, version_info::GetProductName().data(),
+ version_info::GetVersionNumber().data(),
+ version_info::GetOSType().data()));
// 1500 is a good MTU value for most Ethernet LANs.
DCHECK_LE(request.size(), 1500U);
return request;
new cast_channel::CastMessageHandler(
cast_channel::CastSocketService::GetInstance(),
base::BindRepeating(&ParseJsonFromIoThread),
- embedder_support::GetUserAgent(), version_info::GetVersionNumber(),
+ embedder_support::GetUserAgent(),
+ std::string(version_info::GetVersionNumber()),
g_browser_process->GetApplicationLocale());
return instance;
}
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/logging.h"
+#include "base/strings/strcat.h"
#include "base/strings/stringprintf.h"
#include "base/task/sequenced_task_runner.h"
#include "build/build_config.h"
net::AddMultipartValueForUpload("prod", kProduct, kBoundary, std::string(),
upload_data);
- net::AddMultipartValueForUpload("ver",
- version_info::GetVersionNumber() + "-webrtc",
- kBoundary, std::string(), upload_data);
+ net::AddMultipartValueForUpload(
+ "ver", base::StrCat({version_info::GetVersionNumber(), "-webrtc"}),
+ kBoundary, std::string(), upload_data);
net::AddMultipartValueForUpload("guid", "0", kBoundary, std::string(),
upload_data);
net::AddMultipartValueForUpload("type", filename, kBoundary, std::string(),
#endif
net::AddMultipartValueForUpload("prod", product, kWebrtcLogMultipartBoundary,
"", post_data);
- net::AddMultipartValueForUpload("ver",
- version_info::GetVersionNumber() + "-webrtc",
- kWebrtcLogMultipartBoundary, "", post_data);
+ net::AddMultipartValueForUpload(
+ "ver", base::StrCat({version_info::GetVersionNumber(), "-webrtc"}),
+ kWebrtcLogMultipartBoundary, "", post_data);
net::AddMultipartValueForUpload("guid", "0", kWebrtcLogMultipartBoundary, "",
post_data);
net::AddMultipartValueForUpload("type", "webrtc_log",
}
// Chrome version
- LogToCircularBuffer("Chrome version: " + version_info::GetVersionNumber() +
- " " +
- chrome::GetChannelName(chrome::WithExtendedStable(true)));
+ LogToCircularBuffer(
+ base::StrCat({"Chrome version: ", version_info::GetVersionNumber(), " ",
+ chrome::GetChannelName(chrome::WithExtendedStable(true))}));
// OS
LogToCircularBuffer(base::SysInfo::OperatingSystemName() + " " +
auto prompt_parameters =
permissions::PermissionHatsTriggerHelper::PromptParametersForHaTS(
request_type, action, prompt_disposition, prompt_disposition_reason,
- gesture_type, version_info::GetChannelString(chrome::GetChannel()),
+ gesture_type,
+ std::string(version_info::GetChannelString(chrome::GetChannel())),
is_post_prompt ? permissions::kOnPromptResolved
: permissions::kOnPromptAppearing,
prompt_display_duration,
#include <stdint.h>
#include "base/logging.h"
+#include "base/strings/strcat.h"
#include "base/strings/stringprintf.h"
#include "base/system/sys_info.h"
#include "build/build_config.h"
}
std::string DeviceManagementServiceConfiguration::GetAgentParameter() const {
- return base::StringPrintf("%s %s(%s)",
- version_info::GetProductName().c_str(),
- version_info::GetVersionNumber().c_str(),
- version_info::GetLastChange().c_str());
+ return base::StrCat({version_info::GetProductName(), " ",
+ version_info::GetVersionNumber(), "(",
+ version_info::GetLastChange(), ")"});
}
std::string DeviceManagementServiceConfiguration::GetPlatformParameter() const {
g_browser_process->GetApplicationLocale());
AddPair(list, l10n_util::GetStringUTF16(IDS_VERSION_UI_USER_AGENT),
embedder_support::GetUserAgent());
- std::string version = version_info::GetVersionNumber();
+ std::string version(version_info::GetVersionNumber());
version += chrome::GetChannelName(chrome::WithExtendedStable(true));
AddPair(list,
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
// If this is a new profile set version to current version, otherwise
// (pre-existing profile), leave pref at default value (1.0.0.0) to
// avoid any first-run behavior.
- std::string version = version_info::GetVersionNumber();
+ std::string version(version_info::GetVersionNumber());
if (prefs->FindPreference(prefs::kProfileCreatedByVersion)->
IsDefaultValue() && is_new_profile) {
SetVersion(prefs, version);
#include "base/feature_list.h"
#include "base/metrics/field_trial.h"
+#include "base/strings/strcat.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/safe_browsing/advanced_protection_status_manager.h"
#include "chrome/browser/safe_browsing/advanced_protection_status_manager_factory.h"
content::BrowserTaskEnvironment task_environment;
TestingProfile profile;
std::string user_agent =
- version_info::GetProductNameAndVersionForUserAgent() + "/" +
- version_info::GetOSType();
+ base::StrCat({version_info::GetProductNameAndVersionForUserAgent(), "/",
+ version_info::GetOSType()});
ChromeUserPopulation population = GetUserPopulationForProfile(&profile);
EXPECT_EQ(population.user_agent(), user_agent);
}
#include "base/check.h"
#include "base/metrics/field_trial.h"
+#include "base/strings/strcat.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/google/google_brand.h"
// in UIThreadSearchTermsData since SearchTermsData cannot depend on src/chrome
// as it is shared with iOS.
std::string UIThreadSearchTermsData::GoogleImageSearchSource() const {
- std::string version(version_info::GetProductName() + " " +
- version_info::GetVersionNumber());
- if (version_info::IsOfficialBuild())
- version += " (Official)";
- version += " " + version_info::GetOSType();
// Do not distinguish extended from regular stable in image search queries.
- std::string modifier(
- chrome::GetChannelName(chrome::WithExtendedStable(false)));
- if (!modifier.empty())
- version += " " + modifier;
- return version;
+ const std::string channel_name =
+ chrome::GetChannelName(chrome::WithExtendedStable(false));
+ return base::StrCat({version_info::GetProductName(), " ",
+ version_info::GetVersionNumber(),
+ version_info::IsOfficialBuild() ? " (Official) " : " ",
+ version_info::GetOSType(),
+ channel_name.empty() ? "" : " ", channel_name});
}
size_t UIThreadSearchTermsData::EstimateMemoryUsage() const {
}
std::string ChromeShellDelegate::GetVersionString() {
- return version_info::GetVersionNumber();
+ return std::string(version_info::GetVersionNumber());
}
void ChromeShellDelegate::ShouldExitFullscreenBeforeLock(
#include "chrome/browser/ui/autofill/risk_util.h"
#include <memory>
+#include <string>
#include "base/base64.h"
#include "base/functional/bind.h"
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
risk::GetFingerprint(obfuscated_gaia_id, window_bounds, web_contents,
- version_info::GetVersionNumber(), charset,
+ std::string(version_info::GetVersionNumber()), charset,
accept_languages, install_time,
g_browser_process->GetApplicationLocale(),
embedder_support::GetUserAgent(),
[](const ::testing::TestParamInfo<FirstRunFieldTrialTestParams>& params) {
return base::StringPrintf(
"%02.0fpctEntropy%s", params.param.entropy_value * 100,
- version_info::GetChannelString(params.param.channel).c_str());
+ version_info::GetChannelString(params.param.channel).data());
});
// Tests to verify the logic for synthetic trial registration that we use to
}
std::string ChromeViewsDelegate::GetApplicationName() {
- return version_info::GetProductName();
+ return std::string(version_info::GetProductName());
}
IDR_AUTOFILL_AND_PASSWORD_MANAGER_INTERNALS_JS);
source->SetDefaultResource(IDR_AUTOFILL_AND_PASSWORD_MANAGER_INTERNALS_HTML);
// Data strings:
- source->AddString(version_ui::kVersion, version_info::GetVersionNumber());
+ source->AddString(version_ui::kVersion,
+ std::string(version_info::GetVersionNumber()));
source->AddString(version_ui::kOfficial, version_info::IsOfficialBuild()
? "official"
: "Developer build");
source->AddString(version_ui::kVersionModifier,
chrome::GetChannelName(chrome::WithExtendedStable(true)));
- source->AddString(version_ui::kCL, version_info::GetLastChange());
+ source->AddString(version_ui::kCL,
+ std::string(version_info::GetLastChange()));
source->AddString(version_ui::kUserAgent, embedder_support::GetUserAgent());
source->AddString("app_locale", g_browser_process->GetApplicationLocale());
}
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::TrustedTypes,
"trusted-types jstemplate;");
- source->AddString(flags_ui::kVersion, version_info::GetVersionNumber());
+ source->AddString(flags_ui::kVersion,
+ std::string(version_info::GetVersionNumber()));
#if BUILDFLAG(IS_CHROMEOS_ASH)
if (!user_manager::UserManager::Get()->IsCurrentUserOwner() &&
#include "base/memory/weak_ptr.h"
#include "base/metrics/user_metrics.h"
#include "base/path_service.h"
+#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/thread_pool.h"
void NaClDomHandler::AddOperatingSystemInfo(base::Value::List* list) {
// Obtain the Chrome version info.
- AddPair(list, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
- ASCIIToUTF16(
- version_info::GetVersionNumber() + " (" +
- chrome::GetChannelName(chrome::WithExtendedStable(true)) + ")"));
+ AddPair(
+ list, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
+ ASCIIToUTF16(base::StrCat(
+ {version_info::GetVersionNumber(), " (",
+ chrome::GetChannelName(chrome::WithExtendedStable(true)), ")"})));
// OS version information.
// TODO(jvoung): refactor this to share the extra windows labeling
// with about:flash, or something.
- std::string os_label = version_info::GetOSType();
+ std::string os_label(version_info::GetOSType());
#if BUILDFLAG(IS_WIN)
base::win::OSInfo* os = base::win::OSInfo::GetInstance();
switch (os->version()) {
// Data strings.
html_source->AddString(version_ui::kVersion,
- version_info::GetVersionNumber());
+ std::string(version_info::GetVersionNumber()));
html_source->AddString(version_ui::kVersionModifier, GetProductModifier());
base::i18n::MessageFormatter::FormatWithNumberedArgs(
l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_COPYRIGHT),
base::Time::Now()));
- html_source->AddString(version_ui::kCL, version_info::GetLastChange());
+ html_source->AddString(version_ui::kCL,
+ std::string(version_info::GetLastChange()));
html_source->AddString(version_ui::kUserAgent,
embedder_support::GetUserAgent());
// Note that the executable path and profile path are retrieved asynchronously
#if BUILDFLAG(IS_MAC)
html_source->AddString(version_ui::kOSType, base::mac::GetOSDisplayName());
#elif !BUILDFLAG(IS_CHROMEOS_ASH)
- html_source->AddString(version_ui::kOSType, version_info::GetOSType());
+ html_source->AddString(version_ui::kOSType,
+ std::string(version_info::GetOSType()));
#endif // BUILDFLAG(IS_MAC)
#if BUILDFLAG(IS_ANDROID)
: std::string());
html_source->AddString(version_ui::kSanitizer,
- version_info::GetSanitizerList());
+ std::string(version_info::GetSanitizerList()));
}
#if !BUILDFLAG(IS_ANDROID)
#include "chrome/browser/update_client/chrome_update_query_params_delegate.h"
#include "base/lazy_instance.h"
-#include "base/strings/stringprintf.h"
+#include "base/strings/strcat.h"
#include "chrome/browser/browser_process.h"
#include "chrome/common/channel_info.h"
#include "components/version_info/version_info.h"
}
std::string ChromeUpdateQueryParamsDelegate::GetExtraParams() {
- return base::StringPrintf(
- "&prodchannel=%s&prodversion=%s&lang=%s",
- chrome::GetChannelName(chrome::WithExtendedStable(true)).c_str(),
- version_info::GetVersionNumber().c_str(), GetLang());
+ return base::StrCat({"&prodchannel=",
+ chrome::GetChannelName(chrome::WithExtendedStable(true)),
+ "&prodversion=", version_info::GetVersionNumber(),
+ "&lang=", GetLang()});
}
// static
#include <string>
-#include "base/strings/stringprintf.h"
+#include "base/strings/strcat.h"
#include "base/system/sys_info.h"
#include "chrome/browser/update_client/chrome_update_query_params_delegate.h"
#include "chrome/common/channel_info.h"
#include "components/version_info/version_info.h"
#include "testing/gtest/include/gtest/gtest.h"
-using base::StringPrintf;
-
namespace {
bool Contains(const std::string& source, const std::string& target) {
EXPECT_TRUE(Contains(
params,
- StringPrintf("os=%s", update_client::UpdateQueryParams::GetOS())));
+ base::StrCat({"os=", update_client::UpdateQueryParams::GetOS()})));
EXPECT_TRUE(Contains(
params,
- StringPrintf("arch=%s", update_client::UpdateQueryParams::GetArch())));
+ base::StrCat({"arch=", update_client::UpdateQueryParams::GetArch()})));
+ EXPECT_TRUE(Contains(
+ params, base::StrCat({"os_arch=",
+ base::SysInfo().OperatingSystemArchitecture()})));
EXPECT_TRUE(Contains(
params,
- StringPrintf("os_arch=%s",
- base::SysInfo().OperatingSystemArchitecture().c_str())));
+ base::StrCat({"prod=", update_client::UpdateQueryParams::GetProdIdString(
+ prod_id)})));
EXPECT_TRUE(Contains(
- params, StringPrintf(
- "prod=%s",
- update_client::UpdateQueryParams::GetProdIdString(prod_id))));
+ params,
+ base::StrCat({"prodchannel=", chrome::GetChannelName(
+ chrome::WithExtendedStable(true))})));
EXPECT_TRUE(Contains(
params,
- StringPrintf(
- "prodchannel=%s",
- chrome::GetChannelName(chrome::WithExtendedStable(true)).c_str())));
- EXPECT_TRUE(
- Contains(params, StringPrintf("prodversion=%s",
- version_info::GetVersionNumber().c_str())));
+ base::StrCat({"prodversion=", version_info::GetVersionNumber()})));
EXPECT_TRUE(Contains(
params,
- StringPrintf("lang=%s", ChromeUpdateQueryParamsDelegate::GetLang())));
+ base::StrCat({"lang=", ChromeUpdateQueryParamsDelegate::GetLang()})));
}
TEST(ChromeUpdateQueryParamsDelegateTest, GetParams) {
case ChildMode::kWithVersion:
// Print the current version and report success.
- printf("%s\n", version_info::GetVersionNumber().c_str());
+ printf("%s\n", version_info::GetVersionNumber().data());
return 0;
}
return 1;
base::FilePath framework_path;
base::FilePath framework_dylib_path;
EXPECT_TRUE(app_mode::GetChromeBundleInfo(
- chrome_bundle_path, version_info::GetVersionNumber(), &executable_path,
- &framework_path, &framework_dylib_path));
+ chrome_bundle_path, std::string(version_info::GetVersionNumber()),
+ &executable_path, &framework_path, &framework_dylib_path));
EXPECT_TRUE(base::PathExists(executable_path));
EXPECT_TRUE(base::DirectoryExists(framework_path));
EXPECT_TRUE(base::PathExists(framework_dylib_path));
// static
ChromeConnectionConfig ChromeConnectionConfig::GenerateForCurrentProcess() {
return {
- .framework_version = version_info::GetVersionNumber(),
+ .framework_version = std::string(version_info::GetVersionNumber()),
.is_mojo_ipcz_enabled = mojo::core::IsMojoIpczEnabled(),
};
}
}
std::string Configurator::GetOSLongName() const {
- return version_info::GetOSType();
+ return std::string(version_info::GetOSType());
}
base::flat_map<std::string, std::string> Configurator::ExtraRequestParams()
#include "components/autofill/core/browser/form_structure.h"
#include <stdint.h>
-#include <utility>
#include <algorithm>
#include <deque>
#include <map>
#include <memory>
+#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
AutofillUploadContents upload;
upload.set_submission(observed_submission);
upload.set_client_version(
- version_info::GetProductNameAndVersionForUserAgent());
+ std::string(version_info::GetProductNameAndVersionForUserAgent()));
upload.set_form_signature(form_signature().value());
upload.set_autofill_used(form_was_autofilled);
upload.set_data_present(data_present);
base::flat_map<FormGlobalId, FormSignature>(std::move(subforms))) {
uploads.emplace_back();
uploads.back().set_client_version(
- version_info::GetProductNameAndVersionForUserAgent());
+ std::string(version_info::GetProductNameAndVersionForUserAgent()));
uploads.back().set_form_signature(subform_signature.value());
uploads.back().set_autofill_used(form_was_autofilled);
uploads.back().set_data_present(data_present);
queried_form_signatures->reserve(forms.size());
query->set_client_version(
- version_info::GetProductNameAndVersionForUserAgent());
+ std::string(version_info::GetProductNameAndVersionForUserAgent()));
// If a page contains repeated forms, detect that and encode only one form as
// the returned data would be the same for all the repeated forms.
#include <stddef.h>
#include <memory>
+#include <string>
#include "base/base64.h"
#include "base/command_line.h"
// Prepare the expected proto string.
AutofillPageQueryRequest query;
- query.set_client_version(GetProductNameAndVersionForUserAgent());
+ query.set_client_version(std::string(GetProductNameAndVersionForUserAgent()));
{
AutofillPageQueryRequest::Form* query_form = query.add_forms();
query_form->set_signature(form_signature.value());
// Prepare the expected proto string.
AutofillUploadContents upload;
upload.set_submission(true);
- upload.set_client_version(GetProductNameAndVersionForUserAgent());
+ upload.set_client_version(
+ std::string(GetProductNameAndVersionForUserAgent()));
upload.set_form_signature(form_structure->form_signature().value());
upload.set_autofill_used(false);
upload.set_data_present("1442000308");
// Prepare the expected proto string.
AutofillUploadContents upload;
upload.set_submission(true);
- upload.set_client_version(GetProductNameAndVersionForUserAgent());
+ upload.set_client_version(
+ std::string(GetProductNameAndVersionForUserAgent()));
upload.set_form_signature(form_structure->form_signature().value());
upload.set_autofill_used(false);
upload.set_data_present("1442000308");
// Prepare the expected proto string.
AutofillUploadContents upload;
upload.set_submission(true);
- upload.set_client_version(GetProductNameAndVersionForUserAgent());
+ upload.set_client_version(
+ std::string(GetProductNameAndVersionForUserAgent()));
upload.set_form_signature(form_structure->form_signature().value());
upload.set_autofill_used(false);
upload.set_data_present("1442000308");
AutofillUploadContents upload;
upload.set_submission(true);
upload.set_submission_event(AutofillUploadContents::HTML_FORM_SUBMISSION);
- upload.set_client_version(GetProductNameAndVersionForUserAgent());
+ upload.set_client_version(
+ std::string(GetProductNameAndVersionForUserAgent()));
upload.set_form_signature(form_structure->form_signature().value());
upload.set_autofill_used(false);
upload.set_data_present("1442000308");
// Prepare the expected proto string.
AutofillUploadContents upload;
upload.set_submission(true);
- upload.set_client_version(GetProductNameAndVersionForUserAgent());
+ upload.set_client_version(
+ std::string(GetProductNameAndVersionForUserAgent()));
upload.set_form_signature(form_structure->form_signature().value());
upload.set_autofill_used(true);
upload.set_data_present("1440000000000000000802");
// Prepare the expected proto string.
AutofillUploadContents upload;
upload.set_submission(true);
- upload.set_client_version(GetProductNameAndVersionForUserAgent());
+ upload.set_client_version(
+ std::string(GetProductNameAndVersionForUserAgent()));
upload.set_form_signature(form_structure->form_signature().value());
upload.set_autofill_used(true);
upload.set_data_present("1440");
// Prepare the expected proto string.
AutofillUploadContents upload;
upload.set_submission(true);
- upload.set_client_version(GetProductNameAndVersionForUserAgent());
+ upload.set_client_version(
+ std::string(GetProductNameAndVersionForUserAgent()));
upload.set_form_signature(form_structure->form_signature().value());
upload.set_autofill_used(true);
upload.set_data_present("1440");
// Prepare the expected proto string.
AutofillUploadContents upload;
upload.set_submission(false);
- upload.set_client_version(GetProductNameAndVersionForUserAgent());
+ upload.set_client_version(
+ std::string(GetProductNameAndVersionForUserAgent()));
upload.set_form_signature(form_structure->form_signature().value());
upload.set_autofill_used(true);
upload.set_data_present("1440");
// Prepare the expected proto string.
AutofillUploadContents upload;
upload.set_submission(true);
- upload.set_client_version(GetProductNameAndVersionForUserAgent());
+ upload.set_client_version(
+ std::string(GetProductNameAndVersionForUserAgent()));
upload.set_form_signature(form_structure->form_signature().value());
upload.set_autofill_used(true);
upload.set_data_present("1440");
// Prepare the expected proto string.
AutofillUploadContents upload;
upload.set_submission(true);
- upload.set_client_version(GetProductNameAndVersionForUserAgent());
+ upload.set_client_version(
+ std::string(GetProductNameAndVersionForUserAgent()));
upload.set_form_signature(form_structure->form_signature().value());
upload.set_autofill_used(true);
upload.set_data_present("1440");
// Prepare the expected proto string.
AutofillUploadContents upload;
upload.set_submission(true);
- upload.set_client_version(GetProductNameAndVersionForUserAgent());
+ upload.set_client_version(
+ std::string(GetProductNameAndVersionForUserAgent()));
upload.set_form_signature(form_structure->form_signature().value());
upload.set_autofill_used(true);
upload.set_data_present("1440");
// Prepare the expected proto string.
AutofillUploadContents upload;
upload.set_submission(true);
- upload.set_client_version(GetProductNameAndVersionForUserAgent());
+ upload.set_client_version(
+ std::string(GetProductNameAndVersionForUserAgent()));
upload.set_form_signature(form_structure->form_signature().value());
upload.set_autofill_used(true);
upload.set_data_present("1440");
// Prepare the expected proto string.
AutofillUploadContents upload;
upload.set_submission(true);
- upload.set_client_version(GetProductNameAndVersionForUserAgent());
+ upload.set_client_version(
+ std::string(GetProductNameAndVersionForUserAgent()));
upload.set_form_signature(form_structure->form_signature().value());
upload.set_autofill_used(true);
upload.set_data_present("1440");
upload.set_submission(true);
upload.set_submission_event(
AutofillUploadContents_SubmissionIndicatorEvent_NONE);
- upload.set_client_version(GetProductNameAndVersionForUserAgent());
+ upload.set_client_version(
+ std::string(GetProductNameAndVersionForUserAgent()));
upload.set_form_signature(form_structure->form_signature().value());
upload.set_autofill_used(false);
upload.set_data_present("0000000000001850");
const AutofillUploadContents upload_name_exp = [&] {
AutofillUploadContents upload;
- upload.set_client_version(GetProductNameAndVersionForUserAgent());
+ upload.set_client_version(
+ std::string(GetProductNameAndVersionForUserAgent()));
upload.set_form_signature(form.fields[0].host_form_signature.value());
upload.set_autofill_used(false);
upload.set_data_present("0000000000001850");
const AutofillUploadContents upload_number = [&] {
AutofillUploadContents upload;
- upload.set_client_version(GetProductNameAndVersionForUserAgent());
+ upload.set_client_version(
+ std::string(GetProductNameAndVersionForUserAgent()));
upload.set_form_signature(form.fields[1].host_form_signature.value());
upload.set_autofill_used(false);
upload.set_data_present("0000000000001850");
const AutofillUploadContents upload_cvc = [&] {
AutofillUploadContents upload;
- upload.set_client_version(GetProductNameAndVersionForUserAgent());
+ upload.set_client_version(
+ std::string(GetProductNameAndVersionForUserAgent()));
upload.set_form_signature(form.fields[3].host_form_signature.value());
upload.set_autofill_used(false);
upload.set_data_present("0000000000001850");
// Prepare the expected proto string.
AutofillUploadContents upload;
upload.set_submission(true);
- upload.set_client_version(GetProductNameAndVersionForUserAgent());
+ upload.set_client_version(
+ std::string(GetProductNameAndVersionForUserAgent()));
upload.set_form_signature(form_structure.form_signature().value());
upload.set_autofill_used(false);
upload.set_data_present("");
// Prepare the expected proto string.
AutofillUploadContents upload;
upload.set_submission(true);
- upload.set_client_version(GetProductNameAndVersionForUserAgent());
+ upload.set_client_version(
+ std::string(GetProductNameAndVersionForUserAgent()));
upload.set_form_signature(form_structure->form_signature().value());
upload.set_autofill_used(false);
upload.set_data_present("1440000360000008");
// Create the expected query and serialize it to a string.
AutofillPageQueryRequest query;
- query.set_client_version(GetProductNameAndVersionForUserAgent());
+ query.set_client_version(std::string(GetProductNameAndVersionForUserAgent()));
AutofillPageQueryRequest::Form* query_form = query.add_forms();
query_form->set_signature(form_structure.form_signature().value());
// Create the expected query and serialize it to a string.
AutofillPageQueryRequest query;
- query.set_client_version(GetProductNameAndVersionForUserAgent());
+ query.set_client_version(std::string(GetProductNameAndVersionForUserAgent()));
AutofillPageQueryRequest::Form* query_form = query.add_forms();
query_form->set_signature(form_structure.form_signature().value());
// Create the expected query and serialize it to a string.
AutofillPageQueryRequest query;
- query.set_client_version(GetProductNameAndVersionForUserAgent());
+ query.set_client_version(std::string(GetProductNameAndVersionForUserAgent()));
AutofillPageQueryRequest::Form* query_form = query.add_forms();
query_form->set_signature(form_structure.form_signature().value());
// Create the expected query and serialize it to a string.
AutofillPageQueryRequest query;
- query.set_client_version(GetProductNameAndVersionForUserAgent());
+ query.set_client_version(std::string(GetProductNameAndVersionForUserAgent()));
AutofillPageQueryRequest::Form* query_form = query.add_forms();
query_form->set_signature(form_structure.form_signature().value());
void StopTheDedupeProcess() {
personal_data_->pref_service_->SetInteger(
prefs::kAutofillLastVersionDeduped,
- atoi(version_info::GetVersionNumber().c_str()));
+ version_info::GetMajorVersionNumberAsInt());
}
void AddProfileToPersonalDataManager(const AutofillProfile& profile) {
}
std::string ConfiguratorImpl::GetOSLongName() const {
- return version_info::GetOSType();
+ return std::string(version_info::GetOSType());
}
base::flat_map<std::string, std::string> ConfiguratorImpl::ExtraRequestParams()
#include "components/embedder_support/user_agent_utils.h"
+#include <string>
#include <vector>
#include "base/command_line.h"
std::string GetVersionNumber(const UserAgentOptions& options) {
// Force major version to 99.
- if (ShouldForceMajorVersionToMinorPosition(options.force_major_to_minor))
- return GetMajorInMinorVersionNumber();
-
- const std::string& version_str = version_info::GetVersionNumber();
- return version_str;
+ return ShouldForceMajorVersionToMinorPosition(options.force_major_to_minor)
+ ? GetMajorInMinorVersionNumber()
+ : version_info::GetVersionNumber();
}
const blink::UserAgentBrandList GetUserAgentBrandList(
bool enable_updated_grease_by_policy) {
return GetUserAgentBrandList(version_info::GetMajorVersionNumber(),
enable_updated_grease_by_policy,
- version_info::GetVersionNumber(),
+ std::string(version_info::GetVersionNumber()),
blink::UserAgentBrandVersionType::kMajorVersion);
}
bool enable_updated_grease_by_policy) {
return GetUserAgentBrandList(version_info::GetMajorVersionNumber(),
enable_updated_grease_by_policy,
- version_info::GetVersionNumber(),
+ std::string(version_info::GetVersionNumber()),
blink::UserAgentBrandVersionType::kFullVersion);
}
return "Chromium OS";
# endif
#else
- return version_info::GetOSType();
+ return std::string(version_info::GetOSType());
#endif
}
#include "components/embedder_support/user_agent_utils.h"
+#include <string>
#include <vector>
#include "base/command_line.h"
// Make sure all APIs have the correct behavior once user provide invalid
// custom user agent.
const std::string major_version = version_info::GetMajorVersionNumber();
- const std::string full_version = version_info::GetVersionNumber();
+ const std::string full_version(version_info::GetVersionNumber());
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(blink::features::kReduceUserAgent);
auto metadata = GetUserAgentMetadata();
const std::string major_version = version_info::GetMajorVersionNumber();
- const std::string full_version = version_info::GetVersionNumber();
+ const std::string full_version(version_info::GetVersionNumber());
const std::string major_to_minor_full_version = MajorToMinorVersionNumber();
// According to spec, Sec-CH-UA should contain what project the browser is
const blink::UserAgentBrandVersion major_to_minor_chromium_brand_version = {
"Chromium", "99"};
const blink::UserAgentBrandVersion product_brand_version = {
- version_info::GetProductName(), major_version};
+ std::string(version_info::GetProductName()), major_version};
const blink::UserAgentBrandVersion major_to_minor_product_brand_version = {
- version_info::GetProductName(), "99"};
+ std::string(version_info::GetProductName()), "99"};
EXPECT_TRUE(ContainsBrandVersion(metadata.brand_version_list,
chromium_brand_version));
major_to_minor_chromium_brand_full_version = {
"Chromium", major_to_minor_full_version};
const blink::UserAgentBrandVersion product_brand_full_version = {
- version_info::GetProductName(), full_version};
+ std::string(version_info::GetProductName()), full_version};
const blink::UserAgentBrandVersion major_to_minor_product_brand_full_version =
- {version_info::GetProductName(), major_to_minor_full_version};
+ {std::string(version_info::GetProductName()),
+ major_to_minor_full_version};
EXPECT_TRUE(ContainsBrandVersion(metadata.brand_full_version_list,
chromium_brand_full_version));
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
if (contains_version_and_channel) {
- report->set_browser_version(version_info::GetVersionNumber());
+ report->set_browser_version(std::string(version_info::GetVersionNumber()));
report->set_channel(policy::ConvertToProtoChannel(delegate_->GetChannel()));
if (delegate_->IsExtendedStableChannel())
report->set_is_extended_stable_channel(true);
component_data.set_namespace_(std::string(component_namespace));
// TODO(https://crbug.com/1077428): Add release channel to the annotations.
component_data.mutable_annotations()->push_back(
- {"version", version_info::GetVersionNumber()});
+ {"version", std::string(version_info::GetVersionNumber())});
base::ComponentContextForProcess()
->svc()
->Connect<fuchsia::feedback::ComponentDataRegister>()
// These values are managed by the inspector, since they won't be updated over
// the lifetime of the component.
// TODO(https://crbug.com/1077428): Add release channel.
- inspector->root().CreateString(kVersion, version_info::GetVersionNumber(),
- inspector);
- inspector->root().CreateString(kLastChange, version_info::GetLastChange(),
- inspector);
+ inspector->root().CreateString(
+ kVersion, std::string(version_info::GetVersionNumber()), inspector);
+ inspector->root().CreateString(
+ kLastChange, std::string(version_info::GetLastChange()), inspector);
}
} // namespace fuchsia_component_support
}
std::string GetVersion() {
- return version_info::GetVersionNumber();
+ return std::string(version_info::GetVersionNumber());
}
GCMClient::ChromeBuildInfo GetChromeBuildInfo(
namespace metrics {
std::string GetVersionString() {
- std::string version = version_info::GetVersionNumber();
+ std::string version(version_info::GetVersionNumber());
#if defined(ARCH_CPU_64_BITS)
version += "-64";
#endif // defined(ARCH_CPU_64_BITS)
crashpad::HTTPMultipartBuilder builder;
builder.SetFormData("version", version_number);
builder.SetFormData("product", "Chrome_Android");
- std::string channel =
- version_info::GetChannelString(version_info::android::GetChannel());
- builder.SetFormData("channel", channel);
+ builder.SetFormData("channel", version_info::GetChannelString(
+ version_info::android::GetChannel()));
if (!build_id.empty()) {
builder.SetFormData("elf_build_id", build_id);
}
#include <memory>
#include "base/json/json_writer.h"
-#include "base/strings/stringprintf.h"
+#include "base/strings/strcat.h"
#include "base/values.h"
#include "components/policy/core/browser/policy_conversions.h"
#include "components/policy/core/browser/policy_conversions_client.h"
base::Value::Dict chrome_metadata;
chrome_metadata.Set("application", params.application_name);
- std::string version = base::StringPrintf(
- "%s (%s)%s %s%s", version_info::GetVersionNumber().c_str(),
- l10n_util::GetStringUTF8(version_info::IsOfficialBuild()
- ? IDS_VERSION_UI_OFFICIAL
- : IDS_VERSION_UI_UNOFFICIAL)
- .c_str(),
- (params.channel_name.empty() ? "" : " " + params.channel_name).c_str(),
- params.processor_variation.c_str(),
- params.cohort_name ? params.cohort_name->c_str() : "");
+ std::string version = base::StrCat(
+ {version_info::GetVersionNumber(), " (",
+ l10n_util::GetStringUTF8(version_info::IsOfficialBuild()
+ ? IDS_VERSION_UI_OFFICIAL
+ : IDS_VERSION_UI_UNOFFICIAL),
+ ") ", params.channel_name, params.channel_name.empty() ? "" : " ",
+ params.processor_variation, params.cohort_name.value_or(std::string())});
chrome_metadata.Set(kChromeMetadataVersionKey, version);
}
std::string GetOSPlatform() {
- return version_info::GetOSType();
+ return std::string(version_info::GetOSType());
}
std::string GetOSArchitecture() {
// Constructs the URL for Chromium Code Search that points to the line of code
// that generated the log and the Chromium git revision hash.
std::string GetLineURL(const base::Location location) {
- std::string last_change = version_info::GetLastChange();
+ std::string last_change(version_info::GetLastChange());
// The substring separates the last change commit hash from the branch name on
// the '-'.
DCHECK(thread_checker_.CalledOnValidThread());
// URL of icc file on Quirks Server.
- int major_version = atoi(version_info::GetVersionNumber().c_str());
+ int major_version = version_info::GetMajorVersionNumberAsInt();
std::string url = base::StringPrintf(
kQuirksUrlFormat, IdToHexString(product_id_).c_str(), major_version);
bool disable_auto_update) {
return V4ProtocolConfig(client_name, disable_auto_update,
google_apis::GetAPIKey(),
- version_info::GetVersionNumber());
+ std::string(version_info::GetVersionNumber()));
}
void SetSbV4UrlPrefixForTesting(const char* url_prefix) {
#include "components/safe_browsing/core/browser/user_population.h"
#include "base/feature_list.h"
+#include "base/strings/strcat.h"
#include "components/prefs/pref_service.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
GetProfileManagementStatus(browser_policy_connector));
std::string user_agent =
- version_info::GetProductNameAndVersionForUserAgent() + "/" +
- version_info::GetOSType();
+ base::StrCat({version_info::GetProductNameAndVersionForUserAgent(), "/",
+ version_info::GetOSType()});
population.set_user_agent(user_agent);
if (num_profiles)
#include "components/safe_browsing/core/browser/user_population.h"
#include "base/feature_list.h"
+#include "base/strings/strcat.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "components/safe_browsing/buildflags.h"
base::test::TaskEnvironment task_environment;
auto pref_service = CreatePrefService();
std::string user_agent =
- version_info::GetProductNameAndVersionForUserAgent() + "/" +
- version_info::GetOSType();
+ base::StrCat({version_info::GetProductNameAndVersionForUserAgent(), "/",
+ version_info::GetOSType()});
ChromeUserPopulation population =
GetUserPopulation(pref_service.get(), false, false, false, false, nullptr,
absl::optional<size_t>(), absl::optional<size_t>(),
chrome_browser_ssl::CertLoggerFeaturesInfo::ANDROID_AIA_FETCHING_ENABLED);
#endif
- cert_report_->set_chrome_version(version_info::GetVersionNumber());
- cert_report_->set_os_type(version_info::GetOSType());
+ cert_report_->set_chrome_version(
+ std::string(version_info::GetVersionNumber()));
+ cert_report_->set_os_type(std::string(version_info::GetOSType()));
cert_report_->set_os_version(base::SysInfo::OperatingSystemVersion());
cert_report_->set_hardware_model_name(base::SysInfo::HardwareModelName());
cert_report_->set_os_architecture(
#include "base/command_line.h"
#include "base/logging.h"
+#include "base/strings/strcat.h"
#include "base/strings/stringize_macros.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
std::string FormatUserAgentForSync(const std::string& system,
version_info::Channel channel) {
- std::string product = STRINGIZE(SYNC_USER_AGENT_PRODUCT);
- std::string user_agent;
- user_agent = product + " ";
- user_agent += system;
- user_agent += version_info::GetVersionNumber();
- user_agent += " (" + version_info::GetLastChange() + ")";
- if (!version_info::IsOfficialBuild()) {
- user_agent += "-devel";
- } else {
- user_agent += " channel(" + version_info::GetChannelString(channel) + ")";
- }
- return user_agent;
+ constexpr base::StringPiece kProduct = STRINGIZE(SYNC_USER_AGENT_PRODUCT);
+ return base::StrCat(
+ {kProduct, " ", system, version_info::GetVersionNumber(), " (",
+ version_info::GetLastChange(), ")",
+ version_info::IsOfficialBuild()
+ ? base::StrCat(
+ {" channel(", version_info::GetChannelString(channel), ")"})
+ : std::string("-devel")});
}
} // namespace internal
#include "base/i18n/time_formatting.h"
#include "base/notreached.h"
+#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
} else {
version_modifier = " " + version_modifier;
}
- return version_info::GetProductName() + " " + version_info::GetOSType() +
- " " + version_info::GetVersionNumber() + " (" +
- version_info::GetLastChange() + ")" + version_modifier;
+ return base::StrCat({version_info::GetProductName(), " ",
+ version_info::GetOSType(), " ",
+ version_info::GetVersionNumber(), " (",
+ version_info::GetLastChange(), ")", version_modifier});
}
std::string GetTimeStr(base::Time time,
// static
std::string UpdateQueryParams::GetProdVersion() {
- return version_info::GetVersionNumber();
+ return std::string(version_info::GetVersionNumber());
}
// static
const std::string GetProductNameAndVersionForReducedUserAgent(
const std::string& build_version) {
- std::string product_and_version;
- base::StrAppend(&product_and_version, {"Chrome/", GetMajorVersionNumber(),
- ".0.", build_version, ".0"});
- return product_and_version;
+ return base::StrCat(
+ {"Chrome/", GetMajorVersionNumber(), ".0.", build_version, ".0"});
}
int GetMajorVersionNumberAsInt() {
webapk->set_manifest_url(shortcut_info.manifest_url.spec());
webapk->set_requester_application_package(
base::android::BuildInfo::GetInstance()->package_name());
- webapk->set_requester_application_version(version_info::GetVersionNumber());
+ webapk->set_requester_application_version(
+ std::string(version_info::GetVersionNumber()));
webapk->set_android_abi(getCurrentAbi());
webapk->set_package_name(package_name);
webapk->set_version(version);
std::string ShellExtensionsBrowserClient::GetUserAgent() const {
return content::BuildUserAgentFromProduct(
- version_info::GetProductNameAndVersionForUserAgent());
+ std::string(version_info::GetProductNameAndVersionForUserAgent()));
}
void ShellExtensionsBrowserClient::InitWithBrowserContext(
#include "base/command_line.h"
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
+#include "base/strings/strcat.h"
#include "base/strings/string_piece.h"
#include "base/strings/stringprintf.h"
#include "components/version_info/version_info.h"
"Starting %.*s %s", base::saturated_cast<int>(component_name.length()),
component_name.data(), version_info::GetVersionNumber().c_str());
#if !defined(OFFICIAL_BUILD)
- version_string += " (built at " + version_info::GetLastChange() + ")";
+ version_string +=
+ base::StrCat({" (built at ", version_info::GetLastChange(), ")"});
#endif // !defined(OFFICIAL_BUILD)
LOG(INFO) << version_string;
}
std::string WebEngineContentBrowserClient::GetProduct() {
- return version_info::GetProductNameAndVersionForUserAgent();
+ return std::string(version_info::GetProductNameAndVersionForUserAgent());
}
std::string WebEngineContentBrowserClient::GetUserAgent() {
}
std::string ContentBrowserClientImpl::GetProduct() {
- return version_info::GetProductNameAndVersionForUserAgent();
+ return std::string(version_info::GetProductNameAndVersionForUserAgent());
}
std::string ContentBrowserClientImpl::GetUserAgent() {