Commit fd2a4512 authored by Wez's avatar Wez Committed by Chromium LUCI CQ

[fuchsia] Include fallback languages in HTTP language headers.

Include "fallback" languages in the "sec-ch-lang" and "accept-language"
headers rather than relying on generic language fallbacks. This allows
language/locale combinations that are less commonly supported by sites
to be substituted with more appropriate commonly-supported combinations
than would otherwise be possible.

Bug: 1092804, 1164990
Change-Id: I7827ecbc24c0d2745e53a7c50af01b2c0cda0773
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2632757
Auto-Submit: Wez <wez@chromium.org>
Commit-Queue: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Reviewed-by: default avatarDavid Dorwin <ddorwin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844834}
parent a6198df8
...@@ -65,15 +65,18 @@ repack("web_engine_pak") { ...@@ -65,15 +65,18 @@ repack("web_engine_pak") {
foreach(locale, locales_with_fake_bidi) { foreach(locale, locales_with_fake_bidi) {
repack("web_engine_locale_${locale}_pak") { repack("web_engine_locale_${locale}_pak") {
# WebEngine requires the following locale-specific resources: # WebEngine requires the following locale-specific resources:
# 1. Blink strings for UI elements, e.g. drop-down lists. # 1. Locale settings (e.g. default encoding, accept-languages per locale).
# 2. //ui strings used to configure e.g. preferred font family. # 2. Blink strings for UI elements, e.g. drop-down lists.
# 3. //ui strings used to configure e.g. preferred font family.
sources = [ sources = [
"$root_gen_dir/components/strings/components_locale_settings_${locale}.pak",
"$root_gen_dir/third_party/blink/public/strings/blink_strings_${locale}.pak", "$root_gen_dir/third_party/blink/public/strings/blink_strings_${locale}.pak",
"$root_gen_dir/ui/strings/app_locale_settings_${locale}.pak", "$root_gen_dir/ui/strings/app_locale_settings_${locale}.pak",
] ]
deps = [ deps = [
"//components/strings:components_locale_settings",
"//third_party/blink/public/strings", "//third_party/blink/public/strings",
"//ui/strings:app_locale_settings", "//ui/strings:app_locale_settings",
] ]
......
...@@ -3,6 +3,7 @@ include_rules = [ ...@@ -3,6 +3,7 @@ include_rules = [
"+components/keyed_service/core", "+components/keyed_service/core",
"+components/on_load_script_injector/browser", "+components/on_load_script_injector/browser",
"+components/policy/content", "+components/policy/content",
"+components/strings",
"+content/public/common", "+content/public/common",
"+content/public/browser", "+content/public/browser",
"+media/base", "+media/base",
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "base/system/sys_info.h" #include "base/system/sys_info.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/keyed_service/core/simple_key_map.h" #include "components/keyed_service/core/simple_key_map.h"
#include "components/strings/grit/components_locale_settings.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/resource_context.h" #include "content/public/browser/resource_context.h"
...@@ -24,8 +25,8 @@ ...@@ -24,8 +25,8 @@
#include "fuchsia/engine/switches.h" #include "fuchsia/engine/switches.h"
#include "media/capabilities/in_memory_video_decode_stats_db_impl.h" #include "media/capabilities/in_memory_video_decode_stats_db_impl.h"
#include "media/mojo/services/video_decode_perf_history.h" #include "media/mojo/services/video_decode_perf_history.h"
#include "net/http/http_util.h"
#include "services/network/public/cpp/network_switches.h" #include "services/network/public/cpp/network_switches.h"
#include "ui/base/l10n/l10n_util.h"
namespace { namespace {
...@@ -194,7 +195,7 @@ WebEngineBrowserContext::GetVideoDecodePerfHistory() { ...@@ -194,7 +195,7 @@ WebEngineBrowserContext::GetVideoDecodePerfHistory() {
} }
std::string WebEngineBrowserContext::GetPreferredLanguages() const { std::string WebEngineBrowserContext::GetPreferredLanguages() const {
return net::HttpUtil::ExpandLanguageList(base::i18n::GetConfiguredLocale()); return l10n_util::GetStringUTF8(IDS_ACCEPT_LANGUAGES);
} }
media::VideoDecodePerfHistory* media::VideoDecodePerfHistory*
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "gpu/command_buffer/service/gpu_switches.h" #include "gpu/command_buffer/service/gpu_switches.h"
#include "services/network/public/mojom/network_context.mojom.h" #include "services/network/public/mojom/network_context.mojom.h"
#include "ui/aura/screen_ozone.h" #include "ui/aura/screen_ozone.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/switches.h" #include "ui/gfx/switches.h"
#include "ui/ozone/public/ozone_platform.h" #include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/ozone_switches.h" #include "ui/ozone/public/ozone_switches.h"
...@@ -182,6 +183,12 @@ void WebEngineBrowserMainParts::OnIntlProfileChanged( ...@@ -182,6 +183,12 @@ void WebEngineBrowserMainParts::OnIntlProfileChanged(
base::FuchsiaIntlProfileWatcher::GetPrimaryLocaleIdFromProfile(profile); base::FuchsiaIntlProfileWatcher::GetPrimaryLocaleIdFromProfile(profile);
base::i18n::SetICUDefaultLocale(primary_locale); base::i18n::SetICUDefaultLocale(primary_locale);
// Reload locale-specific resources.
std::string loaded_locale =
ui::ResourceBundle::GetSharedInstance().ReloadLocaleResources(
base::i18n::GetConfiguredLocale());
VLOG(1) << "Reloaded locale resources: " << loaded_locale;
// Reconfigure the network process. // Reconfigure the network process.
content::BrowserContext::GetDefaultStoragePartition(browser_context_.get()) content::BrowserContext::GetDefaultStoragePartition(browser_context_.get())
->GetNetworkContext() ->GetNetworkContext()
......
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