Commit cdf5e214 authored by Alex Newcomer's avatar Alex Newcomer Committed by Commit Bot

cros: Specify the charset for the html render request

When rendering HTML, specify charset. Without this, we get some
strange looking characters in the render. This should not fix all cases,
but hopefully fixes the majority.

Bug: 1128615
Change-Id: Ie81e2278c29c6f056bc5b4a1af886f5f9c089a02
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2437706
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Reviewed-by: default avatarDavid Black <dmblack@google.com>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811908}
parent 7fdb94c2
......@@ -73,11 +73,19 @@ void ClipboardImageModelRequest::Start(Params&& params) {
timeout_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(5), this,
&ClipboardImageModelRequest::OnTimeout);
std::string encoded_html;
// Begin the document with the proper charset, this should prevent strange
// looking characters from showing up in the render in some cases.
std::string html_document(
"<html><head><meta charset=\"UTF-8\"></meta></head><body>");
// Hide overflow to prevent scroll bars from showing up, which occurs when the
// rendered HTML takes up more space than 'kWebContentsBounds'.
params.html_markup.append("<style>body{overflow:hidden;}</style>");
base::Base64Encode(params.html_markup, &encoded_html);
html_document.append("<style>body{overflow:hidden;}</style>");
html_document.append(params.html_markup);
html_document.append("</body></html>");
std::string encoded_html;
base::Base64Encode(html_document, &encoded_html);
constexpr char kDataURIPrefix[] = "data:text/html;base64,";
web_view_->GetWebContents()->GetController().LoadURLWithParams(
content::NavigationController::LoadURLParams(
......
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