From fbff355742336179371ba728ce83e4d4111360d0 Mon Sep 17 00:00:00 2001 From: Nitish Sakhawalkar Date: Sun, 1 Apr 2018 20:47:00 -0700 Subject: [PATCH] Support for navigator.languages (#12419) --- atom/browser/api/atom_api_web_contents.cc | 6 ++++-- spec/chromium-spec.js | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index d702a8e5a131..57c6e3f8299a 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -50,6 +50,7 @@ #include "base/values.h" #include "brightray/browser/inspectable_web_contents.h" #include "brightray/browser/inspectable_web_contents_view.h" +#include "chrome/browser/browser_process.h" #include "chrome/browser/printing/print_preview_message_handler.h" #include "chrome/browser/printing/print_view_manager_basic.h" #include "chrome/browser/ssl/security_state_tab_helper.h" @@ -102,7 +103,6 @@ struct PrintSettings { bool print_background; base::string16 device_name; }; - } // namespace namespace mate { @@ -437,9 +437,11 @@ void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate, managed_web_contents()->GetView()->SetDelegate(this); + auto* prefs = web_contents->GetMutableRendererPrefs(); + prefs->accept_languages = g_browser_process->GetApplicationLocale(); + #if defined(OS_LINUX) || defined(OS_WIN) // Update font settings. - auto* prefs = web_contents->GetMutableRendererPrefs(); CR_DEFINE_STATIC_LOCAL(const gfx::FontRenderParams, params, (gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), nullptr))); prefs->should_antialias_text = params.antialiasing; diff --git a/spec/chromium-spec.js b/spec/chromium-spec.js index b12450993406..05b833fae9a8 100644 --- a/spec/chromium-spec.js +++ b/spec/chromium-spec.js @@ -132,6 +132,14 @@ describe('chromium feature', () => { }) }) + describe('navigator.languages', (done) => { + it('should return the system locale only', () => { + let appLocale = app.getLocale() + assert.equal(navigator.languages.length, 1) + assert.equal(navigator.languages[0], appLocale) + }) + }) + describe('navigator.serviceWorker', () => { it('should register for file scheme', (done) => { w = new BrowserWindow({