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.
5 #ifndef CHROME_BROWSER_SHELL_INTEGRATION_LINUX_H_
6 #define CHROME_BROWSER_SHELL_INTEGRATION_LINUX_H_
10 #include "base/basictypes.h"
11 #include "base/files/file_path.h"
12 #include "chrome/browser/shell_integration.h"
19 namespace ShellIntegrationLinux
{
21 // Get the path to write user-specific application data files to, as specified
22 // in the XDG Base Directory Specification:
23 // http://standards.freedesktop.org/basedir-spec/latest/
24 // Returns true on success, or false if no such path could be found.
25 // Called on the FILE thread.
26 bool GetDataWriteLocation(base::Environment
* env
, base::FilePath
* search_path
);
28 // Get the list of paths to search for application data files, in order of
29 // preference, as specified in the XDG Base Directory Specification:
30 // http://standards.freedesktop.org/basedir-spec/latest/
31 // Called on the FILE thread.
32 std::vector
<base::FilePath
> GetDataSearchLocations(base::Environment
* env
);
34 // Gets the name for use as the res_class (and possibly res_name) of the
35 // window's WM_CLASS property. This is the program name from argv[0], with the
36 // first letter capitalized. Equivalent to GDK's gdk_get_program_class().
37 std::string
GetProgramClassName();
39 // Returns filename of the desktop shortcut used to launch the browser.
40 std::string
GetDesktopName(base::Environment
* env
);
42 // Returns name of the browser icon (without a path or file extension).
43 std::string
GetIconName();
45 // Returns the set of locations in which shortcuts are installed for the
46 // extension with |extension_id| in |profile_path|.
47 // This searches the file system for .desktop files in appropriate locations. A
48 // shortcut with NoDisplay=true causes hidden to become true, instead of
49 // in_applications_menu.
50 ShellIntegration::ShortcutLocations
GetExistingShortcutLocations(
51 base::Environment
* env
,
52 const base::FilePath
& profile_path
,
53 const std::string
& extension_id
);
55 // Version of GetExistingShortcutLocations which takes an explicit path
56 // to the user's desktop directory. Useful for testing.
57 // If |desktop_path| is empty, the desktop is not searched.
58 ShellIntegration::ShortcutLocations
GetExistingShortcutLocations(
59 base::Environment
* env
,
60 const base::FilePath
& profile_path
,
61 const std::string
& extension_id
,
62 const base::FilePath
& desktop_path
);
64 // Returns the contents of an existing .desktop file installed in the system.
65 // Searches the "applications" subdirectory of each XDG data directory for a
66 // file named |desktop_filename|. If the file is found, populates |output| with
67 // its contents and returns true. Else, returns false.
68 bool GetExistingShortcutContents(base::Environment
* env
,
69 const base::FilePath
& desktop_filename
,
72 // Returns filename for .desktop file based on |url|, sanitized for security.
73 base::FilePath
GetWebShortcutFilename(const GURL
& url
);
75 // Returns filename for .desktop file based on |profile_path| and
76 // |extension_id|, sanitized for security.
77 base::FilePath
GetExtensionShortcutFilename(const base::FilePath
& profile_path
,
78 const std::string
& extension_id
);
80 // Returns a list of filenames for all existing .desktop files corresponding to
81 // on |profile_path| in a given |directory|.
82 std::vector
<base::FilePath
> GetExistingProfileShortcutFilenames(
83 const base::FilePath
& profile_path
,
84 const base::FilePath
& directory
);
86 // Returns contents for .desktop file based on |url| and |title|. If
87 // |no_display| is true, the shortcut will not be visible to the user in menus.
88 std::string
GetDesktopFileContents(const base::FilePath
& chrome_exe_path
,
89 const std::string
& app_name
,
91 const std::string
& extension_id
,
92 const base::FilePath
& extension_path
,
93 const string16
& title
,
94 const std::string
& icon_name
,
95 const base::FilePath
& profile_path
,
98 // Returns contents for .directory file named |title| with icon |icon_name|. If
99 // |icon_name| is empty, will use the Chrome icon.
100 std::string
GetDirectoryFileContents(const string16
& title
,
101 const std::string
& icon_name
);
103 // Create shortcuts on the desktop or in the application menu (as specified by
104 // |shortcut_info|), for the web page or extension in |shortcut_info|.
105 // For extensions, duplicate shortcuts are avoided, so if a requested shortcut
106 // already exists it is deleted first.
107 bool CreateDesktopShortcut(
108 const ShellIntegration::ShortcutInfo
& shortcut_info
,
109 const ShellIntegration::ShortcutLocations
& creation_locations
);
111 // Delete any desktop shortcuts on desktop or in the application menu that have
112 // been added for the extension with |extension_id| in |profile_path|.
113 void DeleteDesktopShortcuts(const base::FilePath
& profile_path
,
114 const std::string
& extension_id
);
116 // Delete any desktop shortcuts on desktop or in the application menu that have
117 // for the profile in |profile_path|.
118 void DeleteAllDesktopShortcuts(const base::FilePath
& profile_path
);
120 } // namespace ShellIntegrationLinux
122 #endif // CHROME_BROWSER_SHELL_INTEGRATION_LINUX_H_