  v8::Local<v8::Value> GetWebPreference(v8::Isolate* isolate,
                                        std::string pref_name) {
    content::RenderFrame* render_frame;
    if (!MaybeGetRenderFrame(isolate, "getWebPreference", &render_frame))
      return v8::Undefined(isolate);

    const auto& prefs = render_frame->GetBlinkPreferences();

    if (pref_name == options::kPreloadScripts) {
      return gin::ConvertToV8(isolate, prefs.preloads);
    } else if (pref_name == "isWebView") {
      // FIXME(zcbenz): For child windows opened with window.open('') from
      // webview, the WebPreferences is inherited from webview and the value
      // of |is_webview| is wrong.
      // Please check ElectronRenderFrameObserver::DidInstallConditionalFeatures
      // for the background.
      auto* web_frame = render_frame->GetWebFrame();
      if (web_frame->Opener())
        return gin::ConvertToV8(isolate, false);
      return gin::ConvertToV8(isolate, prefs.is_webview);
    } else if (pref_name == options::kHiddenPage) {
      // NOTE: hiddenPage is internal-only.
      return gin::ConvertToV8(isolate, prefs.hidden_page);
    } else if (pref_name == options::kOffscreen) {
      return gin::ConvertToV8(isolate, prefs.offscreen);
    } else if (pref_name == options::kPreloadScript) {
      return gin::ConvertToV8(isolate, prefs.preload.value());
    } else if (pref_name == options::kNodeIntegration) {
      return gin::ConvertToV8(isolate, prefs.node_integration);
    } else if (pref_name == options::kNodeIntegrationInWorker) {
      return gin::ConvertToV8(isolate, prefs.node_integration_in_worker);
    } else if (pref_name == options::kNodeIntegrationInSubFrames) {
      return gin::ConvertToV8(isolate, true);
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
    } else if (pref_name == options::kSpellcheck) {
      return gin::ConvertToV8(isolate, prefs.enable_spellcheck);
#endif
    } else if (pref_name == options::kPlugins) {
      return gin::ConvertToV8(isolate, prefs.enable_plugins);
    } else if (pref_name == options::kEnableWebSQL) {
      return gin::ConvertToV8(isolate, prefs.enable_websql);
    } else if (pref_name == options::kWebviewTag) {
      return gin::ConvertToV8(isolate, prefs.webview_tag);
    }
    return v8::Null(isolate);
  }
  v8::Local<v8::Value> GetWebPreference(v8::Isolate* isolate,
                                        std::string pref_name) {
    content::RenderFrame* render_frame;
    if (!MaybeGetRenderFrame(isolate, "getWebPreference", &render_frame))
      return v8::Undefined(isolate);

    const auto& prefs = render_frame->GetBlinkPreferences();

    if (pref_name == options::kPreloadScripts) {
      return gin::ConvertToV8(isolate, prefs.preloads);
    } else if (pref_name == "isWebView") {
       
       
       
       
       
      auto* web_frame = render_frame->GetWebFrame();
      if (web_frame->Opener())
        return gin::ConvertToV8(isolate, false);
      return gin::ConvertToV8(isolate, prefs.is_webview);
    } else if (pref_name == options::kHiddenPage) {
       
      return gin::ConvertToV8(isolate, prefs.hidden_page);
    } else if (pref_name == options::kOffscreen) {
      return gin::ConvertToV8(isolate, prefs.offscreen);
    } else if (pref_name == options::kPreloadScript) {
      return gin::ConvertToV8(isolate, prefs.preload.value());
    } else if (pref_name == options::kNodeIntegration) {
      return gin::ConvertToV8(isolate, prefs.node_integration);
    } else if (pref_name == options::kNodeIntegrationInWorker) {
      return gin::ConvertToV8(isolate, prefs.node_integration_in_worker);
    } else if (pref_name == options::kNodeIntegrationInSubFrames) {
      return gin::ConvertToV8(isolate, true);
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
    } else if (pref_name == options::kSpellcheck) {
      return gin::ConvertToV8(isolate, prefs.enable_spellcheck);
#endif
    } else if (pref_name == options::kPlugins) {
      return gin::ConvertToV8(isolate, prefs.enable_plugins);
    } else if (pref_name == options::kEnableWebSQL) {
      return gin::ConvertToV8(isolate, prefs.enable_websql);
    } else if (pref_name == options::kWebviewTag) {
      return gin::ConvertToV8(isolate, prefs.webview_tag);
    }
    return v8::Null(isolate);
  }