Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: chrome/browser/shell_integration_linux.h

Issue 12208085: On Linux, automatically create app shortcuts on install or update. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rename and move some functions to more appropriate names/places. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SHELL_INTEGRATION_LINUX_H_ 5 #ifndef CHROME_BROWSER_SHELL_INTEGRATION_LINUX_H_
6 #define CHROME_BROWSER_SHELL_INTEGRATION_LINUX_H_ 6 #define CHROME_BROWSER_SHELL_INTEGRATION_LINUX_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "chrome/browser/shell_integration.h" 12 #include "chrome/browser/shell_integration.h"
13 #include "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
14 14
15 namespace base { 15 namespace base {
16 class Environment; 16 class Environment;
17 } 17 }
18 18
19 namespace ShellIntegrationLinux { 19 namespace ShellIntegrationLinux {
20 20
21 // Returns filename of the desktop shortcut used to launch the browser. 21 // Returns filename of the desktop shortcut used to launch the browser.
22 std::string GetDesktopName(base::Environment* env); 22 std::string GetDesktopName(base::Environment* env);
23 23
24 // Returns the set of locations in which shortcuts are installed for the
25 // extension with |extension_id| in |profile_path|.
26 // This searches the file system for .desktop files in appropriate locations. A
27 // shortcut with NoDisplay=true does not count as being in the applications
28 // menu (as it is invisible to the user).
29 ShellIntegration::ShortcutLocations GetExistingShortcutLocations(
30 base::Environment* env,
31 const base::FilePath& profile_path,
32 const std::string& extension_id);
33
34 // Version of GetExistingShortcutLocations which takes an explicit path
35 // to the user's desktop directory. Useful for testing.
36 // If |desktop_path| is empty, the desktop is not searched.
37 ShellIntegration::ShortcutLocations GetExistingShortcutLocations(
38 base::Environment* env,
39 const base::FilePath& profile_path,
40 const std::string& extension_id,
41 const base::FilePath& desktop_path);
42
43 // Returns the contents of an existing .desktop file installed in the system.
44 // Searches the "applications" subdirectory of each XDG data directory for a
45 // file named |desktop_filename|. If the file is found, populates |output| with
46 // its contents and returns true. Else, returns false.
47 bool GetExistingShortcutContents(base::Environment* env,
48 const base::FilePath& desktop_filename,
49 std::string* output);
50
51 // Returns the contents of the .desktop file for Google Chrome or Chromium. If
52 // such a file exists, populates |output| and returns true. Else, returns false.
24 bool GetDesktopShortcutTemplate(base::Environment* env, 53 bool GetDesktopShortcutTemplate(base::Environment* env,
25 std::string* output); 54 std::string* output);
26 55
27 // Returns filename for .desktop file based on |url|, sanitized for security. 56 // Returns filename for .desktop file based on |url|, sanitized for security.
28 base::FilePath GetWebShortcutFilename(const GURL& url); 57 base::FilePath GetWebShortcutFilename(const GURL& url);
29 58
30 // Returns filename for .desktop file based on |profile_path| and 59 // Returns filename for .desktop file based on |profile_path| and
31 // |extension_id|, sanitized for security. 60 // |extension_id|, sanitized for security.
32 base::FilePath GetExtensionShortcutFilename(const base::FilePath& profile_path, 61 base::FilePath GetExtensionShortcutFilename(const base::FilePath& profile_path,
33 const std::string& extension_id); 62 const std::string& extension_id);
34 63
35 // Returns contents for .desktop file based on |template_contents|, |url| 64 // Returns contents for .desktop file based on |template_contents|, |url|
36 // and |title|. The |template_contents| should be contents of .desktop file 65 // and |title|. The |template_contents| should be contents of .desktop file
37 // used to launch Chrome. 66 // used to launch Chrome. If |no_display| is true, the shortcut will not be
67 // visible to the user in menus.
38 std::string GetDesktopFileContents(const std::string& template_contents, 68 std::string GetDesktopFileContents(const std::string& template_contents,
39 const std::string& app_name, 69 const std::string& app_name,
40 const GURL& url, 70 const GURL& url,
41 const std::string& extension_id, 71 const std::string& extension_id,
42 const base::FilePath& extension_path, 72 const base::FilePath& extension_path,
43 const string16& title, 73 const string16& title,
44 const std::string& icon_name, 74 const std::string& icon_name,
45 const base::FilePath& profile_path); 75 const base::FilePath& profile_path,
76 bool no_display);
46 77
47 78
48 // Create shortcuts on the desktop or in the application menu (as specified by 79 // Create shortcuts on the desktop or in the application menu (as specified by
49 // |shortcut_info|), for the web page or extension in |shortcut_info|. Use the 80 // |shortcut_info|), for the web page or extension in |shortcut_info|. Use the
50 // shortcut template contained in |shortcut_template|. 81 // shortcut template contained in |shortcut_template|.
51 // For extensions, duplicate shortcuts are avoided, so if a requested shortcut 82 // For extensions, duplicate shortcuts are avoided, so if a requested shortcut
52 // already exists it is deleted first. 83 // already exists it is deleted first.
53 bool CreateDesktopShortcut( 84 bool CreateDesktopShortcut(
54 const ShellIntegration::ShortcutInfo& shortcut_info, 85 const ShellIntegration::ShortcutInfo& shortcut_info,
55 const ShellIntegration::ShortcutLocations& creation_locations, 86 const ShellIntegration::ShortcutLocations& creation_locations,
56 const std::string& shortcut_template); 87 const std::string& shortcut_template);
57 88
58 // Delete any desktop shortcuts on desktop or in the application menu that have 89 // Delete any desktop shortcuts on desktop or in the application menu that have
59 // been added for the extension with |extension_id| in |profile_path|. 90 // been added for the extension with |extension_id| in |profile_path|.
60 void DeleteDesktopShortcuts(const base::FilePath& profile_path, 91 void DeleteDesktopShortcuts(const base::FilePath& profile_path,
61 const std::string& extension_id); 92 const std::string& extension_id);
62 93
63 } // namespace ShellIntegrationLinux 94 } // namespace ShellIntegrationLinux
64 95
65 #endif // CHROME_BROWSER_SHELL_INTEGRATION_LINUX_H_ 96 #endif // CHROME_BROWSER_SHELL_INTEGRATION_LINUX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698