/
platform_util.h
67 lines (49 loc) · 1.91 KB
/
platform_util.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (c) 2013 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ELECTRON_SHELL_COMMON_PLATFORM_UTIL_H_
#define ELECTRON_SHELL_COMMON_PLATFORM_UTIL_H_
#include <string>
#include "base/callback_forward.h"
#include "base/files/file_path.h"
#include "build/build_config.h"
class GURL;
namespace platform_util {
typedef base::OnceCallback<void(const std::string&)> OpenCallback;
// Show the given file in a file manager. If possible, select the file.
// Must be called from the UI thread.
void ShowItemInFolder(const base::FilePath& full_path);
// Open the given file in the desktop's default manner.
// Must be called from the UI thread.
void OpenPath(const base::FilePath& full_path, OpenCallback callback);
struct OpenExternalOptions {
bool activate = true;
base::FilePath working_dir;
};
// Open the given external protocol URL in the desktop's default manner.
// (For example, mailto: URLs in the default mail user agent.)
void OpenExternal(const GURL& url,
const OpenExternalOptions& options,
OpenCallback callback);
// Move a file to trash, asynchronously.
void TrashItem(const base::FilePath& full_path,
base::OnceCallback<void(bool, const std::string&)> callback);
void Beep();
#if BUILDFLAG(IS_WIN)
// SHGetFolderPath calls not covered by Chromium
bool GetFolderPath(int key, base::FilePath* result);
#endif
#if BUILDFLAG(IS_MAC)
bool GetLoginItemEnabled();
bool SetLoginItemEnabled(bool enabled);
#endif
#if BUILDFLAG(IS_LINUX)
// Returns a success flag.
// Unlike libgtkui, does *not* use "chromium-browser.desktop" as a fallback.
bool GetDesktopName(std::string* setme);
// The XDG application ID must match the name of the desktop entry file without
// the .desktop extension.
std::string GetXdgAppId();
#endif
} // namespace platform_util
#endif // ELECTRON_SHELL_COMMON_PLATFORM_UTIL_H_