From b3377cd5c13386864a46a95c0346044a7fc4c65f Mon Sep 17 00:00:00 2001 From: uzair Date: Wed, 28 Jun 2023 11:26:33 +0530 Subject: [PATCH] [PDNCF] Avoid constexpr std::string which is C++20-specific Below change backports [1] and [2] to bringup tizen build [1]https://chromium-review.googlesource.com/c/chromium/src/+/4521911 [2]https://chromium-review.googlesource.com/c/chromium/src/+/4523268 Change-Id: If06210edd2e73c79c745b77b6757b5e51eb3de15 Signed-off-by: uzair --- chrome/app/chrome_main_delegate.cc | 6 +- .../apps/app_service/webapk/webapk_install_task.cc | 6 +- .../apps/guest_view/web_view_browsertest.cc | 25 +++----- .../browser/ash/app_mode/kiosk_external_updater.cc | 5 +- .../client_app_metadata_provider_service.cc | 6 +- .../ash/cryptauth/gcm_device_info_provider_impl.cc | 4 +- .../reporting/os_updates/os_updates_reporter.cc | 2 +- .../status_collector/device_status_collector.cc | 2 +- .../help_app_notification_controller_unittest.cc | 8 +-- .../autofill/autofill_server_browsertest.cc | 9 ++- chrome/browser/chrome_browser_main_win.cc | 7 ++- chrome/browser/chrome_content_browser_client.cc | 2 +- chrome/browser/diagnostics/recon_diagnostics.cc | 2 +- .../enterprise/connectors/connectors_service.cc | 3 +- .../reporting/crash_reporting_context.cc | 8 +-- .../reporting/report_scheduler_unittest.cc | 13 +++-- .../declarative/rules_registry_service_unittest.cc | 8 +-- .../identity/identity_get_auth_token_function.cc | 4 +- .../extensions/chrome_extensions_browser_client.cc | 2 +- chrome/browser/extensions/preinstalled_apps.cc | 2 +- .../router/discovery/dial/dial_service_impl.cc | 7 ++- .../providers/cast/chrome_cast_message_handler.cc | 3 +- .../media/webrtc/webrtc_event_log_uploader.cc | 7 ++- chrome/browser/media/webrtc/webrtc_log_uploader.cc | 6 +- .../media/webrtc/webrtc_text_log_handler.cc | 6 +- .../permissions/chrome_permissions_client.cc | 3 +- .../device_management_service_configuration.cc | 8 +-- .../resettable_settings_snapshot.cc | 2 +- chrome/browser/profiles/chrome_version_service.cc | 2 +- .../chrome_user_population_helper_unittest.cc | 5 +- .../search_engines/ui_thread_search_terms_data.cc | 18 +++--- chrome/browser/ui/ash/chrome_shell_delegate.cc | 2 +- chrome/browser/ui/autofill/risk_util.cc | 3 +- .../ui/startup/first_run_service_unittest.cc | 2 +- chrome/browser/ui/views/chrome_views_delegate.cc | 2 +- .../internals_ui_handler.cc | 6 +- chrome/browser/ui/webui/flags/flags_ui.cc | 3 +- chrome/browser/ui/webui/nacl_ui.cc | 12 ++-- chrome/browser/ui/webui/version/version_ui.cc | 10 ++-- .../chrome_update_query_params_delegate.cc | 10 ++-- ...chrome_update_query_params_delegate_unittest.cc | 30 +++++----- .../get_installed_version_linux_unittest.cc | 2 +- .../mac/app_mode_chrome_locator_browsertest.mm | 4 +- chrome/common/mac/app_mode_common.mm | 2 +- chrome/updater/configurator.cc | 2 +- components/autofill/core/browser/form_structure.cc | 8 +-- .../core/browser/form_structure_unittest.cc | 68 ++++++++++++++-------- .../core/browser/personal_data_manager_unittest.cc | 2 +- components/component_updater/configurator_impl.cc | 2 +- components/embedder_support/user_agent_utils.cc | 15 +++-- .../embedder_support/user_agent_utils_unittest.cc | 14 +++-- .../browser/reporting/browser_report_generator.cc | 2 +- .../feedback_registration.cc | 2 +- components/fuchsia_component_support/inspect.cc | 8 +-- components/gcm_driver/gcm_desktop_utils.cc | 2 +- components/metrics/version_utils.cc | 2 +- .../rewrite_minidumps_as_mimes.cc | 5 +- .../policy/core/browser/webui/json_generation.cc | 18 +++--- .../policy/core/common/cloud/cloud_policy_util.cc | 2 +- components/policy/core/common/policy_logger.cc | 2 +- components/quirks/quirks_client.cc | 2 +- .../core/browser/db/v4_protocol_manager_util.cc | 2 +- .../safe_browsing/core/browser/user_population.cc | 5 +- .../core/browser/user_population_unittest.cc | 5 +- .../content/certificate_error_report.cc | 5 +- components/sync/base/sync_util.cc | 21 +++---- components/sync/driver/sync_internals_util.cc | 8 ++- components/update_client/update_query_params.cc | 2 +- components/version_info/version_info.cc | 6 +- .../browser/android/webapk/webapk_proto_builder.cc | 3 +- .../browser/shell_extensions_browser_client.cc | 2 +- fuchsia_web/common/init_logging.cc | 4 +- .../browser/web_engine_content_browser_client.cc | 2 +- weblayer/browser/content_browser_client_impl.cc | 2 +- 74 files changed, 268 insertions(+), 234 deletions(-) diff --git a/chrome/app/chrome_main_delegate.cc b/chrome/app/chrome_main_delegate.cc index fb50937..6dc223a 100644 --- a/chrome/app/chrome_main_delegate.cc +++ b/chrome/app/chrome_main_delegate.cc @@ -395,14 +395,14 @@ bool HandleCreditsSwitch(const base::CommandLine& command_line) { 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; } diff --git a/chrome/browser/apps/app_service/webapk/webapk_install_task.cc b/chrome/browser/apps/app_service/webapk/webapk_install_task.cc index 8fc0138..b800239 100644 --- a/chrome/browser/apps/app_service/webapk/webapk_install_task.cc +++ b/chrome/browser/apps/app_service/webapk/webapk_install_task.cc @@ -294,7 +294,8 @@ void WebApkInstallTask::Start(ResultCallback callback) { std::unique_ptr webapk = std::make_unique(); 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)); } @@ -563,7 +564,8 @@ void WebApkInstallTask::OnWebApkInfoFetchedFromCrosapi( } 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)); } diff --git a/chrome/browser/apps/guest_view/web_view_browsertest.cc b/chrome/browser/apps/guest_view/web_view_browsertest.cc index 014e41d..0560f4b 100644 --- a/chrome/browser/apps/guest_view/web_view_browsertest.cc +++ b/chrome/browser/apps/guest_view/web_view_browsertest.cc @@ -15,8 +15,8 @@ #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" @@ -912,8 +912,7 @@ class WebViewNewWindowTest : public WebViewTest, static std::string DescribeParams( const testing::TestParamInfo& info) { - return base::StringPrintf("NewWindow%s", - info.param ? "Restricted" : "Legacy"); + return info.param ? "NewWindowRestricted" : "NewWindowLegacy"; } bool IsNewWindowRestricted() { return GetParam(); } @@ -932,7 +931,7 @@ class WebViewDPITest : public WebViewTest { 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; } @@ -2127,9 +2126,7 @@ class WebViewSSLErrorTest : public WebViewTest, static std::string DescribeParams( const testing::TestParamInfo& info) { - bool use_interstitials = info.param; - return base::StringPrintf("Use%s", - use_interstitials ? "Interstitial" : "ErrorPage"); + return info.param ? "UseInterstitial" : "UseErrorPage"; } bool UseInterstitials() { return GetParam(); } @@ -4136,9 +4133,8 @@ IN_PROC_BROWSER_TEST_P( 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"); @@ -4185,9 +4181,8 @@ IN_PROC_BROWSER_TEST_P( 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"); @@ -4817,9 +4812,7 @@ class WebViewGuestScrollTest : public WebViewTest, static std::string DescribeParams( const testing::TestParamInfo& info) { - bool is_scroll_disabled = info.param; - return base::StringPrintf("Scroll%s", - is_scroll_disabled ? "Disabled" : "Enabled"); + return info.param ? "ScrollDisabled" : "ScrollEnabled"; } }; diff --git a/chrome/browser/ash/app_mode/kiosk_external_updater.cc b/chrome/browser/ash/app_mode/kiosk_external_updater.cc index 1f353fb..be7c99a 100644 --- a/chrome/browser/ash/app_mode/kiosk_external_updater.cc +++ b/chrome/browser/ash/app_mode/kiosk_external_updater.cc @@ -350,8 +350,9 @@ bool KioskExternalUpdater::ShouldDoExternalUpdate( // 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)); diff --git a/chrome/browser/ash/cryptauth/client_app_metadata_provider_service.cc b/chrome/browser/ash/cryptauth/client_app_metadata_provider_service.cc index d63b7e1..78efa5d 100644 --- a/chrome/browser/ash/cryptauth/client_app_metadata_provider_service.cc +++ b/chrome/browser/ash/cryptauth/client_app_metadata_provider_service.cc @@ -332,8 +332,8 @@ void ClientAppMetadataProviderService::OnInstanceIdTokenFetched( 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. @@ -423,7 +423,7 @@ instance_id::InstanceID* ClientAppMetadataProviderService::GetInstanceId() { int64_t ClientAppMetadataProviderService::SoftwareVersionCodeAsInt64() { static const int64_t version_code = - ConvertVersionCodeToInt64(version_info::GetVersionNumber()); + ConvertVersionCodeToInt64(std::string(version_info::GetVersionNumber())); return version_code; } diff --git a/chrome/browser/ash/cryptauth/gcm_device_info_provider_impl.cc b/chrome/browser/ash/cryptauth/gcm_device_info_provider_impl.cc index 06b7fd5..abceb69 100644 --- a/chrome/browser/ash/cryptauth/gcm_device_info_provider_impl.cc +++ b/chrome/browser/ash/cryptauth/gcm_device_info_provider_impl.cc @@ -53,7 +53,7 @@ const cryptauth::GcmDeviceInfo& GcmDeviceInfoProviderImpl::GetGcmDeviceInfo() const { static const base::NoDestructor gcm_device_info([] { static const google::protobuf::int64 kSoftwareVersionCode = - HashStringToInt64(version_info::GetLastChange()); + HashStringToInt64(std::string(version_info::GetLastChange())); cryptauth::GcmDeviceInfo gcm_device_info; @@ -61,7 +61,7 @@ const cryptauth::GcmDeviceInfo& GcmDeviceInfoProviderImpl::GetGcmDeviceInfo() 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()); diff --git a/chrome/browser/ash/policy/reporting/os_updates/os_updates_reporter.cc b/chrome/browser/ash/policy/reporting/os_updates/os_updates_reporter.cc index 3c472d4..f0e9ff4 100644 --- a/chrome/browser/ash/policy/reporting/os_updates/os_updates_reporter.cc +++ b/chrome/browser/ash/policy/reporting/os_updates/os_updates_reporter.cc @@ -87,7 +87,7 @@ void OsUpdatesReporter::MaybeReportEvent( 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()); diff --git a/chrome/browser/ash/policy/status_collector/device_status_collector.cc b/chrome/browser/ash/policy/status_collector/device_status_collector.cc index 866cc06..d03a10f 100644 --- a/chrome/browser/ash/policy/status_collector/device_status_collector.cc +++ b/chrome/browser/ash/policy/status_collector/device_status_collector.cc @@ -2261,7 +2261,7 @@ bool DeviceStatusCollector::GetActivityTimes( 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())); diff --git a/chrome/browser/ash/web_applications/help_app/help_app_notification_controller_unittest.cc b/chrome/browser/ash/web_applications/help_app/help_app_notification_controller_unittest.cc index 4e98b10..71b6b7e 100644 --- a/chrome/browser/ash/web_applications/help_app/help_app_notification_controller_unittest.cc +++ b/chrome/browser/ash/web_applications/help_app/help_app_notification_controller_unittest.cc @@ -56,15 +56,15 @@ class HelpAppNotificationControllerTest : public BrowserWithTestWindowTest { builder.SetProfileName("user@gmail.com"); std::unique_ptr 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 CreateChildProfile() { std::unique_ptr profile = CreateRegularProfile(); - ChromeVersionService::SetVersion(profile->GetPrefs(), - version_info::GetVersionNumber()); + ChromeVersionService::SetVersion( + profile->GetPrefs(), std::string(version_info::GetVersionNumber())); profile->SetIsSupervisedProfile(); return profile; } diff --git a/chrome/browser/autofill/autofill_server_browsertest.cc b/chrome/browser/autofill/autofill_server_browsertest.cc index 7aac57a..85fe9ac 100644 --- a/chrome/browser/autofill/autofill_server_browsertest.cc +++ b/chrome/browser/autofill/autofill_server_browsertest.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include + #include "base/base64url.h" #include "base/base_switches.h" #include "base/command_line.h" @@ -225,7 +227,7 @@ IN_PROC_BROWSER_TEST_F(AutofillServerTest, ""; 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); @@ -249,7 +251,8 @@ IN_PROC_BROWSER_TEST_F(AutofillServerTest, 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); @@ -319,7 +322,7 @@ IN_PROC_BROWSER_TEST_F(AutofillServerTest, AlwaysQueryForPasswordFields) { ""; 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); diff --git a/chrome/browser/chrome_browser_main_win.cc b/chrome/browser/chrome_browser_main_win.cc index 0d96e40..b249926 100644 --- a/chrome/browser/chrome_browser_main_win.cc +++ b/chrome/browser/chrome_browser_main_win.cc @@ -391,9 +391,10 @@ void MigratePinnedTaskBarShortcutsIfNeeded() { 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()))); } } } diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 1979ba1..f84dc86 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -6881,7 +6881,7 @@ void ChromeContentBrowserClient::LogWebFeatureForCurrentPage( } std::string ChromeContentBrowserClient::GetProduct() { - return version_info::GetProductNameAndVersionForUserAgent(); + return std::string(version_info::GetProductNameAndVersionForUserAgent()); } std::string ChromeContentBrowserClient::GetUserAgent() { diff --git a/chrome/browser/diagnostics/recon_diagnostics.cc b/chrome/browser/diagnostics/recon_diagnostics.cc index 4a550b5..9645b12d 100644 --- a/chrome/browser/diagnostics/recon_diagnostics.cc +++ b/chrome/browser/diagnostics/recon_diagnostics.cc @@ -297,7 +297,7 @@ class VersionTest : public DiagnosticsTest { 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; diff --git a/chrome/browser/enterprise/connectors/connectors_service.cc b/chrome/browser/enterprise/connectors/connectors_service.cc index 500879b..8dcb5bf 100644 --- a/chrome/browser/enterprise/connectors/connectors_service.cc +++ b/chrome/browser/enterprise/connectors/connectors_service.cc @@ -75,7 +75,8 @@ void PopulateBrowserMetadata(bool include_device_info, 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()); } diff --git a/chrome/browser/enterprise/connectors/reporting/crash_reporting_context.cc b/chrome/browser/enterprise/connectors/reporting/crash_reporting_context.cc index 683956d..64a65354 100644 --- a/chrome/browser/enterprise/connectors/reporting/crash_reporting_context.cc +++ b/chrome/browser/enterprise/connectors/reporting/crash_reporting_context.cc @@ -155,10 +155,10 @@ void UploadToReportingServer( } absl::optional 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; diff --git a/chrome/browser/enterprise/reporting/report_scheduler_unittest.cc b/chrome/browser/enterprise/reporting/report_scheduler_unittest.cc index 2bc74d3..acf7492 100644 --- a/chrome/browser/enterprise/reporting/report_scheduler_unittest.cc +++ b/chrome/browser/enterprise/reporting/report_scheduler_unittest.cc @@ -8,6 +8,7 @@ #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" @@ -728,7 +729,8 @@ TEST_F(ReportSchedulerTest, OnUpdate) { 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 @@ -752,7 +754,8 @@ TEST_F(ReportSchedulerTest, OnUpdateAndPersistentError) { 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 @@ -764,7 +767,8 @@ TEST_F(ReportSchedulerTest, OnUpdateAndPersistentError) { // 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); } @@ -790,7 +794,8 @@ TEST_F(ReportSchedulerTest, DeferredTimer) { 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_); diff --git a/chrome/browser/extensions/api/declarative/rules_registry_service_unittest.cc b/chrome/browser/extensions/api/declarative/rules_registry_service_unittest.cc index 3e4ca589..7d8446a 100644 --- a/chrome/browser/extensions/api/declarative/rules_registry_service_unittest.cc +++ b/chrome/browser/extensions/api/declarative/rules_registry_service_unittest.cc @@ -11,7 +11,7 @@ #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" @@ -143,9 +143,9 @@ TEST_F(RulesRegistryServiceTest, DefaultRulesRegistryRegistered) { }; 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, diff --git a/chrome/browser/extensions/api/identity/identity_get_auth_token_function.cc b/chrome/browser/extensions/api/identity/identity_get_auth_token_function.cc index bacad4d..c1daa5d 100644 --- a/chrome/browser/extensions/api/identity/identity_get_auth_token_function.cc +++ b/chrome/browser/extensions/api/identity/identity_get_auth_token_function.cc @@ -60,11 +60,11 @@ bool IsBrowserSigninAllowed(Profile* profile) { } 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, diff --git a/chrome/browser/extensions/chrome_extensions_browser_client.cc b/chrome/browser/extensions/chrome_extensions_browser_client.cc index 387ae00..dd9c995 100644 --- a/chrome/browser/extensions/chrome_extensions_browser_client.cc +++ b/chrome/browser/extensions/chrome_extensions_browser_client.cc @@ -382,7 +382,7 @@ bool ChromeExtensionsBrowserClient::DidVersionUpdate( 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); diff --git a/chrome/browser/extensions/preinstalled_apps.cc b/chrome/browser/extensions/preinstalled_apps.cc index a07c733..6dd8739 100644 --- a/chrome/browser/extensions/preinstalled_apps.cc +++ b/chrome/browser/extensions/preinstalled_apps.cc @@ -89,7 +89,7 @@ void Provider::InitProfileState() { // 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; diff --git a/chrome/browser/media/router/discovery/dial/dial_service_impl.cc b/chrome/browser/media/router/discovery/dial/dial_service_impl.cc index a66e96b..b5da7be 100644 --- a/chrome/browser/media/router/discovery/dial/dial_service_impl.cc +++ b/chrome/browser/media/router/discovery/dial/dial_service_impl.cc @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -125,9 +126,9 @@ std::string BuildRequest() { "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; diff --git a/chrome/browser/media/router/providers/cast/chrome_cast_message_handler.cc b/chrome/browser/media/router/providers/cast/chrome_cast_message_handler.cc index b24dbb7..3d53090 100644 --- a/chrome/browser/media/router/providers/cast/chrome_cast_message_handler.cc +++ b/chrome/browser/media/router/providers/cast/chrome_cast_message_handler.cc @@ -36,7 +36,8 @@ cast_channel::CastMessageHandler* GetCastMessageHandler() { 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; } diff --git a/chrome/browser/media/webrtc/webrtc_event_log_uploader.cc b/chrome/browser/media/webrtc/webrtc_event_log_uploader.cc index 6cd0ba0..1c20dcc 100644 --- a/chrome/browser/media/webrtc/webrtc_event_log_uploader.cc +++ b/chrome/browser/media/webrtc/webrtc_event_log_uploader.cc @@ -7,6 +7,7 @@ #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" @@ -265,9 +266,9 @@ bool WebRtcEventLogUploaderImpl::PrepareUploadData(std::string* upload_data) { 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(), diff --git a/chrome/browser/media/webrtc/webrtc_log_uploader.cc b/chrome/browser/media/webrtc/webrtc_log_uploader.cc index fb8757a..9a90da3 100644 --- a/chrome/browser/media/webrtc/webrtc_log_uploader.cc +++ b/chrome/browser/media/webrtc/webrtc_log_uploader.cc @@ -377,9 +377,9 @@ void WebRtcLogUploader::SetupMultipart( #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", diff --git a/chrome/browser/media/webrtc/webrtc_text_log_handler.cc b/chrome/browser/media/webrtc/webrtc_text_log_handler.cc index 6518ff3..b058c94 100644 --- a/chrome/browser/media/webrtc/webrtc_text_log_handler.cc +++ b/chrome/browser/media/webrtc/webrtc_text_log_handler.cc @@ -460,9 +460,9 @@ void WebRtcTextLogHandler::OnGetNetworkInterfaceListFinish( } // 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() + " " + diff --git a/chrome/browser/permissions/chrome_permissions_client.cc b/chrome/browser/permissions/chrome_permissions_client.cc index 4933021..5760cd2 100644 --- a/chrome/browser/permissions/chrome_permissions_client.cc +++ b/chrome/browser/permissions/chrome_permissions_client.cc @@ -269,7 +269,8 @@ void ChromePermissionsClient::TriggerPromptHatsSurveyIfEnabled( 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, diff --git a/chrome/browser/policy/device_management_service_configuration.cc b/chrome/browser/policy/device_management_service_configuration.cc index 0804711..c231ed87 100644 --- a/chrome/browser/policy/device_management_service_configuration.cc +++ b/chrome/browser/policy/device_management_service_configuration.cc @@ -7,6 +7,7 @@ #include #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" @@ -44,10 +45,9 @@ std::string DeviceManagementServiceConfiguration::GetDMServerUrl() const { } 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 { diff --git a/chrome/browser/profile_resetter/resettable_settings_snapshot.cc b/chrome/browser/profile_resetter/resettable_settings_snapshot.cc index 0a22530..1a1974e 100644 --- a/chrome/browser/profile_resetter/resettable_settings_snapshot.cc +++ b/chrome/browser/profile_resetter/resettable_settings_snapshot.cc @@ -244,7 +244,7 @@ base::Value::List GetReadableFeedbackForSnapshot( 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), diff --git a/chrome/browser/profiles/chrome_version_service.cc b/chrome/browser/profiles/chrome_version_service.cc index bf99f549..8cd5806 100644 --- a/chrome/browser/profiles/chrome_version_service.cc +++ b/chrome/browser/profiles/chrome_version_service.cc @@ -33,7 +33,7 @@ void ChromeVersionService::OnProfileLoaded(PrefService* prefs, // 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); diff --git a/chrome/browser/safe_browsing/chrome_user_population_helper_unittest.cc b/chrome/browser/safe_browsing/chrome_user_population_helper_unittest.cc index abd2137..54738a6 100644 --- a/chrome/browser/safe_browsing/chrome_user_population_helper_unittest.cc +++ b/chrome/browser/safe_browsing/chrome_user_population_helper_unittest.cc @@ -6,6 +6,7 @@ #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" @@ -186,8 +187,8 @@ TEST(GetUserPopulationForProfileTest, PopulatesUserAgent) { 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); } diff --git a/chrome/browser/search_engines/ui_thread_search_terms_data.cc b/chrome/browser/search_engines/ui_thread_search_terms_data.cc index 1344991..70b2571 100644 --- a/chrome/browser/search_engines/ui_thread_search_terms_data.cc +++ b/chrome/browser/search_engines/ui_thread_search_terms_data.cc @@ -6,6 +6,7 @@ #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" @@ -122,17 +123,14 @@ std::string UIThreadSearchTermsData::GetSuggestRequestIdentifier( // 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 { diff --git a/chrome/browser/ui/ash/chrome_shell_delegate.cc b/chrome/browser/ui/ash/chrome_shell_delegate.cc index 2df6bf8..5f5bc4e 100644 --- a/chrome/browser/ui/ash/chrome_shell_delegate.cc +++ b/chrome/browser/ui/ash/chrome_shell_delegate.cc @@ -413,7 +413,7 @@ void ChromeShellDelegate::ForceSkipWarningUserOnClose( } std::string ChromeShellDelegate::GetVersionString() { - return version_info::GetVersionNumber(); + return std::string(version_info::GetVersionNumber()); } void ChromeShellDelegate::ShouldExitFullscreenBeforeLock( diff --git a/chrome/browser/ui/autofill/risk_util.cc b/chrome/browser/ui/autofill/risk_util.cc index a772a22..fdbc2fa 100644 --- a/chrome/browser/ui/autofill/risk_util.cc +++ b/chrome/browser/ui/autofill/risk_util.cc @@ -5,6 +5,7 @@ #include "chrome/browser/ui/autofill/risk_util.h" #include +#include #include "base/base64.h" #include "base/functional/bind.h" @@ -101,7 +102,7 @@ void LoadRiskDataHelper(uint64_t obfuscated_gaia_id, 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(), diff --git a/chrome/browser/ui/startup/first_run_service_unittest.cc b/chrome/browser/ui/startup/first_run_service_unittest.cc index 519ec16..e6b0a58 100644 --- a/chrome/browser/ui/startup/first_run_service_unittest.cc +++ b/chrome/browser/ui/startup/first_run_service_unittest.cc @@ -224,7 +224,7 @@ INSTANTIATE_TEST_SUITE_P( [](const ::testing::TestParamInfo& 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 diff --git a/chrome/browser/ui/views/chrome_views_delegate.cc b/chrome/browser/ui/views/chrome_views_delegate.cc index 5870c87..4327473 100644 --- a/chrome/browser/ui/views/chrome_views_delegate.cc +++ b/chrome/browser/ui/views/chrome_views_delegate.cc @@ -210,5 +210,5 @@ void ChromeViewsDelegate::OnBeforeWidgetInit( } std::string ChromeViewsDelegate::GetApplicationName() { - return version_info::GetProductName(); + return std::string(version_info::GetProductName()); } diff --git a/chrome/browser/ui/webui/autofill_and_password_manager_internals/internals_ui_handler.cc b/chrome/browser/ui/webui/autofill_and_password_manager_internals/internals_ui_handler.cc index 8eba939..bf676bc 100644 --- a/chrome/browser/ui/webui/autofill_and_password_manager_internals/internals_ui_handler.cc +++ b/chrome/browser/ui/webui/autofill_and_password_manager_internals/internals_ui_handler.cc @@ -37,13 +37,15 @@ void CreateAndAddInternalsHTMLSource(Profile* profile, 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()); } diff --git a/chrome/browser/ui/webui/flags/flags_ui.cc b/chrome/browser/ui/webui/flags/flags_ui.cc index a273e23..bc0318f 100644 --- a/chrome/browser/ui/webui/flags/flags_ui.cc +++ b/chrome/browser/ui/webui/flags/flags_ui.cc @@ -70,7 +70,8 @@ content::WebUIDataSource* CreateAndAddFlagsUIHTMLSource(Profile* profile) { 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() && diff --git a/chrome/browser/ui/webui/nacl_ui.cc b/chrome/browser/ui/webui/nacl_ui.cc index ea8b7ca..8ead8db 100644 --- a/chrome/browser/ui/webui/nacl_ui.cc +++ b/chrome/browser/ui/webui/nacl_ui.cc @@ -19,6 +19,7 @@ #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" @@ -187,15 +188,16 @@ bool NaClDomHandler::isPluginEnabled(size_t plugin_index) { 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()) { diff --git a/chrome/browser/ui/webui/version/version_ui.cc b/chrome/browser/ui/webui/version/version_ui.cc index 7ca8498..d61e235 100644 --- a/chrome/browser/ui/webui/version/version_ui.cc +++ b/chrome/browser/ui/webui/version/version_ui.cc @@ -223,7 +223,7 @@ void VersionUI::AddVersionDetailStrings(content::WebUIDataSource* html_source) { // Data strings. html_source->AddString(version_ui::kVersion, - version_info::GetVersionNumber()); + std::string(version_info::GetVersionNumber())); html_source->AddString(version_ui::kVersionModifier, GetProductModifier()); @@ -239,7 +239,8 @@ void VersionUI::AddVersionDetailStrings(content::WebUIDataSource* html_source) { 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 @@ -251,7 +252,8 @@ void VersionUI::AddVersionDetailStrings(content::WebUIDataSource* html_source) { #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) @@ -307,7 +309,7 @@ void VersionUI::AddVersionDetailStrings(content::WebUIDataSource* html_source) { : std::string()); html_source->AddString(version_ui::kSanitizer, - version_info::GetSanitizerList()); + std::string(version_info::GetSanitizerList())); } #if !BUILDFLAG(IS_ANDROID) diff --git a/chrome/browser/update_client/chrome_update_query_params_delegate.cc b/chrome/browser/update_client/chrome_update_query_params_delegate.cc index 4f48863..3947ede 100644 --- a/chrome/browser/update_client/chrome_update_query_params_delegate.cc +++ b/chrome/browser/update_client/chrome_update_query_params_delegate.cc @@ -5,7 +5,7 @@ #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" @@ -30,10 +30,10 @@ ChromeUpdateQueryParamsDelegate::GetInstance() { } 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 diff --git a/chrome/browser/update_client/chrome_update_query_params_delegate_unittest.cc b/chrome/browser/update_client/chrome_update_query_params_delegate_unittest.cc index 83faf8e..e550096 100644 --- a/chrome/browser/update_client/chrome_update_query_params_delegate_unittest.cc +++ b/chrome/browser/update_client/chrome_update_query_params_delegate_unittest.cc @@ -4,7 +4,7 @@ #include -#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" @@ -12,8 +12,6 @@ #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) { @@ -27,29 +25,27 @@ void TestParams(update_client::UpdateQueryParams::ProdId prod_id) { 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) { diff --git a/chrome/browser/upgrade_detector/get_installed_version_linux_unittest.cc b/chrome/browser/upgrade_detector/get_installed_version_linux_unittest.cc index 2e923bd..1297beb 100644 --- a/chrome/browser/upgrade_detector/get_installed_version_linux_unittest.cc +++ b/chrome/browser/upgrade_detector/get_installed_version_linux_unittest.cc @@ -61,7 +61,7 @@ MULTIPROCESS_TEST_MAIN(GetProductVersionInChildProc) { 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; diff --git a/chrome/common/mac/app_mode_chrome_locator_browsertest.mm b/chrome/common/mac/app_mode_chrome_locator_browsertest.mm index b7a08aa..ddc843b 100644 --- a/chrome/common/mac/app_mode_chrome_locator_browsertest.mm +++ b/chrome/common/mac/app_mode_chrome_locator_browsertest.mm @@ -68,8 +68,8 @@ TEST(ChromeLocatorTest, GetChromeBundleInfoWithLatestVersion) { 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)); diff --git a/chrome/common/mac/app_mode_common.mm b/chrome/common/mac/app_mode_common.mm index 022bd28..26a52b7 100644 --- a/chrome/common/mac/app_mode_common.mm +++ b/chrome/common/mac/app_mode_common.mm @@ -87,7 +87,7 @@ static_assert( // static ChromeConnectionConfig ChromeConnectionConfig::GenerateForCurrentProcess() { return { - .framework_version = version_info::GetVersionNumber(), + .framework_version = std::string(version_info::GetVersionNumber()), .is_mojo_ipcz_enabled = mojo::core::IsMojoIpczEnabled(), }; } diff --git a/chrome/updater/configurator.cc b/chrome/updater/configurator.cc index 69f1510..4b0c45f 100644 --- a/chrome/updater/configurator.cc +++ b/chrome/updater/configurator.cc @@ -129,7 +129,7 @@ std::string Configurator::GetLang() const { } std::string Configurator::GetOSLongName() const { - return version_info::GetOSType(); + return std::string(version_info::GetOSType()); } base::flat_map Configurator::ExtraRequestParams() diff --git a/components/autofill/core/browser/form_structure.cc b/components/autofill/core/browser/form_structure.cc index 6a7f5e9..407bff1 100644 --- a/components/autofill/core/browser/form_structure.cc +++ b/components/autofill/core/browser/form_structure.cc @@ -5,12 +5,12 @@ #include "components/autofill/core/browser/form_structure.h" #include -#include #include #include #include #include +#include #include #include #include @@ -414,7 +414,7 @@ std::vector FormStructure::EncodeUploadRequest( 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); @@ -500,7 +500,7 @@ std::vector FormStructure::EncodeUploadRequest( base::flat_map(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); @@ -521,7 +521,7 @@ bool FormStructure::EncodeQueryRequest( 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. diff --git a/components/autofill/core/browser/form_structure_unittest.cc b/components/autofill/core/browser/form_structure_unittest.cc index ad64317..e1071b4 100644 --- a/components/autofill/core/browser/form_structure_unittest.cc +++ b/components/autofill/core/browser/form_structure_unittest.cc @@ -7,6 +7,7 @@ #include #include +#include #include "base/base64.h" #include "base/command_line.h" @@ -2257,7 +2258,7 @@ TEST_P(ParameterizedFormStructureTest, EncodeQueryRequest) { // 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()); @@ -2562,7 +2563,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithMatchingValidities) { // 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"); @@ -2741,7 +2743,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithNonMatchingValidities) { // 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"); @@ -2865,7 +2868,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithMultipleValidities) { // 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"); @@ -2987,7 +2991,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest) { 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"); @@ -3169,7 +3174,8 @@ TEST_F(FormStructureTestImpl, // 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"); @@ -3260,7 +3266,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithAutocomplete) { // 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"); @@ -3348,7 +3355,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequestWithPropertiesMask) { // 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"); @@ -3433,7 +3441,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_ObservedSubmissionFalse) { // 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"); @@ -3507,7 +3516,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithLabels) { // 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"); @@ -3580,7 +3590,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithCssClassesAndIds) { // 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"); @@ -3663,7 +3674,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithFormName) { // 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"); @@ -3739,7 +3751,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequestPartialMetadata) { // 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"); @@ -3824,7 +3837,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_DisabledMetadata) { // 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"); @@ -3929,7 +3943,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithSubForms) { 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"); @@ -3949,7 +3964,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithSubForms) { 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"); @@ -3962,7 +3978,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithSubForms) { 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"); @@ -3973,7 +3990,8 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_WithSubForms) { 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"); @@ -4040,7 +4058,8 @@ TEST_F(FormStructureTestImpl, CheckDataPresence) { // 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(""); @@ -4301,7 +4320,8 @@ TEST_F(FormStructureTestImpl, CheckMultipleTypes) { // 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"); @@ -4798,7 +4818,7 @@ TEST_F(FormStructureTestImpl, SkipFieldTest) { // 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()); @@ -4847,7 +4867,7 @@ TEST_F(FormStructureTestImpl, EncodeQueryRequest_WithLabels) { // 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()); @@ -4898,7 +4918,7 @@ TEST_F(FormStructureTestImpl, EncodeQueryRequest_WithLongLabels) { // 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()); @@ -4944,7 +4964,7 @@ TEST_F(FormStructureTestImpl, EncodeQueryRequest_MissingNames) { // 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()); diff --git a/components/autofill/core/browser/personal_data_manager_unittest.cc b/components/autofill/core/browser/personal_data_manager_unittest.cc index 2d1449a..fcb48bc 100644 --- a/components/autofill/core/browser/personal_data_manager_unittest.cc +++ b/components/autofill/core/browser/personal_data_manager_unittest.cc @@ -417,7 +417,7 @@ class PersonalDataManagerMockTest : public PersonalDataManagerTestBase, void StopTheDedupeProcess() { personal_data_->pref_service_->SetInteger( prefs::kAutofillLastVersionDeduped, - atoi(version_info::GetVersionNumber().c_str())); + version_info::GetMajorVersionNumberAsInt()); } void AddProfileToPersonalDataManager(const AutofillProfile& profile) { diff --git a/components/component_updater/configurator_impl.cc b/components/component_updater/configurator_impl.cc index 034d38b..f3f29ea 100644 --- a/components/component_updater/configurator_impl.cc +++ b/components/component_updater/configurator_impl.cc @@ -89,7 +89,7 @@ const base::Version& ConfiguratorImpl::GetBrowserVersion() const { } std::string ConfiguratorImpl::GetOSLongName() const { - return version_info::GetOSType(); + return std::string(version_info::GetOSType()); } base::flat_map ConfiguratorImpl::ExtraRequestParams() diff --git a/components/embedder_support/user_agent_utils.cc b/components/embedder_support/user_agent_utils.cc index 86e97af..cdc9d27 100644 --- a/components/embedder_support/user_agent_utils.cc +++ b/components/embedder_support/user_agent_utils.cc @@ -4,6 +4,7 @@ #include "components/embedder_support/user_agent_utils.h" +#include #include #include "base/command_line.h" @@ -230,11 +231,9 @@ const std::string& GetReducedMajorInMinorVersionNumber() { 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( @@ -275,7 +274,7 @@ const blink::UserAgentBrandList GetUserAgentBrandMajorVersionList( 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); } @@ -293,7 +292,7 @@ blink::UserAgentBrandList GetUserAgentBrandFullVersionList( 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); } @@ -584,7 +583,7 @@ std::string GetPlatformForUAMetadata() { return "Chromium OS"; # endif #else - return version_info::GetOSType(); + return std::string(version_info::GetOSType()); #endif } diff --git a/components/embedder_support/user_agent_utils_unittest.cc b/components/embedder_support/user_agent_utils_unittest.cc index a36d3ea..5e4c37e 100644 --- a/components/embedder_support/user_agent_utils_unittest.cc +++ b/components/embedder_support/user_agent_utils_unittest.cc @@ -4,6 +4,7 @@ #include "components/embedder_support/user_agent_utils.h" +#include #include #include "base/command_line.h" @@ -456,7 +457,7 @@ TEST_F(UserAgentUtilsTest, InvalidCustomUserAgent) { // 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); @@ -818,7 +819,7 @@ TEST_F(UserAgentUtilsTest, UserAgentMetadata) { 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 @@ -831,9 +832,9 @@ TEST_F(UserAgentUtilsTest, UserAgentMetadata) { 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)); @@ -847,9 +848,10 @@ TEST_F(UserAgentUtilsTest, UserAgentMetadata) { 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)); diff --git a/components/enterprise/browser/reporting/browser_report_generator.cc b/components/enterprise/browser/reporting/browser_report_generator.cc index 5bcd4ff..e928f92 100644 --- a/components/enterprise/browser/reporting/browser_report_generator.cc +++ b/components/enterprise/browser/reporting/browser_report_generator.cc @@ -57,7 +57,7 @@ void BrowserReportGenerator::GenerateBasicInfo(em::BrowserReport* report, #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); diff --git a/components/fuchsia_component_support/feedback_registration.cc b/components/fuchsia_component_support/feedback_registration.cc index 5d8aa37..da2bc08 100644 --- a/components/fuchsia_component_support/feedback_registration.cc +++ b/components/fuchsia_component_support/feedback_registration.cc @@ -47,7 +47,7 @@ void RegisterProductDataForFeedback(base::StringPiece component_namespace) { 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() diff --git a/components/fuchsia_component_support/inspect.cc b/components/fuchsia_component_support/inspect.cc index 7129bcb..dc5a4f3 100644 --- a/components/fuchsia_component_support/inspect.cc +++ b/components/fuchsia_component_support/inspect.cc @@ -19,10 +19,10 @@ void PublishVersionInfoToInspect(sys::ComponentInspector* inspector) { // 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 diff --git a/components/gcm_driver/gcm_desktop_utils.cc b/components/gcm_driver/gcm_desktop_utils.cc index 1ebdd54..be2b26c 100644 --- a/components/gcm_driver/gcm_desktop_utils.cc +++ b/components/gcm_driver/gcm_desktop_utils.cc @@ -57,7 +57,7 @@ GCMClient::ChromeChannel GetChannel(version_info::Channel channel) { } std::string GetVersion() { - return version_info::GetVersionNumber(); + return std::string(version_info::GetVersionNumber()); } GCMClient::ChromeBuildInfo GetChromeBuildInfo( diff --git a/components/metrics/version_utils.cc b/components/metrics/version_utils.cc index bc4e987..34e80a6 100644 --- a/components/metrics/version_utils.cc +++ b/components/metrics/version_utils.cc @@ -16,7 +16,7 @@ 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) diff --git a/components/minidump_uploader/rewrite_minidumps_as_mimes.cc b/components/minidump_uploader/rewrite_minidumps_as_mimes.cc index d749d12..04cc43d 100644 --- a/components/minidump_uploader/rewrite_minidumps_as_mimes.cc +++ b/components/minidump_uploader/rewrite_minidumps_as_mimes.cc @@ -230,9 +230,8 @@ static void WriteAnrAsMime(crashpad::FileReader* anr_reader, 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); } diff --git a/components/policy/core/browser/webui/json_generation.cc b/components/policy/core/browser/webui/json_generation.cc index 3770525..2710214 100644 --- a/components/policy/core/browser/webui/json_generation.cc +++ b/components/policy/core/browser/webui/json_generation.cc @@ -7,7 +7,7 @@ #include #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" @@ -44,15 +44,13 @@ base::Value::Dict GetChromeMetadataValue(const JsonGenerationParams& params) { 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); diff --git a/components/policy/core/common/cloud/cloud_policy_util.cc b/components/policy/core/common/cloud/cloud_policy_util.cc index ee21a43..cacdf10 100644 --- a/components/policy/core/common/cloud/cloud_policy_util.cc +++ b/components/policy/core/common/cloud/cloud_policy_util.cc @@ -155,7 +155,7 @@ std::string GetOSVersion() { } std::string GetOSPlatform() { - return version_info::GetOSType(); + return std::string(version_info::GetOSType()); } std::string GetOSArchitecture() { diff --git a/components/policy/core/common/policy_logger.cc b/components/policy/core/common/policy_logger.cc index 1b45e8b..db32aa3 100644 --- a/components/policy/core/common/policy_logger.cc +++ b/components/policy/core/common/policy_logger.cc @@ -60,7 +60,7 @@ std::string GetLogSeverity(const PolicyLogger::Log::Severity log_severity) { // 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 '-'. diff --git a/components/quirks/quirks_client.cc b/components/quirks/quirks_client.cc index 9f9d04b..afab6b6 100644 --- a/components/quirks/quirks_client.cc +++ b/components/quirks/quirks_client.cc @@ -72,7 +72,7 @@ void QuirksClient::StartDownload() { 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); diff --git a/components/safe_browsing/core/browser/db/v4_protocol_manager_util.cc b/components/safe_browsing/core/browser/db/v4_protocol_manager_util.cc index 090ec1f..09c3f25 100644 --- a/components/safe_browsing/core/browser/db/v4_protocol_manager_util.cc +++ b/components/safe_browsing/core/browser/db/v4_protocol_manager_util.cc @@ -81,7 +81,7 @@ V4ProtocolConfig GetV4ProtocolConfig(const std::string& client_name, 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) { diff --git a/components/safe_browsing/core/browser/user_population.cc b/components/safe_browsing/core/browser/user_population.cc index c6ad200..2cf3c8a 100644 --- a/components/safe_browsing/core/browser/user_population.cc +++ b/components/safe_browsing/core/browser/user_population.cc @@ -5,6 +5,7 @@ #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" @@ -57,8 +58,8 @@ ChromeUserPopulation GetUserPopulation( 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) diff --git a/components/safe_browsing/core/browser/user_population_unittest.cc b/components/safe_browsing/core/browser/user_population_unittest.cc index 1abb2b4..928db1c 100644 --- a/components/safe_browsing/core/browser/user_population_unittest.cc +++ b/components/safe_browsing/core/browser/user_population_unittest.cc @@ -5,6 +5,7 @@ #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" @@ -158,8 +159,8 @@ TEST(GetUserPopulationTest, PopulatesUserAgent) { 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(), absl::optional(), diff --git a/components/security_interstitials/content/certificate_error_report.cc b/components/security_interstitials/content/certificate_error_report.cc index 5afe25e..b09db9f 100644 --- a/components/security_interstitials/content/certificate_error_report.cc +++ b/components/security_interstitials/content/certificate_error_report.cc @@ -486,8 +486,9 @@ CertificateErrorReport::CertificateErrorReport( 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( diff --git a/components/sync/base/sync_util.cc b/components/sync/base/sync_util.cc index d3ba4ce..e636023 100644 --- a/components/sync/base/sync_util.cc +++ b/components/sync/base/sync_util.cc @@ -6,6 +6,7 @@ #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" @@ -54,18 +55,14 @@ namespace internal { 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 diff --git a/components/sync/driver/sync_internals_util.cc b/components/sync/driver/sync_internals_util.cc index c361524..7d4b020 100644 --- a/components/sync/driver/sync_internals_util.cc +++ b/components/sync/driver/sync_internals_util.cc @@ -10,6 +10,7 @@ #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" @@ -225,9 +226,10 @@ std::string GetVersionString(const std::string& channel) { } 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, diff --git a/components/update_client/update_query_params.cc b/components/update_client/update_query_params.cc index a427158..e52d9e7 100644 --- a/components/update_client/update_query_params.cc +++ b/components/update_client/update_query_params.cc @@ -158,7 +158,7 @@ const char* UpdateQueryParams::GetNaclArch() { // static std::string UpdateQueryParams::GetProdVersion() { - return version_info::GetVersionNumber(); + return std::string(version_info::GetVersionNumber()); } // static diff --git a/components/version_info/version_info.cc b/components/version_info/version_info.cc index 9b1f5e4..081f81f 100644 --- a/components/version_info/version_info.cc +++ b/components/version_info/version_info.cc @@ -15,10 +15,8 @@ namespace version_info { 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() { diff --git a/components/webapps/browser/android/webapk/webapk_proto_builder.cc b/components/webapps/browser/android/webapk/webapk_proto_builder.cc index 85d4a70..977a624 100644 --- a/components/webapps/browser/android/webapk/webapk_proto_builder.cc +++ b/components/webapps/browser/android/webapk/webapk_proto_builder.cc @@ -107,7 +107,8 @@ std::unique_ptr BuildProtoInBackground( 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); diff --git a/extensions/shell/browser/shell_extensions_browser_client.cc b/extensions/shell/browser/shell_extensions_browser_client.cc index 7fcd119..5583a00 100644 --- a/extensions/shell/browser/shell_extensions_browser_client.cc +++ b/extensions/shell/browser/shell_extensions_browser_client.cc @@ -321,7 +321,7 @@ std::string ShellExtensionsBrowserClient::GetApplicationLocale() { std::string ShellExtensionsBrowserClient::GetUserAgent() const { return content::BuildUserAgentFromProduct( - version_info::GetProductNameAndVersionForUserAgent()); + std::string(version_info::GetProductNameAndVersionForUserAgent())); } void ShellExtensionsBrowserClient::InitWithBrowserContext( diff --git a/fuchsia_web/common/init_logging.cc b/fuchsia_web/common/init_logging.cc index fc0d98a..b7d74ef 100644 --- a/fuchsia_web/common/init_logging.cc +++ b/fuchsia_web/common/init_logging.cc @@ -7,6 +7,7 @@ #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" @@ -49,7 +50,8 @@ void LogComponentStartWithVersion(base::StringPiece component_name) { "Starting %.*s %s", base::saturated_cast(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; diff --git a/fuchsia_web/webengine/browser/web_engine_content_browser_client.cc b/fuchsia_web/webengine/browser/web_engine_content_browser_client.cc index ce15363..9400a50 100644 --- a/fuchsia_web/webengine/browser/web_engine_content_browser_client.cc +++ b/fuchsia_web/webengine/browser/web_engine_content_browser_client.cc @@ -169,7 +169,7 @@ WebEngineContentBrowserClient::CreateDevToolsManagerDelegate() { } std::string WebEngineContentBrowserClient::GetProduct() { - return version_info::GetProductNameAndVersionForUserAgent(); + return std::string(version_info::GetProductNameAndVersionForUserAgent()); } std::string WebEngineContentBrowserClient::GetUserAgent() { diff --git a/weblayer/browser/content_browser_client_impl.cc b/weblayer/browser/content_browser_client_impl.cc index eaba5a6..2fb7290 100644 --- a/weblayer/browser/content_browser_client_impl.cc +++ b/weblayer/browser/content_browser_client_impl.cc @@ -422,7 +422,7 @@ void ContentBrowserClientImpl::LogWebFeatureForCurrentPage( } std::string ContentBrowserClientImpl::GetProduct() { - return version_info::GetProductNameAndVersionForUserAgent(); + return std::string(version_info::GetProductNameAndVersionForUserAgent()); } std::string ContentBrowserClientImpl::GetUserAgent() { -- 2.7.4