2014-10-31 18:17:05 +00:00
|
|
|
// Copyright (c) 2013 GitHub, Inc.
|
2014-04-25 09:49:37 +00:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2013-04-29 12:41:11 +00:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_COMMON_PLATFORM_UTIL_H_
|
|
|
|
#define ELECTRON_SHELL_COMMON_PLATFORM_UTIL_H_
|
2013-04-29 12:41:11 +00:00
|
|
|
|
2016-11-17 02:22:09 +00:00
|
|
|
#include <string>
|
|
|
|
|
2018-10-10 20:46:54 +00:00
|
|
|
#include "base/files/file_path.h"
|
2023-02-03 11:43:42 +00:00
|
|
|
#include "base/functional/callback_forward.h"
|
2016-10-14 19:38:55 +00:00
|
|
|
#include "build/build_config.h"
|
2016-07-11 08:11:05 +00:00
|
|
|
|
2013-04-29 12:41:11 +00:00
|
|
|
class GURL;
|
|
|
|
|
|
|
|
namespace platform_util {
|
|
|
|
|
2019-11-08 07:08:43 +00:00
|
|
|
typedef base::OnceCallback<void(const std::string&)> OpenCallback;
|
2016-11-17 02:22:09 +00:00
|
|
|
|
2013-04-29 12:41:11 +00:00
|
|
|
// Show the given file in a file manager. If possible, select the file.
|
|
|
|
// Must be called from the UI thread.
|
2019-02-27 12:58:23 +00:00
|
|
|
void ShowItemInFolder(const base::FilePath& full_path);
|
2013-04-29 12:41:11 +00:00
|
|
|
|
|
|
|
// Open the given file in the desktop's default manner.
|
|
|
|
// Must be called from the UI thread.
|
2019-11-08 07:08:43 +00:00
|
|
|
void OpenPath(const base::FilePath& full_path, OpenCallback callback);
|
2013-04-29 12:41:11 +00:00
|
|
|
|
2018-10-10 20:46:54 +00:00
|
|
|
struct OpenExternalOptions {
|
|
|
|
bool activate = true;
|
|
|
|
base::FilePath working_dir;
|
2023-02-14 08:53:18 +00:00
|
|
|
bool log_usage = false;
|
2018-10-10 20:46:54 +00:00
|
|
|
};
|
|
|
|
|
2013-04-29 12:41:11 +00:00
|
|
|
// Open the given external protocol URL in the desktop's default manner.
|
|
|
|
// (For example, mailto: URLs in the default mail user agent.)
|
2019-05-03 20:53:45 +00:00
|
|
|
void OpenExternal(const GURL& url,
|
|
|
|
const OpenExternalOptions& options,
|
2019-11-08 07:08:43 +00:00
|
|
|
OpenCallback callback);
|
2016-10-13 20:28:11 +00:00
|
|
|
|
2020-09-02 17:32:33 +00:00
|
|
|
// Move a file to trash, asynchronously.
|
|
|
|
void TrashItem(const base::FilePath& full_path,
|
|
|
|
base::OnceCallback<void(bool, const std::string&)> callback);
|
|
|
|
|
2013-04-29 14:10:03 +00:00
|
|
|
void Beep();
|
|
|
|
|
2022-02-10 02:58:52 +00:00
|
|
|
#if BUILDFLAG(IS_WIN)
|
2020-05-13 02:27:56 +00:00
|
|
|
// SHGetFolderPath calls not covered by Chromium
|
|
|
|
bool GetFolderPath(int key, base::FilePath* result);
|
|
|
|
#endif
|
|
|
|
|
2022-02-10 02:58:52 +00:00
|
|
|
#if BUILDFLAG(IS_MAC)
|
2017-10-17 07:28:29 +00:00
|
|
|
bool GetLoginItemEnabled();
|
2018-11-28 04:16:53 +00:00
|
|
|
bool SetLoginItemEnabled(bool enabled);
|
2017-10-17 07:28:29 +00:00
|
|
|
#endif
|
|
|
|
|
2022-02-10 02:58:52 +00:00
|
|
|
#if BUILDFLAG(IS_LINUX)
|
2018-10-19 18:51:43 +00:00
|
|
|
// Returns a success flag.
|
|
|
|
// Unlike libgtkui, does *not* use "chromium-browser.desktop" as a fallback.
|
|
|
|
bool GetDesktopName(std::string* setme);
|
2022-07-11 18:26:18 +00:00
|
|
|
|
|
|
|
// The XDG application ID must match the name of the desktop entry file without
|
|
|
|
// the .desktop extension.
|
|
|
|
std::string GetXdgAppId();
|
2018-10-19 18:51:43 +00:00
|
|
|
#endif
|
|
|
|
|
2013-05-01 07:42:30 +00:00
|
|
|
} // namespace platform_util
|
2013-04-29 12:41:11 +00:00
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_COMMON_PLATFORM_UTIL_H_
|