Commit 5814800f authored by Alexei Svitkine's avatar Alexei Svitkine Committed by Commit Bot

Fix Windows first run crash related to locale.

The crash would happen if you install Chrome of a specific language
and run it for the first time on a Windows OS of a different
language.

It was caused by code setting the language pref in-between the two
places where it was queried - such that the first time it was
queried resulted in a different value than the second.

This triggered the CHECK that was introduced by this CL:
https://chromium-review.googlesource.com/c/chromium/src/+/1349770

Which correctly identified the problem. This CL fixes the issue
by moving the importing of the first-run locale setting to
earlier.

Bug: 908791, 908114
Change-Id: Ie2e0178f298f78d38e0bc7f0b58c2205bb617561
Reviewed-on: https://chromium-review.googlesource.com/c/1352482Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarRobert Kaplow <rkaplow@chromium.org>
Commit-Queue: Alexei Svitkine <asvitkine@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611480}
parent 00f4bfdf
......@@ -42,19 +42,6 @@ extern void InitializeLocalState(
// locale dll to load. This also causes local state prefs to be registered.
PrefService* local_state = chrome_feature_list_creator->local_state();
DCHECK(local_state);
#if defined(OS_WIN)
if (first_run::IsChromeFirstRun()) {
// During first run we read the google_update registry key to find what
// language the user selected when downloading the installer. This
// becomes our default language in the prefs.
// Other platforms obey the system locale.
base::string16 install_lang;
if (GoogleUpdateSettings::GetLanguage(&install_lang)) {
local_state->SetString(language::prefs::kApplicationLocale,
base::UTF16ToASCII(install_lang));
}
}
#endif // defined(OS_WIN)
// If the local state file for the current profile doesn't exist and the
// parent profile command line flag is present, then we should inherit some
......
......@@ -13,6 +13,7 @@
#include "base/files/file_util.h"
#include "base/memory/scoped_refptr.h"
#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
#include "base/system/sys_info.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
......@@ -26,6 +27,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_result_codes.h"
#include "chrome/common/pref_names.h"
#include "chrome/installer/util/google_update_settings.h"
#include "components/flags_ui/flags_ui_pref_names.h"
#include "components/flags_ui/pref_service_flags_storage.h"
#include "components/language/core/browser/pref_names.h"
......@@ -147,6 +149,23 @@ void ChromeFeatureListCreator::CreatePrefService() {
local_state_file, browser_policy_connector_->GetPolicyService(),
std::move(pref_registry), false, std::move(delegate),
browser_policy_connector_.get());
// TODO(asvitkine): This is done here so that the pref is set before
// VariationsService queries the locale. This should potentially be moved to
// somewhere better, e.g. as a helper in first_run namespace.
#if defined(OS_WIN)
if (first_run::IsChromeFirstRun()) {
// During first run we read the google_update registry key to find what
// language the user selected when downloading the installer. This
// becomes our default language in the prefs.
// Other platforms obey the system locale.
base::string16 install_lang;
if (GoogleUpdateSettings::GetLanguage(&install_lang)) {
local_state_->SetString(language::prefs::kApplicationLocale,
base::UTF16ToASCII(install_lang));
}
}
#endif // defined(OS_WIN)
}
void ChromeFeatureListCreator::ConvertFlagsToSwitches() {
......
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