[PDNCF] Avoid constexpr std::string which is C++20-specific 78/294878/4
authoruzair <uzair.jaleel@samsung.com>
Wed, 28 Jun 2023 05:56:33 +0000 (11:26 +0530)
committerUzair Jaleel <uzair.jaleel@samsung.com>
Mon, 3 Jul 2023 11:17:23 +0000 (11:17 +0000)
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 <uzair.jaleel@samsung.com>
74 files changed:
chrome/app/chrome_main_delegate.cc
chrome/browser/apps/app_service/webapk/webapk_install_task.cc
chrome/browser/apps/guest_view/web_view_browsertest.cc
chrome/browser/ash/app_mode/kiosk_external_updater.cc
chrome/browser/ash/cryptauth/client_app_metadata_provider_service.cc
chrome/browser/ash/cryptauth/gcm_device_info_provider_impl.cc
chrome/browser/ash/policy/reporting/os_updates/os_updates_reporter.cc
chrome/browser/ash/policy/status_collector/device_status_collector.cc
chrome/browser/ash/web_applications/help_app/help_app_notification_controller_unittest.cc
chrome/browser/autofill/autofill_server_browsertest.cc
chrome/browser/chrome_browser_main_win.cc
chrome/browser/chrome_content_browser_client.cc
chrome/browser/diagnostics/recon_diagnostics.cc
chrome/browser/enterprise/connectors/connectors_service.cc
chrome/browser/enterprise/connectors/reporting/crash_reporting_context.cc
chrome/browser/enterprise/reporting/report_scheduler_unittest.cc
chrome/browser/extensions/api/declarative/rules_registry_service_unittest.cc
chrome/browser/extensions/api/identity/identity_get_auth_token_function.cc
chrome/browser/extensions/chrome_extensions_browser_client.cc
chrome/browser/extensions/preinstalled_apps.cc
chrome/browser/media/router/discovery/dial/dial_service_impl.cc
chrome/browser/media/router/providers/cast/chrome_cast_message_handler.cc
chrome/browser/media/webrtc/webrtc_event_log_uploader.cc
chrome/browser/media/webrtc/webrtc_log_uploader.cc
chrome/browser/media/webrtc/webrtc_text_log_handler.cc
chrome/browser/permissions/chrome_permissions_client.cc
chrome/browser/policy/device_management_service_configuration.cc
chrome/browser/profile_resetter/resettable_settings_snapshot.cc
chrome/browser/profiles/chrome_version_service.cc
chrome/browser/safe_browsing/chrome_user_population_helper_unittest.cc
chrome/browser/search_engines/ui_thread_search_terms_data.cc
chrome/browser/ui/ash/chrome_shell_delegate.cc
chrome/browser/ui/autofill/risk_util.cc
chrome/browser/ui/startup/first_run_service_unittest.cc
chrome/browser/ui/views/chrome_views_delegate.cc
chrome/browser/ui/webui/autofill_and_password_manager_internals/internals_ui_handler.cc
chrome/browser/ui/webui/flags/flags_ui.cc
chrome/browser/ui/webui/nacl_ui.cc
chrome/browser/ui/webui/version/version_ui.cc
chrome/browser/update_client/chrome_update_query_params_delegate.cc
chrome/browser/update_client/chrome_update_query_params_delegate_unittest.cc
chrome/browser/upgrade_detector/get_installed_version_linux_unittest.cc
chrome/common/mac/app_mode_chrome_locator_browsertest.mm
chrome/common/mac/app_mode_common.mm
chrome/updater/configurator.cc
components/autofill/core/browser/form_structure.cc
components/autofill/core/browser/form_structure_unittest.cc
components/autofill/core/browser/personal_data_manager_unittest.cc
components/component_updater/configurator_impl.cc
components/embedder_support/user_agent_utils.cc
components/embedder_support/user_agent_utils_unittest.cc
components/enterprise/browser/reporting/browser_report_generator.cc
components/fuchsia_component_support/feedback_registration.cc
components/fuchsia_component_support/inspect.cc
components/gcm_driver/gcm_desktop_utils.cc
components/metrics/version_utils.cc
components/minidump_uploader/rewrite_minidumps_as_mimes.cc
components/policy/core/browser/webui/json_generation.cc
components/policy/core/common/cloud/cloud_policy_util.cc
components/policy/core/common/policy_logger.cc
components/quirks/quirks_client.cc
components/safe_browsing/core/browser/db/v4_protocol_manager_util.cc
components/safe_browsing/core/browser/user_population.cc
components/safe_browsing/core/browser/user_population_unittest.cc
components/security_interstitials/content/certificate_error_report.cc
components/sync/base/sync_util.cc
components/sync/driver/sync_internals_util.cc
components/update_client/update_query_params.cc
components/version_info/version_info.cc
components/webapps/browser/android/webapk/webapk_proto_builder.cc
extensions/shell/browser/shell_extensions_browser_client.cc
fuchsia_web/common/init_logging.cc
fuchsia_web/webengine/browser/web_engine_content_browser_client.cc
weblayer/browser/content_browser_client_impl.cc

index fb50937..6dc223a 100644 (file)
@@ -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;
   }
index 8fc0138..b800239 100644 (file)
@@ -294,7 +294,8 @@ void WebApkInstallTask::Start(ResultCallback callback) {
   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));
 }
@@ -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));
 }
 
index 014e41d..0560f4b 100644 (file)
@@ -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<ParamType>& 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<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(); }
@@ -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<ParamType>& info) {
-    bool is_scroll_disabled = info.param;
-    return base::StringPrintf("Scroll%s",
-                              is_scroll_disabled ? "Disabled" : "Enabled");
+    return info.param ? "ScrollDisabled" : "ScrollEnabled";
   }
 };
 
index 1f353fb..be7c99a 100644 (file)
@@ -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));
index d63b7e1..78efa5d 100644 (file)
@@ -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;
 }
 
index 06b7fd5..abceb69 100644 (file)
@@ -53,7 +53,7 @@ const cryptauth::GcmDeviceInfo& GcmDeviceInfoProviderImpl::GetGcmDeviceInfo()
     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;
 
@@ -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());
index 3c472d4..f0e9ff4 100644 (file)
@@ -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());
 
index 866cc06..d03a10f 100644 (file)
@@ -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()));
index 4e98b10..71b6b7e 100644 (file)
@@ -56,15 +56,15 @@ class HelpAppNotificationControllerTest : public BrowserWithTestWindowTest {
     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;
   }
index 7aac57a..85fe9ac 100644 (file)
@@ -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 <string>
+
 #include "base/base64url.h"
 #include "base/base_switches.h"
 #include "base/command_line.h"
@@ -225,7 +227,7 @@ IN_PROC_BROWSER_TEST_F(AutofillServerTest,
       "</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);
 
@@ -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) {
       "</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);
 
index 0d96e40..b249926 100644 (file)
@@ -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())));
     }
   }
 }
index 1979ba1..f84dc86 100644 (file)
@@ -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() {
index 4a550b5..9645b12 100644 (file)
@@ -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;
index 500879b..8dcb5bf 100644 (file)
@@ -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());
 }
index 683956d..64a6535 100644 (file)
@@ -155,10 +155,10 @@ void UploadToReportingServer(
   }
   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;
 
index 2bc74d3..acf7492 100644 (file)
@@ -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_);
index 3e4ca58..7d8446a 100644 (file)
@@ -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,
index bacad4d..c1daa5d 100644 (file)
@@ -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,
index 387ae00..dd9c995 100644 (file)
@@ -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);
 
index a07c733..6dd8739 100644 (file)
@@ -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;
index a66e96b..b5da7be 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <algorithm>
 #include <set>
+#include <string>
 #include <utility>
 #include <vector>
 
@@ -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;
index b24dbb7..3d53090 100644 (file)
@@ -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;
 }
index 6cd0ba0..1c20dcc 100644 (file)
@@ -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(),
index fb8757a..9a90da3 100644 (file)
@@ -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",
index 6518ff3..b058c94 100644 (file)
@@ -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() + " " +
index 4933021..5760cd2 100644 (file)
@@ -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,
index 0804711..c231ed8 100644 (file)
@@ -7,6 +7,7 @@
 #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"
@@ -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 {
index 0a22530..1a1974e 100644 (file)
@@ -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),
index bf99f54..8cd5806 100644 (file)
@@ -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);
index abd2137..54738a6 100644 (file)
@@ -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);
 }
index 1344991..70b2571 100644 (file)
@@ -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 {
index 2df6bf8..5f5bc4e 100644 (file)
@@ -413,7 +413,7 @@ void ChromeShellDelegate::ForceSkipWarningUserOnClose(
 }
 
 std::string ChromeShellDelegate::GetVersionString() {
-  return version_info::GetVersionNumber();
+  return std::string(version_info::GetVersionNumber());
 }
 
 void ChromeShellDelegate::ShouldExitFullscreenBeforeLock(
index a772a22..fdbc2fa 100644 (file)
@@ -5,6 +5,7 @@
 #include "chrome/browser/ui/autofill/risk_util.h"
 
 #include <memory>
+#include <string>
 
 #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(),
index 519ec16..e6b0a58 100644 (file)
@@ -224,7 +224,7 @@ INSTANTIATE_TEST_SUITE_P(
     [](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
index 5870c87..4327473 100644 (file)
@@ -210,5 +210,5 @@ void ChromeViewsDelegate::OnBeforeWidgetInit(
 }
 
 std::string ChromeViewsDelegate::GetApplicationName() {
-  return version_info::GetProductName();
+  return std::string(version_info::GetProductName());
 }
index 8eba939..bf676bc 100644 (file)
@@ -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());
 }
index a273e23..bc0318f 100644 (file)
@@ -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() &&
index ea8b7ca..8ead8db 100644 (file)
@@ -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()) {
index 7ca8498..d61e235 100644 (file)
@@ -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)
index 4f48863..3947ede 100644 (file)
@@ -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
index 83faf8e..e550096 100644 (file)
@@ -4,7 +4,7 @@
 
 #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"
@@ -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) {
index 2e923bd..1297beb 100644 (file)
@@ -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;
index b7a08aa..ddc843b 100644 (file)
@@ -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));
index 022bd28..26a52b7 100644 (file)
@@ -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(),
   };
 }
index 69f1510..4b0c45f 100644 (file)
@@ -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<std::string, std::string> Configurator::ExtraRequestParams()
index 6a7f5e9..407bff1 100644 (file)
@@ -5,12 +5,12 @@
 #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>
@@ -414,7 +414,7 @@ std::vector<AutofillUploadContents> 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<AutofillUploadContents> FormStructure::EncodeUploadRequest(
        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);
@@ -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.
index ad64317..e1071b4 100644 (file)
@@ -7,6 +7,7 @@
 #include <stddef.h>
 
 #include <memory>
+#include <string>
 
 #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());
 
index 2d1449a..fcb48bc 100644 (file)
@@ -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) {
index 034d38b..f3f29ea 100644 (file)
@@ -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<std::string, std::string> ConfiguratorImpl::ExtraRequestParams()
index 86e97af..cdc9d27 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "components/embedder_support/user_agent_utils.h"
 
+#include <string>
 #include <vector>
 
 #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
 }
 
index a36d3ea..5e4c37e 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "components/embedder_support/user_agent_utils.h"
 
+#include <string>
 #include <vector>
 
 #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));
index 5bcd4ff..e928f92 100644 (file)
@@ -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);
index 5d8aa37..da2bc08 100644 (file)
@@ -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<fuchsia::feedback::ComponentDataRegister>()
index 7129bcb..dc5a4f3 100644 (file)
@@ -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
index 1ebdd54..be2b26c 100644 (file)
@@ -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(
index bc4e987..34e80a6 100644 (file)
@@ -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)
index d749d12..04cc43d 100644 (file)
@@ -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);
   }
index 3770525..2710214 100644 (file)
@@ -7,7 +7,7 @@
 #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"
@@ -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);
 
index ee21a43..cacdf10 100644 (file)
@@ -155,7 +155,7 @@ std::string GetOSVersion() {
 }
 
 std::string GetOSPlatform() {
-  return version_info::GetOSType();
+  return std::string(version_info::GetOSType());
 }
 
 std::string GetOSArchitecture() {
index 1b45e8b..db32aa3 100644 (file)
@@ -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 '-'.
index 9f9d04b..afab6b6 100644 (file)
@@ -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);
 
index 090ec1f..09c3f25 100644 (file)
@@ -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) {
index c6ad200..2cf3c8a 100644 (file)
@@ -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)
index 1abb2b4..928db1c 100644 (file)
@@ -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<size_t>(), absl::optional<size_t>(),
index 5afe25e..b09db9f 100644 (file)
@@ -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(
index d3ba4ce..e636023 100644 (file)
@@ -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
index c361524..7d4b020 100644 (file)
@@ -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,
index a427158..e52d9e7 100644 (file)
@@ -158,7 +158,7 @@ const char* UpdateQueryParams::GetNaclArch() {
 
 // static
 std::string UpdateQueryParams::GetProdVersion() {
-  return version_info::GetVersionNumber();
+  return std::string(version_info::GetVersionNumber());
 }
 
 // static
index 9b1f5e4..081f81f 100644 (file)
@@ -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() {
index 85d4a70..977a624 100644 (file)
@@ -107,7 +107,8 @@ std::unique_ptr<std::string> 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);
index 7fcd119..5583a00 100644 (file)
@@ -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(
index fc0d98a..b7d74ef 100644 (file)
@@ -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<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;
index ce15363..9400a50 100644 (file)
@@ -169,7 +169,7 @@ WebEngineContentBrowserClient::CreateDevToolsManagerDelegate() {
 }
 
 std::string WebEngineContentBrowserClient::GetProduct() {
-  return version_info::GetProductNameAndVersionForUserAgent();
+  return std::string(version_info::GetProductNameAndVersionForUserAgent());
 }
 
 std::string WebEngineContentBrowserClient::GetUserAgent() {
index eaba5a6..2fb7290 100644 (file)
@@ -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() {