void WebContentsPreferences::OverrideWebkitPrefs()

in shell/browser/web_contents_preferences.cc [430:515]


void WebContentsPreferences::OverrideWebkitPrefs(
    blink::web_pref::WebPreferences* prefs) {
  prefs->javascript_enabled = javascript_;
  prefs->images_enabled = images_;
  prefs->animation_policy = image_animation_policy_;
  prefs->text_areas_are_resizable = text_areas_are_resizable_;
  prefs->navigate_on_drag_drop = navigate_on_drag_drop_;
  prefs->autoplay_policy = autoplay_policy_;

  // Check if webgl should be enabled.
  prefs->webgl1_enabled = webgl_;
  prefs->webgl2_enabled = webgl_;

  // Check if web security should be enabled.
  prefs->web_security_enabled = web_security_;
  prefs->allow_running_insecure_content = allow_running_insecure_content_;

  if (auto font =
          default_font_family_.find("standard") != default_font_family_.end())
    prefs->standard_font_family_map[blink::web_pref::kCommonScript] = font;
  if (auto font =
          default_font_family_.find("serif") != default_font_family_.end())
    prefs->serif_font_family_map[blink::web_pref::kCommonScript] = font;
  if (auto font =
          default_font_family_.find("sansSerif") != default_font_family_.end())
    prefs->sans_serif_font_family_map[blink::web_pref::kCommonScript] = font;
  if (auto font =
          default_font_family_.find("monospace") != default_font_family_.end())
    prefs->fixed_font_family_map[blink::web_pref::kCommonScript] = font;
  if (auto font =
          default_font_family_.find("cursive") != default_font_family_.end())
    prefs->cursive_font_family_map[blink::web_pref::kCommonScript] = font;
  if (auto font =
          default_font_family_.find("fantasy") != default_font_family_.end())
    prefs->fantasy_font_family_map[blink::web_pref::kCommonScript] = font;

  if (default_font_size_)
    prefs->default_font_size = *default_font_size_;
  if (default_monospace_font_size_)
    prefs->default_fixed_font_size = *default_monospace_font_size_;
  if (minimum_font_size_)
    prefs->minimum_font_size = *minimum_font_size_;
  if (default_encoding_)
    prefs->default_encoding = *default_encoding_;

  // Run Electron APIs and preload script in isolated world
  prefs->context_isolation = context_isolation_;
  prefs->is_webview = is_webview_;

  prefs->hidden_page = false;
  // Webview `document.visibilityState` tracks window visibility so we need
  // to let it know if the window happens to be hidden right now.
  if (auto* api_web_contents = api::WebContents::From(web_contents_)) {
    if (electron::api::WebContents* embedder = api_web_contents->embedder()) {
      if (auto* relay =
              NativeWindowRelay::FromWebContents(embedder->web_contents())) {
        if (auto* window = relay->GetNativeWindow()) {
          const bool visible = window->IsVisible() && !window->IsMinimized();
          if (!visible) {
            prefs->hidden_page = true;
          }
        }
      }
    }
  }

  prefs->offscreen = offscreen_;

  // The preload script.
  if (preload_path_)
    prefs->preload = *preload_path_;

  prefs->node_integration = node_integration_;
  prefs->node_integration_in_worker = node_integration_in_worker_;
  prefs->node_integration_in_sub_frames = node_integration_in_sub_frames_;

#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
  prefs->enable_spellcheck = spellcheck_;
#endif

  prefs->enable_plugins = plugins_;
  prefs->webview_tag = webview_tag_;
  prefs->enable_websql = enable_websql_;

  prefs->v8_cache_options = v8_cache_options_;
}