Commit 804a2cf8 authored by Dan Beam's avatar Dan Beam Committed by Commit Bot

Local NTP: annotate page content's language in markup for a11y purposes

R=kristipark@chromium.org
BUG=957353

Change-Id: I8eae1cad80062ff3ee97f8eef2bfad774058f5ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1609588
Commit-Queue: Dan Beam <dbeam@chromium.org>
Commit-Queue: Kristi Park <kristipark@chromium.org>
Auto-Submit: Dan Beam <dbeam@chromium.org>
Reviewed-by: default avatarKristi Park <kristipark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659335}
parent 8109ebdb
<!doctype html>
<html>
<html lang="$i18n{language}"><!-- TODO(dbeam): dir="$i18n{textdirection}"? -->
<!-- Copyright 2015 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
......
......@@ -1235,7 +1235,10 @@ function init() {
if (searchboxApiHandle.rtl) {
$(IDS.NOTIFICATION).dir = 'rtl';
// Grabbing the root HTML element.
// Grabbing the root HTML element. TODO(dbeam): could this just be <html ...
// dir="$i18n{textdirection}"> in the .html file instead? It could result in
// less flicker for RTL users (as HTML/CSS can render before JavaScript has
// the chance to run).
document.documentElement.setAttribute('dir', 'rtl');
// Add class for setting alignments based on language directionality.
document.documentElement.classList.add(CLASSES.RTL);
......
......@@ -24,6 +24,7 @@
#include "base/task/post_task.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/background/ntp_background_data.h"
#include "chrome/browser/search/background/ntp_background_service.h"
......@@ -970,6 +971,10 @@ void LocalNtpSource::StartDataRequest(
// TODO(dbeam): rewrite this class to WebUIDataSource instead of
// URLDataSource, and get magical $i18n{} replacement for free.
ui::TemplateReplacements replacements;
const std::string& app_locale = g_browser_process->GetApplicationLocale();
webui::SetLoadTimeDataDefaults(app_locale, &replacements);
replacements["animationsIntegrity"] =
base::StrCat({kSha256, ANIMATIONS_JS_INTEGRITY});
replacements["configDataIntegrity"] = base::StrCat(
......
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