Repository: electron/electron
File: shell/browser/ui/tray_icon_linux.cc (C++)

Code before:
#include "ui/gfx/image/image_skia_rep.h"

namespace electron {

namespace {

gfx::ImageSkia GetBestImageRep(const gfx::ImageSkia& image) {
  image.EnsureRepsForSupportedScales();
  float best_scale = 0.0f;
  SkBitmap best_rep;
  for (const auto& rep : image.image_reps()) {
    if (rep.scale() > best_scale) {
      best_scale = rep.scale();
      best_rep = rep.GetBitmap();
    }
  }
  // All status icon implementations want the image in pixel coordinates, so use
  // a scale factor of 1.
  return gfx::ImageSkia::CreateFromBitmap(best_rep, 1.0f);
}

}  // namespace

TrayIconLinux::TrayIconLinux()
    : status_icon_dbus_(
          new StatusIconLinuxDbus(Browser::Get()->GetName().c_str())),
      status_icon_type_(StatusIconType::kDbus) {
  status_icon_dbus_->SetDelegate(this);
}

TrayIconLinux::~TrayIconLinux() = default;

void TrayIconLinux::SetImage(const gfx::Image& image) {
  image_ = GetBestImageRep(image.AsImageSkia());
  if (auto* status_icon = GetStatusIcon())
    status_icon->SetImage(image_);
}

void TrayIconLinux::SetToolTip(const std::string& tool_tip) {
  tool_tip_ = base::UTF8ToUTF16(tool_tip);
  if (auto* status_icon = GetStatusIcon())
    status_icon->SetToolTip(tool_tip_);
}

void TrayIconLinux::SetContextMenu(raw_ptr<ElectronMenuModel> menu_model) {
  menu_model_ = menu_model;
  if (auto* status_icon = GetStatusIcon())
    status_icon->UpdatePlatformContextMenu(menu_model_);
}

const gfx::ImageSkia& TrayIconLinux::GetImage() const {

Review comment (suggestion):
_nit_: The `c_str()` call appears to be unnecessary? 

```suggestion
          new StatusIconLinuxDbus(Browser::Get()->GetName())),
```

Code after:
#include "ui/gfx/image/image_skia_rep.h"

namespace electron {

namespace {

gfx::ImageSkia GetBestImageRep(const gfx::ImageSkia& image) {
  image.EnsureRepsForSupportedScales();
  float best_scale = 0.0f;
  SkBitmap best_rep;
  for (const auto& rep : image.image_reps()) {
    if (rep.scale() > best_scale) {
      best_scale = rep.scale();
      best_rep = rep.GetBitmap();
    }
  }
  // All status icon implementations want the image in pixel coordinates, so use
  // a scale factor of 1.
  return gfx::ImageSkia::CreateFromBitmap(best_rep, 1.0f);
}

}  // namespace

TrayIconLinux::TrayIconLinux()
    : status_icon_dbus_(new StatusIconLinuxDbus(Browser::Get()->GetName())),
      status_icon_type_(StatusIconType::kDbus) {
  status_icon_dbus_->SetDelegate(this);
}

TrayIconLinux::~TrayIconLinux() = default;

void TrayIconLinux::SetImage(const gfx::Image& image) {
  image_ = GetBestImageRep(image.AsImageSkia());
  if (auto* status_icon = GetStatusIcon())
    status_icon->SetImage(image_);
}

void TrayIconLinux::SetToolTip(const std::string& tool_tip) {
  tool_tip_ = base::UTF8ToUTF16(tool_tip);
  if (auto* status_icon = GetStatusIcon())
    status_icon->SetToolTip(tool_tip_);
}

void TrayIconLinux::SetContextMenu(raw_ptr<ElectronMenuModel> menu_model) {
  menu_model_ = menu_model;
  if (auto* status_icon = GetStatusIcon())
    status_icon->UpdatePlatformContextMenu(menu_model_);
}

const gfx::ImageSkia& TrayIconLinux::GetImage() const {
  return image_;