Commit 7447872b authored by Erik Chen's avatar Erik Chen Committed by Commit Bot

lacros: Add user-agent override hack for netflix.com.

This CL adds a hack to blink that causes Lacros to user the Linux user
agent for netflix.com instead of the ChromeOS user agent. This allows
Lacros users to watch Netflix. A proper solution is blocked on the CDM
team, ETA Q2 2021.

Bug: 1114866
Change-Id: I8b510a9c0886d7f472d932416d60ad404093384c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2521140
Commit-Queue: Erik Chen <erikchen@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825088}
parent 0640ec87
......@@ -269,6 +269,7 @@ target(link_target_type, "renderer") {
"//base",
"//base:i18n",
"//build:chromecast_buildflags",
"//build:chromeos_buildflags",
"//cc",
"//cc/animation",
"//cc/mojo_embedder",
......
......@@ -48,6 +48,7 @@
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "cc/base/switches.h"
#include "content/common/associated_interfaces.mojom.h"
#include "content/common/content_constants_internal.h"
......@@ -4850,6 +4851,21 @@ blink::WebString RenderFrameImpl::UserAgentOverride() {
return WebString::FromUTF8(render_view_->GetRendererPreferences()
.user_agent_override.ua_string_override);
}
#if BUILDFLAG(IS_LACROS)
// TODO(https://crbug.com/1114866): Implement proper L3 CDM support for
// Lacros. This is scheduled for Q2 2021. After that we can remove this hack.
WebSecurityOrigin frame_origin = frame_->GetDocument().GetSecurityOrigin();
if (frame_origin.Host().Utf8() == "www.netflix.com") {
WebString user_agent = RenderThreadImpl::current()->GetUserAgent();
std::string user_agent_utf8 =
user_agent.Utf8(WebString::UTF8ConversionMode::kStrict);
base::ReplaceSubstringsAfterOffset(&user_agent_utf8, /*start_offset=*/0,
" CrOS ", " Linux ");
return WebString::FromUTF8(user_agent_utf8);
}
#endif
return blink::WebString();
}
......
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