Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2372)

Unified Diff: chrome/installer/util/l10n_string_util.cc

Issue 2791593002: Allow installer::GetLocalizedString to return mode-specific strings. (Closed)
Patch Set: manzagop review part the deux Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/installer/util/l10n_string_util.h ('k') | chrome/installer/util/l10n_string_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « chrome/installer/util/l10n_string_util.h ('k') | chrome/installer/util/l10n_string_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698