Repository: electron/electron
File: shell/browser/api/electron_api_browser_window.cc (C++)

Code before:
  else
    BaseWindow::Blur();
}

void BrowserWindow::SetBackgroundColor(const std::string& color_name) {
  BaseWindow::SetBackgroundColor(color_name);
  SkColor color = ParseCSSColor(color_name).value_or(SK_ColorWHITE);
  if (api_web_contents_) {
    api_web_contents_->SetBackgroundColor(color);
    // Also update the web preferences object otherwise the view will be reset
    // on the next load URL call
    auto* web_preferences =
        WebContentsPreferences::From(api_web_contents_->web_contents());
    if (web_preferences) {
      web_preferences->SetBackgroundColor(color);
    }
  }
}

void BrowserWindow::SetBackgroundMaterial(const std::string& material) {
  BaseWindow::SetBackgroundMaterial(material);
  const char* const materialTypes[] = {
      "tabbed",
      "mica",
      "acrylic",
  };

  if (base::Contains(materialTypes, material)) {
    SetBackgroundColor(ToRGBAHex(SK_ColorTRANSPARENT));
  } else if (material == "none") {
    SetBackgroundColor(ToRGBAHex(SK_ColorWHITE));
  }
}

void BrowserWindow::FocusOnWebView() {
  web_contents()->GetRenderViewHost()->GetWidget()->Focus();
}

void BrowserWindow::BlurWebView() {
  web_contents()->GetRenderViewHost()->GetWidget()->Blur();
}

bool BrowserWindow::IsWebViewFocused() {
  auto* host_view = web_contents()->GetRenderViewHost()->GetWidget()->GetView();
  return host_view && host_view->HasFocus();
}

v8::Local<v8::Value> BrowserWindow::GetWebContents(v8::Isolate* isolate) {
  if (web_contents_.IsEmpty())
    return v8::Null(isolate);
  return v8::Local<v8::Value>::New(isolate, web_contents_);

Review comment (suggestion):
```suggestion
  static constexpr auto materialTypes = base::MakeFixedFlatSet<std::string_view>(
        {"tabbed", "mica", "acrylic"});
  if (materialTypes.contains(material)) {
```

Code after:
    BlurWebView();
  else
    BaseWindow::Blur();
}

void BrowserWindow::SetBackgroundColor(const std::string& color_name) {
  BaseWindow::SetBackgroundColor(color_name);
  SkColor color = ParseCSSColor(color_name).value_or(SK_ColorWHITE);
  if (api_web_contents_) {
    api_web_contents_->SetBackgroundColor(color);
    // Also update the web preferences object otherwise the view will be reset
    // on the next load URL call
    auto* web_preferences =
        WebContentsPreferences::From(api_web_contents_->web_contents());
    if (web_preferences) {
      web_preferences->SetBackgroundColor(color);
    }
  }
}

void BrowserWindow::SetBackgroundMaterial(const std::string& material) {
  BaseWindow::SetBackgroundMaterial(material);
  static constexpr auto materialTypes =
      base::MakeFixedFlatSet<std::string_view>({"tabbed", "mica", "acrylic"});

  if (materialTypes.contains(material)) {
    SetBackgroundColor(ToRGBAHex(SK_ColorTRANSPARENT));
  } else if (material == "none") {
    SetBackgroundColor(ToRGBAHex(SK_ColorWHITE));
  }
}

void BrowserWindow::FocusOnWebView() {
  web_contents()->GetRenderViewHost()->GetWidget()->Focus();
}

void BrowserWindow::BlurWebView() {
  web_contents()->GetRenderViewHost()->GetWidget()->Blur();
}

bool BrowserWindow::IsWebViewFocused() {
  auto* host_view = web_contents()->GetRenderViewHost()->GetWidget()->GetView();
  return host_view && host_view->HasFocus();
}

v8::Local<v8::Value> BrowserWindow::GetWebContents(v8::Isolate* isolate) {
  if (web_contents_.IsEmpty())
    return v8::Null(isolate);
  return v8::Local<v8::Value>::New(isolate, web_contents_);
}