Index: chrome/installer/util/l10n_string_util.cc |
diff --git a/chrome/installer/util/l10n_string_util.cc b/chrome/installer/util/l10n_string_util.cc |
index 68acc9298640204b789d8335b696a97d4cc27a60..8765c3625b8bce5900e5fcac71c3b4cda49fc7e3 100644 |
--- a/chrome/installer/util/l10n_string_util.cc |
+++ b/chrome/installer/util/l10n_string_util.cc |
@@ -16,6 +16,9 @@ |
#include "base/logging.h" |
#include "base/strings/string_util.h" |
#include "base/strings/stringprintf.h" |
+#include "chrome/install_static/install_details.h" |
+#include "chrome/install_static/install_modes.h" |
+#include "chrome/installer/util/installer_util_strings.h" |
#include "chrome/installer/util/language_selector.h" |
namespace { |
@@ -40,6 +43,9 @@ void SetTranslationDelegate(TranslationDelegate* delegate) { |
} |
std::wstring GetLocalizedString(int base_message_id) { |
+ // Map |base_message_id| to the base id for the current install mode. |
+ base_message_id = GetBaseMessageIdForMode(base_message_id); |
+ |
if (g_translation_delegate) |
return g_translation_delegate->GetLocalizedString(base_message_id); |
@@ -105,4 +111,35 @@ std::wstring GetCurrentTranslation() { |
return GetLanguageSelector().selected_translation(); |
} |
+int GetBaseMessageIdForMode(int base_message_id) { |
+// Generate the constants holding the mode-specific resource ID arrays. |
+#define HANDLE_MODE_STRING(id, ...) \ |
+ static constexpr int k##id##Strings[] = {__VA_ARGS__}; \ |
+ static_assert( \ |
+ arraysize(k##id##Strings) == install_static::NUM_INSTALL_MODES, \ |
+ "resource " #id \ |
+ " has the wrong number of mode-specific " \ |
+ "strings."); |
+ DO_MODE_STRINGS |
+#undef HANDLE_MODE_STRING |
+ |
+ const int* mode_strings = nullptr; |
+ switch (base_message_id) { |
+// Generate the cases mapping each mode-specific resource ID to its array. |
+#define HANDLE_MODE_STRING(id, ...) \ |
+ case id: \ |
+ mode_strings = &k##id##Strings[0]; \ |
+ break; |
+ DO_MODE_STRINGS |
+#undef HANDLE_MODE_STRING |
+ default: |
+ // This ID has no per-mode variants. |
+ return base_message_id; |
+ } |
+ |
+ // Return the variant of |base_message_id| for the current mode. |
+ return mode_strings[install_static::InstallDetails::Get() |
+ .install_mode_index()]; |
+} |
+ |
} // namespace installer |