2014-10-31 11:17:05 -07:00
|
|
|
// Copyright (c) 2013 GitHub, Inc.
|
2014-04-25 17:49:37 +08:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2013-04-29 20:41:11 +08:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2019-06-19 13:56:58 -07:00
|
|
|
#ifndef SHELL_COMMON_PLATFORM_UTIL_H_
|
|
|
|
#define SHELL_COMMON_PLATFORM_UTIL_H_
|
2013-04-29 20:41:11 +08:00
|
|
|
|
2016-11-17 11:22:09 +09:00
|
|
|
#include <string>
|
|
|
|
|
2016-10-13 13:28:11 -07:00
|
|
|
#include "base/callback_forward.h"
|
2018-10-10 22:46:54 +02:00
|
|
|
#include "base/files/file_path.h"
|
2016-10-14 12:38:55 -07:00
|
|
|
#include "build/build_config.h"
|
2016-07-11 17:11:05 +09:00
|
|
|
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
#include "base/strings/string16.h"
|
|
|
|
#endif
|
|
|
|
|
2013-04-29 20:41:11 +08:00
|
|
|
class GURL;
|
|
|
|
|
|
|
|
namespace platform_util {
|
|
|
|
|
2019-02-21 12:32:44 +00:00
|
|
|
typedef base::OnceCallback<void(const std::string&)> OpenExternalCallback;
|
2016-11-17 11:22:09 +09:00
|
|
|
|
2013-04-29 20:41:11 +08: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 20:41:11 +08:00
|
|
|
|
|
|
|
// Open the given file in the desktop's default manner.
|
|
|
|
// Must be called from the UI thread.
|
2016-09-12 14:29:06 -07:00
|
|
|
bool OpenItem(const base::FilePath& full_path);
|
2013-04-29 20:41:11 +08:00
|
|
|
|
2018-10-10 22:46:54 +02:00
|
|
|
struct OpenExternalOptions {
|
|
|
|
bool activate = true;
|
|
|
|
base::FilePath working_dir;
|
|
|
|
};
|
|
|
|
|
2013-04-29 20:41:11 +08: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 13:53:45 -07:00
|
|
|
void OpenExternal(const GURL& url,
|
|
|
|
const OpenExternalOptions& options,
|
|
|
|
OpenExternalCallback callback);
|
2016-10-13 13:28:11 -07:00
|
|
|
|
2013-04-29 21:57:05 +08:00
|
|
|
// Move a file to trash.
|
2015-03-27 18:31:57 +05:30
|
|
|
bool MoveItemToTrash(const base::FilePath& full_path);
|
2013-04-29 21:57:05 +08:00
|
|
|
|
2013-04-29 22:10:03 +08:00
|
|
|
void Beep();
|
|
|
|
|
2017-10-17 16:28:29 +09:00
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
bool GetLoginItemEnabled();
|
2018-11-27 23:16:53 -05:00
|
|
|
bool SetLoginItemEnabled(bool enabled);
|
2017-10-17 16:28:29 +09:00
|
|
|
#endif
|
|
|
|
|
2018-10-19 20:51:43 +02: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 15:42:30 +08:00
|
|
|
} // namespace platform_util
|
2013-04-29 20:41:11 +08:00
|
|
|
|
2019-06-19 13:56:58 -07:00
|
|
|
#endif // SHELL_COMMON_PLATFORM_UTIL_H_
|