refactor: move media/net from brightray to atom (#15288)

This commit is contained in:
Milan Burda 2018-10-19 20:51:43 +02:00 committed by John Kleinschmidt
parent 6f3c46cc7e
commit 6d844a0b67
32 changed files with 108 additions and 152 deletions

View file

@ -11,9 +11,9 @@
#include <string>
#include "atom/common/atom_version.h"
#include "atom/common/platform_util.h"
#include "base/environment.h"
#include "base/logging.h"
#include "brightray/common/platform_util.h"
#include "chrome/browser/ui/libgtkui/gtk_util.h"
namespace {
@ -22,7 +22,7 @@ GDesktopAppInfo* get_desktop_app_info() {
GDesktopAppInfo* ret = nullptr;
std::string desktop_id;
if (brightray::platform_util::GetDesktopName(&desktop_id))
if (platform_util::GetDesktopName(&desktop_id))
ret = g_desktop_app_info_new(desktop_id.c_str());
return ret;

View file

@ -64,6 +64,12 @@ bool GetLoginItemEnabled();
void SetLoginItemEnabled(bool enabled);
#endif
#if defined(OS_LINUX)
// Returns a success flag.
// Unlike libgtkui, does *not* use "chromium-browser.desktop" as a fallback.
bool GetDesktopName(std::string* setme);
#endif
} // namespace platform_util
#endif // ATOM_COMMON_PLATFORM_UTIL_H_

View file

@ -12,6 +12,7 @@
#include "base/nix/xdg_util.h"
#include "base/process/kill.h"
#include "base/process/launch.h"
#include "chrome/browser/ui/libgtkui/gtk_util.h"
#include "url/gurl.h"
#define ELECTRON_TRASH "ELECTRON_TRASH"
@ -145,4 +146,18 @@ void Beep() {
fclose(console);
}
bool GetDesktopName(std::string* setme) {
bool found = false;
std::unique_ptr<base::Environment> env(base::Environment::Create());
std::string desktop_id = libgtkui::GetDesktopName(env.get());
constexpr char const* libcc_default_id = "chromium-browser.desktop";
if (!desktop_id.empty() && (desktop_id != libcc_default_id)) {
*setme = desktop_id;
found = true;
}
return found;
}
} // namespace platform_util