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.
|
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#ifndef SHELL_COMMON_PLATFORM_UTIL_H_
|
|
|
|
#define SHELL_COMMON_PLATFORM_UTIL_H_
|
2013-04-29 12:41:11 +00:00
|
|
|
|
2016-11-17 02:22:09 +00:00
|
|
|
#include <string>
|
|
|
|
|
2016-10-13 20:28:11 +00:00
|
|
|
#include "base/callback_forward.h"
|
2018-10-10 20:46:54 +00:00
|
|
|
#include "base/files/file_path.h"
|
2016-10-14 19:38:55 +00:00
|
|
|
#include "build/build_config.h"
|
2016-07-11 08:11:05 +00:00
|
|
|
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
#include "base/strings/string16.h"
|
|
|
|
#endif
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
2013-04-29 13:57:05 +00:00
|
|
|
// Move a file to trash.
|
2019-08-13 19:31:53 +00:00
|
|
|
bool MoveItemToTrash(const base::FilePath& full_path, bool delete_on_fail);
|
2013-04-29 13:57:05 +00:00
|
|
|
|
2013-04-29 14:10:03 +00:00
|
|
|
void Beep();
|
|
|
|
|
2020-05-13 02:27:56 +00:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
// SHGetFolderPath calls not covered by Chromium
|
|
|
|
bool GetFolderPath(int key, base::FilePath* result);
|
|
|
|
#endif
|
|
|
|
|
2020-08-12 18:33:58 +00:00
|
|
|
#if defined(OS_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
|
|
|
|
|
2018-10-19 18:51:43 +00:00
|
|
|
#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
|
|
|
|
|
2013-05-01 07:42:30 +00:00
|
|
|
} // namespace platform_util
|
2013-04-29 12:41:11 +00:00
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#endif // SHELL_COMMON_PLATFORM_UTIL_H_
|