blob: e6c3a05e3c51f5a07c3438ebd49d1eb65769b6b9 [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2012 The Chromium Authors
[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
Adam Rice3d178a82021-04-12 13:49:537#include <stdint.h>
8
guidouca055a542016-08-11 11:15:539#include <string>
Adam Rice3d178a82021-04-12 13:49:5310#include <vector>
guidouca055a542016-08-11 11:15:5311
Guido Urdanetafdaf45e2024-12-17 20:47:2912#include "base/logging.h"
guidouca055a542016-08-11 11:15:5313#include "base/strings/string_number_conversions.h"
14#include "base/strings/string_util.h"
avib896c712015-12-26 02:10:4315#include "build/build_config.h"
Yuta Hijikata235fc62b2020-12-08 03:48:3216#include "build/chromeos_buildflags.h"
John Abd-El-Malek7d032b372019-05-07 18:01:3117#include "chrome/browser/browser_process.h"
Adam Rice3d178a82021-04-12 13:49:5318#include "chrome/browser/net/convert_explicitly_allowed_network_ports_pref.h"
Fiona Macintoshafa01d22023-09-18 12:55:4919#include "chrome/browser/privacy_sandbox/tracking_protection_settings_factory.h"
Yves Arrouye39b8ef62021-02-23 00:39:2920#if BUILDFLAG(IS_CHROMEOS_ASH)
Henrique Ferreiro606669a2021-02-24 13:36:5521#include "chrome/browser/ash/login/demo_mode/demo_session.h"
Yves Arrouye39b8ef62021-02-23 00:39:2922#endif
[email protected]8ecad5e2010-12-02 21:18:3323#include "chrome/browser/profiles/profile.h"
[email protected]0a8db0d2011-04-13 15:15:4024#include "chrome/common/pref_names.h"
Friedrich Horschig91c02102025-01-10 13:45:5825#include "components/autofill/core/common/autofill_prefs.h"
Trevor Perrierfa7339d2020-09-11 00:42:4026#include "components/language/core/browser/language_prefs.h"
Alexandre Frechette572755b2019-02-13 22:30:2027#include "components/language/core/browser/pref_names.h"
brettwb1fc1b82016-02-02 00:19:0828#include "components/prefs/pref_service.h"
Fiona Macintoshafa01d22023-09-18 12:55:4929#include "components/privacy_sandbox/tracking_protection_settings.h"
Ian Vollick0c34a072019-02-15 03:40:2730#include "content/public/browser/renderer_preferences_util.h"
Scott Violeta35f9a42018-03-22 22:00:4431#include "media/media_buildflags.h"
Antonio Gomesb5bf548f2019-09-12 17:40:1532#include "third_party/blink/public/common/peerconnection/webrtc_ip_handling_policy.h"
Mario Sanchez Prada0bd8b8c2020-10-21 17:49:2333#include "third_party/blink/public/common/renderer_preferences/renderer_preferences.h"
Guido Urdanetad8bfc6f92024-12-11 14:01:2234#include "third_party/blink/public/mojom/peerconnection/webrtc_ip_handling_policy.mojom.h"
Blink Reformata30d4232018-04-07 15:31:0635#include "third_party/blink/public/public_buildflags.h"
[email protected]38a85712013-01-02 22:45:0236#include "third_party/skia/include/core/SkColor.h"
Jacques Newman58690f2c2024-04-30 20:47:0337#include "ui/accessibility/platform/ax_platform.h"
Ionel Popescu2649f2f2020-01-10 10:06:5938#include "ui/base/ui_base_features.h"
[email protected]93623c5d2009-12-10 21:40:3239
[email protected]dbf75012013-09-24 06:37:2540#if defined(TOOLKIT_VIEWS)
41#include "ui/views/controls/textfield/textfield.h"
[email protected]7bd129f2012-11-30 02:06:0142#endif
43
Tom Anderson4ee83742022-07-14 20:58:4144#if defined(USE_AURA) && BUILDFLAG(IS_LINUX)
[email protected]96514e72013-09-25 20:42:2445#include "chrome/browser/themes/theme_service.h"
46#include "chrome/browser/themes/theme_service_factory.h"
Tom Anderson4ee83742022-07-14 20:58:4147#include "ui/linux/linux_ui.h"
[email protected]96514e72013-09-25 20:42:2448#endif
49
guidouca055a542016-08-11 11:15:5350namespace {
51
52// Parses a string |range| with a port range in the form "<min>-<max>".
53// If |range| is not in the correct format or contains an invalid range, zero
54// is written to |min_port| and |max_port|.
55// TODO(guidou): Consider replacing with remoting/protocol/port_range.cc
56void ParsePortRange(const std::string& range,
57 uint16_t* min_port,
58 uint16_t* max_port) {
59 *min_port = 0;
60 *max_port = 0;
61
62 if (range.empty())
63 return;
64
65 size_t separator_index = range.find('-');
66 if (separator_index == std::string::npos)
67 return;
68
69 std::string min_port_string, max_port_string;
70 base::TrimWhitespaceASCII(range.substr(0, separator_index), base::TRIM_ALL,
71 &min_port_string);
72 base::TrimWhitespaceASCII(range.substr(separator_index + 1), base::TRIM_ALL,
73 &max_port_string);
74 unsigned min_port_uint, max_port_uint;