blob: 41a85d93802888d1416ead78e56a06b336ac3d55 [file] [log] [blame]
[email protected]37cc8042012-02-27 19:32:581// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]93623c5d2009-12-10 21:40:322// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/renderer_preferences_util.h"
6
guidouca055a542016-08-11 11:15:537#include <string>
8
[email protected]516b2c732014-07-25 00:10:319#include "base/macros.h"
guidouca055a542016-08-11 11:15:5310#include "base/strings/string_number_conversions.h"
11#include "base/strings/string_util.h"
avib896c712015-12-26 02:10:4312#include "build/build_config.h"
[email protected]8ecad5e2010-12-02 21:18:3313#include "chrome/browser/profiles/profile.h"
[email protected]0a8db0d2011-04-13 15:15:4014#include "chrome/common/pref_names.h"
brettwb1fc1b82016-02-02 00:19:0815#include "components/prefs/pref_service.h"
[email protected]daf82f82011-10-31 22:35:3116#include "content/public/common/renderer_preferences.h"
guoweisc537ba22015-11-06 21:20:3117#include "content/public/common/webrtc_ip_handling_policy.h"
Scott Violeta35f9a42018-03-22 22:00:4418#include "media/media_buildflags.h"
Blink Reformata30d4232018-04-07 15:31:0619#include "third_party/blink/public/public_buildflags.h"
[email protected]38a85712013-01-02 22:45:0220#include "third_party/skia/include/core/SkColor.h"
[email protected]93623c5d2009-12-10 21:40:3221
[email protected]7d076cf52012-07-09 23:04:4722#if defined(OS_LINUX) || defined(OS_ANDROID)
[email protected]cd9c65e2014-07-10 02:57:0123#include "ui/gfx/font_render_params.h"
[email protected]f57f69012012-06-13 02:52:2124#endif
25
[email protected]dbf75012013-09-24 06:37:2526#if defined(TOOLKIT_VIEWS)
27#include "ui/views/controls/textfield/textfield.h"
[email protected]7bd129f2012-11-30 02:06:0128#endif
29
ellyjonesd0fd7b12016-08-26 18:26:3630#if defined(OS_MACOSX)
31#include "ui/base/cocoa/defaults_utils.h"
32#endif
33
[email protected]96514e72013-09-25 20:42:2434#if defined(USE_AURA) && defined(OS_LINUX) && !defined(OS_CHROMEOS)
35#include "chrome/browser/themes/theme_service.h"
36#include "chrome/browser/themes/theme_service_factory.h"
37#include "ui/views/linux_ui/linux_ui.h"
38#endif
39
guidouca055a542016-08-11 11:15:5340namespace {
41
42// Parses a string |range| with a port range in the form "<min>-<max>".
43// If |range| is not in the correct format or contains an invalid range, zero
44// is written to |min_port| and |max_port|.
45// TODO(guidou): Consider replacing with remoting/protocol/port_range.cc
46void ParsePortRange(const std::string& range,
47 uint16_t* min_port,
48 uint16_t* max_port) {
49 *min_port = 0;
50 *max_port = 0;
51
52 if (range.empty())
53 return;
54
55 size_t separator_index = range.find('-');
56 if (separator_index == std::string::npos)
57 return;
58
59 std::string min_port_string, max_port_string;
60 base::TrimWhitespaceASCII(range.substr(0, separator_index), base::TRIM_ALL,
61 &min_port_string);
62 base::TrimWhitespaceASCII(range.substr(separator_index + 1), base::TRIM_ALL,
63 &max_port_string);
64 unsigned min_port_uint, max_port_uint;
65 if (!base::StringToUint(min_port_string, &min_port_uint) ||
66 !base::StringToUint(max_port_string, &max_port_uint)) {
67 return;
68 }
69 if (min_port_uint == 0 || min_port_uint > max_port_uint ||
70 max_port_uint > UINT16_MAX) {
71 return;
72 }
73
74 *min_port = static_cast<uint16_t>(min_port_uint);
75 *max_port = static_cast<uint16_t>(max_port_uint);
76}
77
78} // namespace
79
[email protected]93623c5d2009-12-10 21:40:3280namespace renderer_preferences_util {
81
wjmacleane530aa742014-10-14 21:43:3082void UpdateFromSystemSettings(content::RendererPreferences* prefs,
Kenichi Ishibashif522ac42018-07-12 23:16:4683 Profile* profile) {
[email protected]f57f69012012-06-13 02:52:2184 const PrefService* pref_service = profile->GetPrefs();
[email protected]9982c802013-06-12 15:22:0685 prefs->accept_languages = pref_service->GetString(prefs::kAcceptLanguages);
[email protected]f57f69012012-06-13 02:52:2186 prefs->enable_referrers = pref_service->GetBoolean(prefs::kEnableReferrers);
[email protected]498bc512012-09-21 21:50:0887 prefs->enable_do_not_track =
88 pref_service->GetBoolean(prefs::kEnableDoNotTrack);
Xiaohan Wang2ec4a6832017-11-15 00:55:51