Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 contents of an existing .desktop file installed in the system. | |
| 25 // Searches the "applications" subdirectory of each XDG data directory for a | |
| 26 // file named |desktop_filename|. If the file is found, populates |output| with | |
| 27 // its contents and returns true. Else, returns false. | |
| 28 bool GetExistingDesktopShortcutContents(base::Environment* env, | |
| 29 const base::FilePath& desktop_filename, | |
| 30 std::string* output); | |
| 31 | |
| 32 // Returns the contents of the .desktop file for Google Chrome or Chromium. If | |
| 33 // such a file exists, populates |output| and returns true. Else, returns false. | |
| 24 bool GetDesktopShortcutTemplate(base::Environment* env, | 34 bool GetDesktopShortcutTemplate(base::Environment* env, |
| 25 std::string* output); | 35 std::string* output); |
| 26 | 36 |
| 27 // Returns filename for .desktop file based on |url|, sanitized for security. | 37 // Returns filename for .desktop file based on |url|, sanitized for security. |
| 28 base::FilePath GetWebShortcutFilename(const GURL& url); | 38 base::FilePath GetWebShortcutFilename(const GURL& url); |
| 29 | 39 |
| 30 // Returns filename for .desktop file based on |profile_path| and | 40 // Returns filename for .desktop file based on |profile_path| and |
| 31 // |extension_id|, sanitized for security. | 41 // |extension_id|, sanitized for security. |
| 32 base::FilePath GetExtensionShortcutFilename(const base::FilePath& profile_path, | 42 base::FilePath GetExtensionShortcutFilename(const base::FilePath& profile_path, |
| 33 const std::string& extension_id); | 43 const std::string& extension_id); |
| 34 | 44 |
| 35 // Returns contents for .desktop file based on |template_contents|, |url| | 45 // Returns contents for .desktop file based on |template_contents|, |url| |
| 36 // and |title|. The |template_contents| should be contents of .desktop file | 46 // and |title|. The |template_contents| should be contents of .desktop file |
| 37 // used to launch Chrome. | 47 // used to launch Chrome. If |no_display| is true, the shortcut will not be |
| 48 // visible to the user in menus. | |
| 38 std::string GetDesktopFileContents(const std::string& template_contents, | 49 std::string GetDesktopFileContents(const std::string& template_contents, |
| 39 const std::string& app_name, | 50 const std::string& app_name, |
| 40 const GURL& url, | 51 const GURL& url, |
| 41 const std::string& extension_id, | 52 const std::string& extension_id, |
| 42 const base::FilePath& extension_path, | 53 const base::FilePath& extension_path, |
| 43 const string16& title, | 54 const string16& title, |
| 44 const std::string& icon_name, | 55 const std::string& icon_name, |
| 45 const base::FilePath& profile_path); | 56 const base::FilePath& profile_path, |
| 57 bool no_display); | |
| 46 | 58 |
| 47 | 59 |
| 48 // Create shortcuts on the desktop or in the application menu (as specified by | 60 // 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 | 61 // |shortcut_info|), for the web page or extension in |shortcut_info|. Use the |
| 50 // shortcut template contained in |shortcut_template|. | 62 // shortcut template contained in |shortcut_template|. |
| 51 // For extensions, duplicate shortcuts are avoided, so if a requested shortcut | 63 // For extensions, duplicate shortcuts are avoided, so if a requested shortcut |
| 52 // already exists it is deleted first. | 64 // already exists it is deleted first. |
| 53 bool CreateDesktopShortcut( | 65 bool CreateDesktopShortcut( |
| 54 const ShellIntegration::ShortcutInfo& shortcut_info, | 66 const ShellIntegration::ShortcutInfo& shortcut_info, |
| 55 const ShellIntegration::ShortcutLocations& creation_locations, | 67 const ShellIntegration::ShortcutLocations& creation_locations, |
| 56 const std::string& shortcut_template); | 68 const std::string& shortcut_template); |
| 57 | 69 |
| 58 // Delete any desktop shortcuts on desktop or in the application menu that have | 70 // 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|. | 71 // been added for the extension with |extension_id| in |profile_path|. |
| 60 void DeleteDesktopShortcuts(const base::FilePath& profile_path, | 72 void DeleteDesktopShortcuts(const base::FilePath& profile_path, |
| 61 const std::string& extension_id); | 73 const std::string& extension_id); |
| 62 | 74 |
| 75 // Returns the set of locations in which shortcuts are installed for the | |
| 76 // extension with |extension_id| in |profile_path|. | |
| 77 // This searches the file system for .desktop files in appropriate locations. A | |
| 78 // shortcut with NoDisplay=true does not count as being in the applications | |
| 79 // menu (as it is invisible to the user). | |
| 80 ShellIntegration::ShortcutLocations DesktopShortcutLocations( | |
|
benwells
2013/03/06 06:36:39
Can we rename this to GetExistingShortcutLocations
Matt Giuca
2013/03/06 07:23:11
Done. Also moved it up near GetExistingDesktopShor
| |
| 81 base::Environment* env, | |
| 82 const base::FilePath& profile_path, | |
| 83 const std::string& extension_id); | |
| 84 | |
| 85 // Version of DesktopShortcutLocations which takes an explicit path to the | |
| 86 // user's desktop directory. Useful for testing. | |
| 87 // If |desktop_path| is empty, the desktop is not searched. | |
| 88 ShellIntegration::ShortcutLocations DesktopShortcutLocations( | |
| 89 base::Environment* env, | |
| 90 const base::FilePath& profile_path, | |
| 91 const std::string& extension_id, | |
| 92 const base::FilePath& desktop_path); | |
| 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_ |
| OLD | NEW |