[M85 Dev][EFL] Fix errors to generate ninja files
[platform/framework/web/chromium-efl.git] / chrome / browser / shell_integration_linux.h
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_SHELL_INTEGRATION_LINUX_H_
6 #define CHROME_BROWSER_SHELL_INTEGRATION_LINUX_H_
7
8 #include <string>
9
10 #include "base/files/file_path.h"
11 #include "chrome/browser/web_applications/components/web_app_id.h"
12 #include "chrome/common/buildflags.h"
13 #include "components/services/app_service/public/cpp/file_handler.h"
14 #include "url/gurl.h"
15
16 #if defined(OS_CHROMEOS)
17 #error shell_integration_linux is for desktop linux only.
18 #endif
19
20 namespace base {
21 class CommandLine;
22 class Environment;
23 }
24
25 namespace shell_integration_linux {
26
27 // Get the path to write user-specific application data files to, as specified
28 // in the XDG Base Directory Specification:
29 // http://standards.freedesktop.org/basedir-spec/latest/
30 base::FilePath GetDataWriteLocation(base::Environment* env);
31
32 // Get the list of paths to search for application data files, in order of
33 // preference, as specified in the XDG Base Directory Specification:
34 // http://standards.freedesktop.org/basedir-spec/latest/
35 // Called on the FILE thread.
36 std::vector<base::FilePath> GetDataSearchLocations(base::Environment* env);
37
38 // Gets the name for use as the res_name of the window's WM_CLASS property.
39 std::string GetProgramClassName();
40
41 // Gets the name for use as the res_class of the window's WM_CLASS property.
42 std::string GetProgramClassClass();
43
44 // Returns name of the browser icon (without a path or file extension).
45 std::string GetIconName();
46
47 // Returns the contents of an existing .desktop file installed in the system.
48 // Searches the "applications" subdirectory of each XDG data directory for a
49 // file named |desktop_filename|. If the file is found, populates |output| with
50 // its contents and returns true. Else, returns false.
51 bool GetExistingShortcutContents(base::Environment* env,
52                                  const base::FilePath& desktop_filename,
53                                  std::string* output);
54
55 // Returns filename for .desktop file based on |url|, sanitized for security.
56 base::FilePath GetWebShortcutFilename(const GURL& url);
57
58 // Returns a list of filenames for all existing .desktop files corresponding to
59 // on |profile_path| in a given |directory|.
60 std::vector<base::FilePath> GetExistingProfileShortcutFilenames(
61     const base::FilePath& profile_path,
62     const base::FilePath& directory);
63
64 // Returns contents for .desktop file based on |url| and |title|. If
65 // |no_display| is true, the shortcut will not be visible to the user in menus.
66 std::string GetDesktopFileContents(const base::FilePath& chrome_exe_path,
67                                    const std::string& app_name,
68                                    const GURL& url,
69                                    const std::string& extension_id,
70                                    const base::string16& title,
71                                    const std::string& icon_name,
72                                    const base::FilePath& profile_path,
73                                    const std::string& categories,
74                                    const std::string& mime_type,
75                                    bool no_display);
76
77 // Returns contents for .desktop file that executes command_line. This is a more
78 // general form of GetDesktopFileContents. If |no_display| is true, the shortcut
79 // will not be visible to the user in menus.
80 std::string GetDesktopFileContentsForCommand(
81     const base::CommandLine& command_line,
82     const std::string& app_name,
83     const GURL& url,
84     const base::string16& title,
85     const std::string& icon_name,
86     const std::string& categories,
87     const std::string& mime_type,
88     bool no_display);
89
90 // Returns contents for .directory file named |title| with icon |icon_name|. If
91 // |icon_name| is empty, will use the Chrome icon.
92 std::string GetDirectoryFileContents(const base::string16& title,
93                                      const std::string& icon_name);
94
95 // Returns the filename for a .xml file, corresponding to a given |app_id|,
96 // which is passed to `xdg-mime` to register one or more custom MIME types in
97 // Linux.
98 base::FilePath GetMimeTypesRegistrationFilename(
99     const base::FilePath& profile_path,
100     const web_app::AppId& app_id);
101
102 // Returns the contents of a .xml file as specified by |file_handlers|, which is
103 // passed to `xdg-mime` to register one or more custom MIME types in Linux.
104 std::string GetMimeTypesRegistrationFileContents(
105     const apps::FileHandlers& file_handlers);
106
107 // Windows that correspond to web apps need to have a deterministic (and
108 // different) WMClass than normal chrome windows so the window manager groups
109 // them as a separate application.
110 std::string GetWMClassFromAppName(std::string app_name);
111
112 // Helper to launch xdg scripts. We don't want them to ask any questions on the
113 // terminal etc. The function returns true if the utility launches and exits
114 // cleanly, in which case |exit_code| returns the utility's exit code.
115 // thread_restrictions.h assumes it to be in shell_integration namespace.
116 bool LaunchXdgUtility(const std::vector<std::string>& argv, int* exit_code);
117
118 namespace internal {
119
120 // Exposed for testing.  Clients should use the corresponding functions in
121 // shell_integration_linux instead.
122 std::string GetProgramClassName(const base::CommandLine& command_line,
123                                 const std::string& desktop_file_name);
124 std::string GetProgramClassClass(const base::CommandLine& command_line,
125                                  const std::string& desktop_file_name);
126
127 // Get the value of NoDisplay from the [Desktop Entry] section of a .desktop
128 // file, given in |shortcut_contents|. If the key is not found, returns false.
129 bool GetNoDisplayFromDesktopFile(const std::string& shortcut_contents);
130
131 // Gets the path to the Chrome executable or wrapper script.
132 // Returns an empty path if the executable path could not be found, which should
133 // never happen.
134 base::FilePath GetChromeExePath();
135
136 }  // namespace internal
137
138 }  // namespace shell_integration_linux
139
140 #endif  // CHROME_BROWSER_SHELL_INTEGRATION_LINUX_H_