Commit c01cd02c authored by Henrique Limas's avatar Henrique Limas Committed by Commit Bot

Use AddLocalizedStringsBulk() on version_ui to reduce code size.

Refactored to use AddLocalizedStringsBulk() instead of
source->AddLocalizedString() to reduce code size and separated
data strings from localized strings.
Follow up of changes https://crrev.com/c/1591712 and
https://crrev.com/c/1628757 and https://crrev.com/c/1630467

CQ_INCLUDE_TRYBOTS=luci.chromium.try:try-nougat-phone-tester

Bug: 957201
Change-Id: I805f4441649ff16c611fdb417548e2cc5040c667
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1661668Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Commit-Queue: Michael Giuffrida <michaelpg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672557}
parent 79a343c0
......@@ -12,6 +12,7 @@
#include "build/build_config.h"
#include "chrome/browser/chrome_content_browser_client.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/localized_string.h"
#include "chrome/browser/ui/webui/version_handler.h"
#include "chrome/browser/ui/webui/version_util_win.h"
#include "chrome/common/channel_info.h"
......@@ -55,58 +56,59 @@ WebUIDataSource* CreateVersionUIDataSource() {
WebUIDataSource* html_source =
WebUIDataSource::Create(chrome::kChromeUIVersionHost);
// Localized and data strings.
html_source->AddLocalizedString(version_ui::kTitle, IDS_VERSION_UI_TITLE);
html_source->AddLocalizedString(version_ui::kApplicationLabel,
IDS_PRODUCT_NAME);
// Localized strings.
static constexpr LocalizedString kStrings[] = {
{version_ui::kTitle, IDS_VERSION_UI_TITLE},
{version_ui::kApplicationLabel, IDS_PRODUCT_NAME},
{version_ui::kCompany, IDS_ABOUT_VERSION_COMPANY_NAME},
{version_ui::kRevision, IDS_VERSION_UI_REVISION},
{version_ui::kUserAgentName, IDS_VERSION_UI_USER_AGENT},
{version_ui::kCommandLineName, IDS_VERSION_UI_COMMAND_LINE},
{version_ui::kExecutablePathName, IDS_VERSION_UI_EXECUTABLE_PATH},
{version_ui::kProfilePathName, IDS_VERSION_UI_PROFILE_PATH},
{version_ui::kVariationsName, IDS_VERSION_UI_VARIATIONS},
{version_ui::kVariationsCmdName, IDS_VERSION_UI_VARIATIONS_CMD},
#if defined(OS_CHROMEOS)
{version_ui::kARC, IDS_ARC_LABEL},
{version_ui::kPlatform, IDS_PLATFORM_LABEL},
{version_ui::kCustomizationId, IDS_VERSION_UI_CUSTOMIZATION_ID},
{version_ui::kFirmwareVersion, IDS_VERSION_UI_FIRMWARE_VERSION},
#else
{version_ui::kOSName, IDS_VERSION_UI_OS},
#endif // OS_CHROMEOS
#if defined(OS_ANDROID)
{version_ui::kGmsName, IDS_VERSION_UI_GMS},
#endif // OS_ANDROID
};
AddLocalizedStringsBulk(html_source, kStrings, base::size(kStrings));
html_source->AddLocalizedString(version_ui::kOfficial,
version_info::IsOfficialBuild()
? IDS_VERSION_UI_OFFICIAL
: IDS_VERSION_UI_UNOFFICIAL);
html_source->AddLocalizedString(
version_ui::kVersionBitSize,
sizeof(void*) == 8 ? IDS_VERSION_UI_64BIT : IDS_VERSION_UI_32BIT);
// Data strings.
html_source->AddString(version_ui::kVersion,
version_info::GetVersionNumber());
html_source->AddString(version_ui::kVersionModifier,
chrome::GetChannelName());
html_source->AddString(version_ui::kJSEngine, "V8");
html_source->AddString(version_ui::kJSVersion, V8_VERSION_STRING);
html_source->AddLocalizedString(version_ui::kCompany,
IDS_ABOUT_VERSION_COMPANY_NAME);
html_source->AddString(
version_ui::kCopyright,
base::i18n::MessageFormatter::FormatWithNumberedArgs(
l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_COPYRIGHT),
base::Time::Now()));
html_source->AddLocalizedString(version_ui::kRevision,
IDS_VERSION_UI_REVISION);
html_source->AddString(version_ui::kCL, version_info::GetLastChange());
html_source->AddLocalizedString(version_ui::kOfficial,
version_info::IsOfficialBuild()
? IDS_VERSION_UI_OFFICIAL
: IDS_VERSION_UI_UNOFFICIAL);
html_source->AddLocalizedString(version_ui::kUserAgentName,
IDS_VERSION_UI_USER_AGENT);
html_source->AddString(version_ui::kUserAgent, GetUserAgent());
html_source->AddLocalizedString(version_ui::kCommandLineName,
IDS_VERSION_UI_COMMAND_LINE);
// Note that the executable path and profile path are retrieved asynchronously
// and returned in VersionHandler::OnGotFilePaths. The area is initially
// blank.
html_source->AddLocalizedString(version_ui::kExecutablePathName,
IDS_VERSION_UI_EXECUTABLE_PATH);
html_source->AddString(version_ui::kExecutablePath, std::string());
html_source->AddLocalizedString(version_ui::kProfilePathName,
IDS_VERSION_UI_PROFILE_PATH);
html_source->AddString(version_ui::kProfilePath, std::string());
html_source->AddLocalizedString(version_ui::kVariationsName,
IDS_VERSION_UI_VARIATIONS);
html_source->AddLocalizedString(version_ui::kVariationsCmdName,
IDS_VERSION_UI_VARIATIONS_CMD);
#if defined(OS_CHROMEOS)
html_source->AddLocalizedString(version_ui::kARC, IDS_ARC_LABEL);
html_source->AddLocalizedString(version_ui::kPlatform, IDS_PLATFORM_LABEL);
html_source->AddLocalizedString(version_ui::kCustomizationId,
IDS_VERSION_UI_CUSTOMIZATION_ID);
html_source->AddLocalizedString(version_ui::kFirmwareVersion,
IDS_VERSION_UI_FIRMWARE_VERSION);
#else
html_source->AddLocalizedString(version_ui::kOSName, IDS_VERSION_UI_OS);
#endif // OS_CHROMEOS
#if defined(OS_MACOSX)
html_source->AddString(version_ui::kOSType, base::mac::GetOSDisplayName());
......@@ -117,7 +119,6 @@ WebUIDataSource* CreateVersionUIDataSource() {
#if defined(OS_ANDROID)
html_source->AddString(version_ui::kOSVersion,
AndroidAboutAppInfo::GetOsInfo());
html_source->AddLocalizedString(version_ui::kGmsName, IDS_VERSION_UI_GMS);
html_source->AddString(version_ui::kGmsVersion,
AndroidAboutAppInfo::GetGmsInfo());
#else
......@@ -127,9 +128,6 @@ WebUIDataSource* CreateVersionUIDataSource() {
html_source->AddString(version_ui::kFlashVersion, std::string());
#endif // OS_ANDROID
html_source->AddLocalizedString(
version_ui::kVersionBitSize,
sizeof(void*) == 8 ? IDS_VERSION_UI_64BIT : IDS_VERSION_UI_32BIT);
#if defined(OS_WIN)
html_source->AddString(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment