electron/shell/common/application_info_linux.cc
electron-roller[bot] f2240e07f0
chore: bump chromium to 137.0.7149.0 (main) (#46777)
* chore: bump chromium in DEPS to 137.0.7144.0

* chore: bump chromium in DEPS to 137.0.7145.0

* chore: bump chromium in DEPS to 137.0.7147.0

* chore: update patches

* Remove deprecated GetVar(std::string_view, std::string*) overload

Refs 6468873

* fixup! Remove deprecated GetVar(std::string_view, std::string*) overload

* fixup! Remove deprecated GetVar(std::string_view, std::string*) overload

* chore: bump chromium in DEPS to 137.0.7149.0

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
2025-04-28 11:39:12 -04:00

75 lines
1.7 KiB
C++

// Copyright (c) 2013 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/common/application_info.h"
#include <gio/gdesktopappinfo.h>
#include <gio/gio.h>
#include <string>
#include "base/logging.h"
#include "electron/electron_version.h"
#include "shell/common/platform_util.h"
namespace {
GDesktopAppInfo* get_desktop_app_info() {
GDesktopAppInfo* ret = nullptr;
if (std::optional<std::string> desktop_id = platform_util::GetDesktopName())
ret = g_desktop_app_info_new(desktop_id->c_str());
return ret;
}
} // namespace
namespace electron {
std::string GetApplicationName() {
// attempt #1: the string set in app.setName()
std::string ret = OverriddenApplicationName();
// attempt #2: the 'Name' entry from .desktop file's [Desktop] section
if (ret.empty()) {
GDesktopAppInfo* info = get_desktop_app_info();
if (info != nullptr) {
char* str = g_desktop_app_info_get_string(info, "Name");
g_clear_object(&info);
if (str != nullptr)
ret = str;
g_clear_pointer(&str, g_free);
}
}
// attempt #3: Electron's name
if (ret.empty()) {
ret = ELECTRON_PRODUCT_NAME;
}
return ret;
}
std::string GetApplicationVersion() {
std::string ret;
// ensure ELECTRON_PRODUCT_NAME and GetApplicationVersion match up
if (GetApplicationName() == ELECTRON_PRODUCT_NAME)
ret = ELECTRON_VERSION_STRING;
// try to use the string set in app.setVersion()
if (ret.empty())
ret = OverriddenApplicationVersion();
// no known version number; return some safe fallback
if (ret.empty()) {
LOG(WARNING) << "No version found. Was app.setVersion() called?";
ret = "0.0";
}
return ret;
}
} // namespace electron