Commit 943f8147 authored by Tim Volodine's avatar Tim Volodine Committed by Commit Bot

[Android WebView] Implement Accept-Language request header functionality with NS.

Make sure the Accept-Language HTTP request header works in Android WebView and
fix the corresponding tests.

In this patch:
- make sure to update the network context using SetAcceptLanguage when the
WebView Accept-Language setting changes.
- fix tests

This patch fixes:
- org.chromium.android_webview.test.AcceptLanguageTest#testAcceptLanguage
- org.chromium.android_webview.test.AcceptLanguageTest#testAcceptLanguagesWithenUS

BUG=893561,841556

Cq-Include-Trybots: luci.chromium.try:linux_mojo
Change-Id: Ibd745513484466541dffbf9d24b65c1e702dc9b0
Reviewed-on: https://chromium-review.googlesource.com/c/1280857
Commit-Queue: Tim Volodine <timvolodine@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604269}
parent 0328261c
......@@ -6,6 +6,7 @@
#include <memory>
#include "android_webview/browser/aw_browser_context.h"
#include "android_webview/browser/aw_content_browser_client.h"
#include "android_webview/browser/aw_contents.h"
#include "android_webview/browser/renderer_host/aw_render_view_host_ext.h"
......@@ -18,10 +19,12 @@
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/renderer_preferences.h"
#include "content/public/common/web_preferences.h"
#include "jni/AwSettings_jni.h"
#include "services/network/public/cpp/features.h"
#include "ui/gfx/font_render_params.h"
using base::android::ConvertJavaStringToUTF16;
......@@ -243,6 +246,18 @@ void AwSettings::UpdateRendererPreferencesLocked(
content::RenderViewHost* host = web_contents()->GetRenderViewHost();
if (update_prefs && host)
host->SyncRendererPrefs();
if (update_prefs &&
base::FeatureList::IsEnabled(network::features::kNetworkService)) {
// make sure to update accept languages when the network service is enabled
AwBrowserContext* aw_browser_context =
AwBrowserContext::FromWebContents(web_contents());
// AndroidWebview does not use per-site storage partitions.
content::StoragePartition* storage_partition =
content::BrowserContext::GetDefaultStoragePartition(aw_browser_context);
storage_partition->GetNetworkContext()->SetAcceptLanguage(
prefs->accept_languages);
}
}
void AwSettings::UpdateOffscreenPreRasterLocked(
......
......@@ -13,9 +13,6 @@
# https://crbug.com/882650
-*__multiprocess_mode
# https://crbug.com/893561
-org.chromium.android_webview.test.AcceptLanguageTest.testAcceptLanguage
# https://crbug.com/893563
-org.chromium.android_webview.test.AwContentsClientFullScreenTest.testExitFullscreenEndsIfAppInvokesCallbackFromOnHideCustomView
-org.chromium.android_webview.test.AwContentsClientFullScreenTest.testFullscreenForNonVideoElementIsSupportedInSoftwareMode
......
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