#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
#include <stddef.h>
#include <stdint.h>
#include <set>
#include <string>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/font_pref_change_notifier_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_preferences_util.h"
#include "chrome/browser/ui/prefs/pref_watcher.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_font_webkit_names.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_names_util.h"
#include "chrome/grit/platform_locale_settings.h"
#include "components/language/core/browser/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/overlay_user_pref_store.h"
#include "components/prefs/pref_service.h"
#include "components/proxy_config/proxy_config_pref_names.h"
#include "components/strings/grit/components_locale_settings.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "extensions/buildflags/buildflags.h"
#include "media/media_buildflags.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/renderer_preferences/renderer_preferences.h"
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
#include "third_party/icu/source/common/unicode/uchar.h"
#include "third_party/icu/source/common/unicode/uscript.h"
#include "ui/base/l10n/l10n_util.h"
#if BUILDFLAG(IS_ANDROID)
#include "chrome/browser/flags/android/chrome_feature_list.h"
#include "components/browser_ui/accessibility/android/font_size_prefs_android.h"
#else
#include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h"
#endif
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_ANDROID)
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#endif
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
#include "ui/gfx/font_list.h"
#endif
WebPreferences;
WebContents;
namespace {
#if !BUILDFLAG(IS_ANDROID)
void RegisterFontFamilyPrefs(user_prefs::PrefRegistrySyncable* registry,
const std::set<std::string>& fonts_with_defaults) { … }
#endif
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
BASE_FEATURE(kPrefsFontList, "PrefsFontList", base::FEATURE_ENABLED_BY_DEFAULT);
#endif
#if BUILDFLAG(IS_WIN)
bool ShouldUseAlternateDefaultFixedFont(const std::string& script) {
if (!base::StartsWith(script, "courier",
base::CompareCase::INSENSITIVE_ASCII))
return false;
UINT smooth_type = 0;
SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &smooth_type, 0);
return smooth_type == FE_FONTSMOOTHINGCLEARTYPE;
}
#endif
struct FontDefault { … };
const FontDefault kFontDefaults[] = …;
const size_t kFontDefaultsLength = …;
UScriptCode GetScriptOfFontPref(const char* pref_name) { … }
UScriptCode GetScriptOfBrowserLocale(const std::string& locale) { … }
void OverrideFontFamily(blink::web_pref::WebPreferences* prefs,
const std::string& generic_family,
const std::string& script,
const std::string& pref_value) { … }
#if !BUILDFLAG(IS_ANDROID)
void RegisterLocalizedFontPref(user_prefs::PrefRegistrySyncable* registry,
const char* path,
int default_message_id) { … }
#endif
}
PrefsTabHelper::PrefsTabHelper(WebContents* contents)
: … { … }
PrefsTabHelper::~PrefsTabHelper() { … }
void PrefsTabHelper::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry,
const std::string& locale) { … }
void PrefsTabHelper::GetServiceInstance() { … }
void PrefsTabHelper::OnThemeChanged() { … }
void PrefsTabHelper::UpdateWebPreferences() { … }
void PrefsTabHelper::UpdateRendererPreferences() { … }
void PrefsTabHelper::OnFontFamilyPrefChanged(const std::string& pref_name) { … }
void PrefsTabHelper::OnWebPrefChanged(const std::string& pref_name) { … }
void PrefsTabHelper::NotifyWebkitPreferencesChanged(
const std::string& pref_name) { … }
WEB_CONTENTS_USER_DATA_KEY_IMPL(PrefsTabHelper);