electron/shell/common/application_info_linux.cc
Electron Bot 2b53788c35
chore: bump chromium to 4b6692e4cc2839729bb7ac009586a (master) (#21864)
* chore: bump chromium in DEPS to a1ea0d7aedd6b5fe58fbabfa3b05aa8ee41304ff

* update patches

* update extensions code

* Remove WebPoint

https://chromium-review.googlesource.com/c/chromium/src/+/2007474

* fix build

* chore: bump chromium in DEPS to 9351e26c2a3714f8bbb10789c71bb51b0b494c75

* update patches

* Remove error description from the DidFailLoadWithError message

https://chromium-review.googlesource.com/c/chromium/src/+/2011280

* Make SimpleNetworkHintsHandlerImpl use the right NetworkIsolationKey

https://chromium-review.googlesource.com/c/chromium/src/+/1994430

* Rename libgtkui to gtk

https://chromium-review.googlesource.com/c/chromium/src/+/2011683

* [metrics] Remove histogram Startup.WarmStartTimeFromRemoteProcessStart*.

https://chromium-review.googlesource.com/c/chromium/src/+/2003211

* fix requestSingleInstanceLock test

* chore: bump chromium in DEPS to a813567a4f17ea08292c2b26fa10d0ffd47010d9

* chore: bump chromium in DEPS to f0aca2de536ceecd6eb66e928051d11e6d11991f

* chore: bump chromium in DEPS to 865556af6d0c9d990f5b1816cb792f7c3859667b

* chore: bump chromium in DEPS to 98538fdd28c4b6692e4cc2839729bb7ac009586a

* update patches

* fix broken tests

* Update node tests for v8 changes

* Update node patches for test failures

* Update for number of tests

Co-authored-by: Jeremy Apthorp <nornagon@nornagon.net>
Co-authored-by: John Kleinschmidt <jkleinsc@github.com>
2020-01-29 07:01:37 -05:00

79 lines
1.8 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 <memory>
#include <string>
#include "base/environment.h"
#include "base/logging.h"
#include "chrome/browser/ui/gtk/gtk_util.h"
#include "electron/electron_version.h"
#include "shell/common/platform_util.h"
namespace {
GDesktopAppInfo* get_desktop_app_info() {
GDesktopAppInfo* ret = nullptr;
std::string desktop_id;
if (platform_util::GetDesktopName(&desktop_id))
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 = GetOverriddenApplicationName();
// 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 = GetOverriddenApplicationVersion();
// 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