Skip to content

Commit

Permalink
Separate into platform files
Browse files Browse the repository at this point in the history
  • Loading branch information
nitsakh committed Nov 13, 2018
1 parent 63dd57f commit 5f9a2db
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 20 deletions.
20 changes: 0 additions & 20 deletions atom/browser/api/atom_api_web_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,10 @@
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/options_switches.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/values.h"
#include "base/win/i18n.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/ssl/security_state_tab_helper.h"
#include "content/browser/frame_host/frame_tree_node.h"
Expand Down Expand Up @@ -98,7 +96,6 @@
#endif

#if defined(OS_LINUX) || defined(OS_WIN)
#include "content/public/common/renderer_preferences.h"
#include "ui/gfx/font_render_params.h"
#endif

Expand Down Expand Up @@ -404,23 +401,6 @@ void WebContents::InitZoomController(content::WebContents* web_contents,
zoom_controller_->SetDefaultZoomFactor(zoom_factor);
}

#if defined(OS_WIN) || defined(OS_LINUX)
void WebContents::SetAcceptLanguages(content::RendererPreferences* prefs) {
#ifdef OS_WIN
std::vector<base::string16> languages;
base::win::i18n::GetThreadPreferredUILanguageList(&languages);
std::string accept_langs;
for (const auto& s16 : languages) {
accept_langs += base::SysWideToUTF8(s16) + ',';
}
accept_langs.pop_back();
prefs->accept_languages = accept_langs;
#else // OS_LINUX
prefs->accept_languages = g_browser_process->GetApplicationLocale();
#endif
}
#endif

void WebContents::InitWithSessionAndOptions(
v8::Isolate* isolate,
std::unique_ptr<content::WebContents> owned_web_contents,
Expand Down
19 changes: 19 additions & 0 deletions atom/browser/api/atom_api_web_contents_linux.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) 2018 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.

#include "atom/browser/api/atom_api_web_contents.h"

#include "content/public/common/renderer_preferences.h"

namespace atom {

namespace api {

void WebContents::SetAcceptLanguages(content::RendererPreferences* prefs) {
prefs->accept_languages = g_browser_process->GetApplicationLocale();
}

} // namespace api

} // namespace atom
28 changes: 28 additions & 0 deletions atom/browser/api/atom_api_web_contents_win.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) 2018 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.

#include "atom/browser/api/atom_api_web_contents.h"

#include "base/strings/sys_string_conversions.h"
#include "base/win/i18n.h"
#include "content/public/common/renderer_preferences.h"

namespace atom {

namespace api {

void WebContents::SetAcceptLanguages(content::RendererPreferences* prefs) {
std::vector<base::string16> languages;
base::win::i18n::GetThreadPreferredUILanguageList(&languages);
std::string accept_langs;
for (const auto& s16 : languages) {
accept_langs += base::SysWideToUTF8(s16) + ',';
}
accept_langs.pop_back();
prefs->accept_languages = accept_langs;
}

} // namespace api

} // namespace atom
2 changes: 2 additions & 0 deletions filenames.gni
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ filenames = {
"atom/browser/api/atom_api_web_contents.cc",
"atom/browser/api/atom_api_web_contents.h",
"atom/browser/api/atom_api_web_contents_mac.mm",
"atom/browser/api/atom_api_web_contents_linux.cc",
"atom/browser/api/atom_api_web_contents_win.cc",
"atom/browser/api/atom_api_web_contents_view.cc",
"atom/browser/api/atom_api_web_contents_view.h",
"atom/browser/api/atom_api_web_request.cc",
Expand Down

0 comments on commit 5f9a2db

Please sign in to comment.