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