Update mojo surfaces bindings and mojo/cc/ glue
[chromium-blink-merge.git] / chrome / browser / shell_integration_linux.h
blob90808b6be05b55b7bb16fb6e2874924a2c2da321
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 // Returns true on success, or false if no such path could be found.
26 // Called on the FILE thread.
27 bool GetDataWriteLocation(base::Environment* env, base::FilePath* search_path);
29 // Get the list of paths to search for application data files, in order of
30 // preference, as specified in the XDG Base Directory Specification:
31 // http://standards.freedesktop.org/basedir-spec/latest/
32 // Called on the FILE thread.
33 std::vector<base::FilePath> GetDataSearchLocations(base::Environment* env);
35 // Gets the name for use as the res_class (and possibly res_name) of the
36 // window's WM_CLASS property. This is the program name from argv[0], with the
37 // first letter capitalized. Equivalent to GDK's gdk_get_program_class().
38 std::string GetProgramClassName();
40 // Returns filename of the desktop shortcut used to launch the browser.
41 std::string GetDesktopName(base::Environment* env);
43 // Returns name of the browser icon (without a path or file extension).
44 std::string GetIconName();
46 // Returns the set of locations in which shortcuts are installed for the
47 // extension with |extension_id| in |profile_path|.
48 // This searches the file system for .desktop files in appropriate locations. A
49 // shortcut with NoDisplay=true causes hidden to become true, instead of
50 // creating at APP_MENU_LOCATIONS_SUBDIR_CHROMEAPPS.
51 web_app::ShortcutLocations GetExistingShortcutLocations(
52 base::Environment* env,
53 const base::FilePath& profile_path,
54 const std::string& extension_id);
56 // Version of GetExistingShortcutLocations which takes an explicit path
57 // to the user's desktop directory. Useful for testing.
58 // If |desktop_path| is empty, the desktop is not searched.
59 web_app::ShortcutLocations GetExistingShortcutLocations(
60 base::Environment* env,
61 const base::FilePath& profile_path,
62 const std::string& extension_id,
63 const base::FilePath& desktop_path);
65 // Returns the contents of an existing .desktop file installed in the system.
66 // Searches the "applications" subdirectory of each XDG data directory for a
67 // file named |desktop_filename|. If the file is found, populates |output| with
68 // its contents and returns true. Else, returns false.
69 bool GetExistingShortcutContents(base::Environment* env,
70 const base::FilePath& desktop_filename,
71 std::string* output);
73 // Returns filename for .desktop file based on |url|, sanitized for security.
74 base::FilePath GetWebShortcutFilename(const GURL& url);
76 // Returns filename for .desktop file based on |profile_path| and
77 // |extension_id|, sanitized for security.
78 base::FilePath GetExtensionShortcutFilename(const base::FilePath& profile_path,
79 const std::string& extension_id);
81 // Returns a list of filenames for all existing .desktop files corresponding to
82 // on |profile_path| in a given |directory|.
83 std::vector<base::FilePath> GetExistingProfileShortcutFilenames(
84 const base::FilePath& profile_path,
85 const base::FilePath& directory);
87 // Returns contents for .desktop file based on |url| and |title|. If
88 // |no_display| is true, the shortcut will not be visible to the user in menus.
89 std::string GetDesktopFileContents(const base::FilePath& chrome_exe_path,
90 const std::string& app_name,
91 const GURL& url,
92 const std::string& extension_id,
93 const base::string16& title,
94 const std::string& icon_name,
95 const base::FilePath& profile_path,
96 const std::string& categories,
97 bool no_display);
99 // Returns contents for .desktop file that executes command_line. This is a more
100 // general form of GetDesktopFileContents. If |no_display| is true, the shortcut
101 // will not be visible to the user in menus.
102 std::string GetDesktopFileContentsForCommand(
103 const base::CommandLine& command_line,
104 const std::string& app_name,
105 const GURL& url,
106 const base::string16& title,
107 const std::string& icon_name,
108 const std::string& categories,
109 bool no_display);
111 // Returns contents for .directory file named |title| with icon |icon_name|. If
112 // |icon_name| is empty, will use the Chrome icon.
113 std::string GetDirectoryFileContents(const base::string16& title,
114 const std::string& icon_name);
116 // Create shortcuts on the desktop or in the application menu (as specified by
117 // |shortcut_info|), for the web page or extension in |shortcut_info|.
118 // For extensions, duplicate shortcuts are avoided, so if a requested shortcut
119 // already exists it is deleted first.
120 bool CreateDesktopShortcut(
121 const web_app::ShortcutInfo& shortcut_info,
122 const web_app::ShortcutLocations& creation_locations);
124 // Create shortcuts in the application menu for the app launcher. Duplicate
125 // shortcuts are avoided, so if a requested shortcut already exists it is
126 // deleted first. Also creates the icon required by the shortcut.
127 bool CreateAppListDesktopShortcut(const std::string& wm_class,
128 const std::string& title);
130 // Delete any desktop shortcuts on desktop or in the application menu that have
131 // been added for the extension with |extension_id| in |profile_path|.
132 void DeleteDesktopShortcuts(const base::FilePath& profile_path,
133 const std::string& extension_id);
135 // Delete any desktop shortcuts on desktop or in the application menu that have
136 // for the profile in |profile_path|.
137 void DeleteAllDesktopShortcuts(const base::FilePath& profile_path);
139 } // namespace shell_integration_linux
141 #endif // CHROME_BROWSER_SHELL_INTEGRATION_LINUX_H_