Extensions: Remove the legacy GetMessages/HasMessages
[chromium-blink-merge.git] / chrome / browser / shell_integration_linux.h
blob9899c3e4f5485516ed8e6b750932416bf4c8d6ee
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_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/files/file_path.h"
12 #include "chrome/browser/web_applications/web_app.h"
13 #include "url/gurl.h"
15 namespace base {
16 class CommandLine;
17 class Environment;
20 namespace shell_integration_linux {
22 // Get the path to write user-specific application data files to, as specified
23 // in the XDG Base Directory Specification:
24 // http://standards.freedesktop.org/basedir-spec/latest/
25 // Called on the FILE thread.
26 base::FilePath GetDataWriteLocation(base::Environment* env);
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 // creating at APP_MENU_LOCATIONS_SUBDIR_CHROMEAPPS.
50 web_app::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 web_app::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,
70 std::string* output);
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,
90 const GURL& url,
91 const std::string& extension_id,
92 const base::string16& title,
93 const std::string& icon_name,
94 const base::FilePath& profile_path,
95 const std::string& categories,
96 bool no_display);
98 // Returns contents for .desktop file that executes command_line. This is a more
99 // general form of GetDesktopFileContents. If |no_display| is true, the shortcut
100 // will not be visible to the user in menus.
101 std::string GetDesktopFileContentsForCommand(
102 const base::CommandLine& command_line,
103 const std::string& app_name,
104 const GURL& url,
105 const base::string16& title,
106 const std::string& icon_name,
107 const std::string& categories,
108 bool no_display);
110 // Returns contents for .directory file named |title| with icon |icon_name|. If
111 // |icon_name| is empty, will use the Chrome icon.
112 std::string GetDirectoryFileContents(const base::string16& title,
113 const std::string& icon_name);
115 // Create shortcuts on the desktop or in the application menu (as specified by
116 // |shortcut_info|), for the web page or extension in |shortcut_info|.
117 // For extensions, duplicate shortcuts are avoided, so if a requested shortcut
118 // already exists it is deleted first.
119 bool CreateDesktopShortcut(
120 const web_app::ShortcutInfo& shortcut_info,
121 const web_app::ShortcutLocations& creation_locations);
123 // Create shortcuts in the application menu for the app launcher. Duplicate
124 // shortcuts are avoided, so if a requested shortcut already exists it is
125 // deleted first. Also creates the icon required by the shortcut.
126 bool CreateAppListDesktopShortcut(const std::string& wm_class,
127 const std::string& title);
129 // Delete any desktop shortcuts on desktop or in the application menu that have
130 // been added for the extension with |extension_id| in |profile_path|.
131 void DeleteDesktopShortcuts(const base::FilePath& profile_path,
132 const std::string& extension_id);
134 // Delete any desktop shortcuts on desktop or in the application menu that have
135 // for the profile in |profile_path|.
136 void DeleteAllDesktopShortcuts(const base::FilePath& profile_path);
138 } // namespace shell_integration_linux
140 #endif // CHROME_BROWSER_SHELL_INTEGRATION_LINUX_H_