Commit 41dc15f1 authored by Alexei Svitkine's avatar Alexei Svitkine Committed by Commit Bot

Add a CHECK failure for when the resource bundle loading fails.

This matches the CHECK in chrome/app/chrome_main_delegate.cc
with the same message.

These errors are not recoverable, and currently result in a CHECK
being hit later in VariationsService::EnsureLocaleEquals(), which
is trying to guard for locale mismatch issues.

Also expands header comments to mention the empty string return
value being the failure case.

See ResourceBundle::LoadLocaleResources() implementation for the
failure details (i.e. if empty string was returned, we either
didn't load the pack file at all, or got an error loading it).

Bug: 1022934
Change-Id: I4cc670cf669ed824c3b2073586941931fd38e364
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2141010Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarGreg Thompson <grt@chromium.org>
Commit-Queue: Alexei Svitkine <asvitkine@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758991}
parent f5d42a0f
......@@ -87,8 +87,8 @@ std::string InitResourceBundleAndDetermineLocale(PrefService* local_state,
// method InitSharedInstance is ignored.
std::string actual_locale = ui::ResourceBundle::InitSharedInstanceWithLocale(
preferred_locale, nullptr, ui::ResourceBundle::LOAD_COMMON_RESOURCES);
if (actual_locale.empty())
return actual_locale;
CHECK(!actual_locale.empty())
<< "Locale could not be found for " << preferred_locale;
// First run prefs needs data from the ResourceBundle, so load it now.
{
......
......@@ -120,7 +120,8 @@ class UI_BASE_EXPORT ResourceBundle {
};
// Initialize the ResourceBundle for this process. Does not take ownership of
// the |delegate| value. Returns the language selected.
// the |delegate| value. Returns the language selected or an empty string if
// initialization failed (e.g. resource bundle not found or corrupted).
// NOTE: Mac ignores this and always loads up resources for the language
// defined by the Cocoa UI (i.e., NSBundle does the language work).
//
......@@ -194,11 +195,12 @@ class UI_BASE_EXPORT ResourceBundle {
ScaleFactor scale_factor);
// Changes the locale for an already-initialized ResourceBundle, returning the
// name of the newly-loaded locale. Future calls to get strings will return
// the strings for this new locale. This has no effect on existing or future
// image resources. |locale_resources_data_| is protected by a lock for the
// duration of the swap, as GetLocalizedString() may be concurrently invoked
// on another thread.
// name of the newly-loaded locale, or an empty string if initialization
// failed (e.g. resource bundle not found or corrupted). Future calls to get
// strings will return the strings for this new locale. This has no effect on
// existing or future image resources. |locale_resources_data_| is protected
// by a lock for the duration of the swap, as GetLocalizedString() may be
// concurrently invoked on another thread.
std::string ReloadLocaleResources(const std::string& pref_locale);
// Gets image with the specified resource_id from the current module data.
......
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