void WebContents::HandleNewRenderFrame(
    content::RenderFrameHost* render_frame_host) {
  auto* rwhv = render_frame_host->GetView();
  if (!rwhv)
    return;

  // Set the background color of RenderWidgetHostView.
  auto* web_preferences = WebContentsPreferences::From(web_contents());
  if (web_preferences) {
    std::string color_name;
    if (web_preferences->GetPreference(options::kBackgroundColor,
                                       &color_name)) {
      web_contents()->SetPageBaseBackgroundColor(ParseHexColor(color_name));
    } else {
      bool guest = IsGuest() || type_ == Type::kBrowserView;
      web_contents()->SetPageBaseBackgroundColor(
          guest ? absl::make_optional(SK_ColorTRANSPARENT) : absl::nullopt);
    }

    // When a page base background color is set, transparency needs to be
    // explicitly set by calling
    // RenderWidgetHostOwnerDelegate::SetBackgroundOpaque(false).
    // RenderWidgetHostViewBase::SetBackgroundColor() will do this for us.
    if (web_preferences->IsEnabled(options::kTransparent) || IsGuest()) {
      rwhv->SetBackgroundColor(SK_ColorTRANSPARENT);
    }
  }

  if (!background_throttling_)
    render_frame_host->GetRenderViewHost()->SetSchedulerThrottling(false);

  auto* rwh_impl =
      static_cast<content::RenderWidgetHostImpl*>(rwhv->GetRenderWidgetHost());
  if (rwh_impl)
    rwh_impl->disable_hidden_ = !background_throttling_;

  auto* web_frame = WebFrameMain::FromRenderFrameHost(render_frame_host);
  if (web_frame)
    web_frame->Connect();
}
void WebContents::HandleNewRenderFrame(
    content::RenderFrameHost* render_frame_host) {
  auto* rwhv = render_frame_host->GetView();
  if (!rwhv)
    return;

   
  auto* web_preferences = WebContentsPreferences::From(web_contents());
  if (web_preferences) {
    std::string color_name;
    if (web_preferences->GetPreference(options::kBackgroundColor,
                                       &color_name)) {
      web_contents()->SetPageBaseBackgroundColor(ParseHexColor(color_name));
    } else {
      bool guest = IsGuest() || type_ == Type::kBrowserView;
      web_contents()->SetPageBaseBackgroundColor(
          guest ? absl::make_optional(SK_ColorTRANSPARENT) : absl::nullopt);
    }

     
     
     
     
    if (web_preferences->IsEnabled(options::kTransparent) || IsGuest()) {
      rwhv->SetBackgroundColor(SK_ColorTRANSPARENT);
    }
  }

  if (!background_throttling_)
    render_frame_host->GetRenderViewHost()->SetSchedulerThrottling(false);

  auto* rwh_impl =
      static_cast<content::RenderWidgetHostImpl*>(rwhv->GetRenderWidgetHost());
  if (rwh_impl)
    rwh_impl->disable_hidden_ = !background_throttling_;

  auto* web_frame = WebFrameMain::FromRenderFrameHost(render_frame_host);
  if (web_frame)
    web_frame->Connect();
}