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.
|
|
|
|
|
|
|
|
#ifndef ATOM_COMMON_PLATFORM_UTIL_H_
|
|
|
|
#define ATOM_COMMON_PLATFORM_UTIL_H_
|
|
|
|
|
2016-11-17 02:22:09 +00:00
|
|
|
#include <string>
|
|
|
|
|
2016-10-13 20:28:11 +00:00
|
|
|
#include "base/callback_forward.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 base {
|
|
|
|
class FilePath;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace platform_util {
|
|
|
|
|
2016-11-17 02:22:09 +00:00
|
|
|
typedef base::Callback<void(const std::string&)> OpenExternalCallback;
|
|
|
|
|
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.
|
2016-09-12 21:22:29 +00:00
|
|
|
bool 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.
|
2016-09-12 21:29:06 +00:00
|
|
|
bool OpenItem(const base::FilePath& full_path);
|
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.)
|
2016-07-11 08:11:05 +00:00
|
|
|
bool OpenExternal(
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
const base::string16& url,
|
|
|
|
#else
|
|
|
|
const GURL& url,
|
|
|
|
#endif
|
|
|
|
bool activate);
|
2013-04-29 12:41:11 +00:00
|
|
|
|
2016-11-17 02:22:09 +00:00
|
|
|
// The asynchronous version of OpenExternal.
|
2016-11-02 23:20:26 +00:00
|
|
|
void OpenExternal(
|
2016-10-13 20:28:11 +00:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
const base::string16& url,
|
|
|
|
#else
|
|
|
|
const GURL& url,
|
|
|
|
#endif
|
|
|
|
bool activate,
|
|
|
|
const OpenExternalCallback& callback);
|
|
|
|
|
2013-04-29 13:57:05 +00:00
|
|
|
// Move a file to trash.
|
2015-03-27 13:01:57 +00:00
|
|
|
bool MoveItemToTrash(const base::FilePath& full_path);
|
2013-04-29 13:57:05 +00:00
|
|
|
|
2013-04-29 14:10:03 +00:00
|
|
|
void Beep();
|
|
|
|
|
2017-10-17 07:28:29 +00:00
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
bool GetLoginItemEnabled();
|
|
|
|
void SetLoginItemEnabled(bool enabled);
|
|
|
|
#endif
|
|
|
|
|
2013-05-01 07:42:30 +00:00
|
|
|
} // namespace platform_util
|
2013-04-29 12:41:11 +00:00
|
|
|
|
|
|
|
#endif // ATOM_COMMON_PLATFORM_UTIL_H_
|