| 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 #include "chrome/browser/shell_integration_linux.h" | 5 #include "chrome/browser/shell_integration_linux.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 | 8 |
| 9 #if defined(USE_GLIB) | 9 #if defined(USE_GLIB) |
| 10 #include <glib.h> | 10 #include <glib.h> |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 // items from the menu with a matching name. | 253 // items from the menu with a matching name. |
| 254 // If |directory_filename| is supplied, this will also remove the item from | 254 // If |directory_filename| is supplied, this will also remove the item from |
| 255 // the directory, and remove the directory if it is empty. | 255 // the directory, and remove the directory if it is empty. |
| 256 if (!directory_filename.empty()) | 256 if (!directory_filename.empty()) |
| 257 argv.push_back(directory_filename.value()); | 257 argv.push_back(directory_filename.value()); |
| 258 argv.push_back(shortcut_filename.value()); | 258 argv.push_back(shortcut_filename.value()); |
| 259 int exit_code; | 259 int exit_code; |
| 260 LaunchXdgUtility(argv, &exit_code); | 260 LaunchXdgUtility(argv, &exit_code); |
| 261 } | 261 } |
| 262 | 262 |
| 263 #if defined(USE_GLIB) |
| 263 // Quote a string such that it appears as one verbatim argument for the Exec | 264 // Quote a string such that it appears as one verbatim argument for the Exec |
| 264 // key in a desktop file. | 265 // key in a desktop file. |
| 265 std::string QuoteArgForDesktopFileExec(const std::string& arg) { | 266 std::string QuoteArgForDesktopFileExec(const std::string& arg) { |
| 266 // http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s06.html | 267 // http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s06.html |
| 267 | 268 |
| 268 // Quoting is only necessary if the argument has a reserved character. | 269 // Quoting is only necessary if the argument has a reserved character. |
| 269 if (arg.find_first_of(" \t\n\"'\\><~|&;$*?#()`") == std::string::npos) | 270 if (arg.find_first_of(" \t\n\"'\\><~|&;$*?#()`") == std::string::npos) |
| 270 return arg; // No quoting necessary. | 271 return arg; // No quoting necessary. |
| 271 | 272 |
| 272 std::string quoted = "\""; | 273 std::string quoted = "\""; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 303 quoted_path += " "; | 304 quoted_path += " "; |
| 304 quoted_path += QuoteArgForDesktopFileExec(*i); | 305 quoted_path += QuoteArgForDesktopFileExec(*i); |
| 305 } | 306 } |
| 306 | 307 |
| 307 return quoted_path; | 308 return quoted_path; |
| 308 } | 309 } |
| 309 | 310 |
| 310 const char kDesktopEntry[] = "Desktop Entry"; | 311 const char kDesktopEntry[] = "Desktop Entry"; |
| 311 | 312 |
| 312 const char kXdgOpenShebang[] = "#!/usr/bin/env xdg-open"; | 313 const char kXdgOpenShebang[] = "#!/usr/bin/env xdg-open"; |
| 314 #endif |
| 313 | 315 |
| 314 const char kXdgSettings[] = "xdg-settings"; | 316 const char kXdgSettings[] = "xdg-settings"; |
| 315 const char kXdgSettingsDefaultBrowser[] = "default-web-browser"; | 317 const char kXdgSettingsDefaultBrowser[] = "default-web-browser"; |
| 316 const char kXdgSettingsDefaultSchemeHandler[] = "default-url-scheme-handler"; | 318 const char kXdgSettingsDefaultSchemeHandler[] = "default-url-scheme-handler"; |
| 317 | 319 |
| 318 const char kDirectoryFilename[] = "chrome-apps.directory"; | 320 const char kDirectoryFilename[] = "chrome-apps.directory"; |
| 319 | 321 |
| 320 #if defined(GOOGLE_CHROME_BUILD) | 322 #if defined(GOOGLE_CHROME_BUILD) |
| 321 const char kAppListDesktopName[] = "chrome-app-list"; | 323 const char kAppListDesktopName[] = "chrome-app-list"; |
| 322 #else // CHROMIUM_BUILD | 324 #else // CHROMIUM_BUILD |
| (...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 for (std::vector<base::FilePath>::const_iterator it = | 1074 for (std::vector<base::FilePath>::const_iterator it = |
| 1073 shortcut_filenames_app_menu.begin(); | 1075 shortcut_filenames_app_menu.begin(); |
| 1074 it != shortcut_filenames_app_menu.end(); ++it) { | 1076 it != shortcut_filenames_app_menu.end(); ++it) { |
| 1075 DeleteShortcutInApplicationsMenu(*it, | 1077 DeleteShortcutInApplicationsMenu(*it, |
| 1076 base::FilePath(kDirectoryFilename)); | 1078 base::FilePath(kDirectoryFilename)); |
| 1077 } | 1079 } |
| 1078 } | 1080 } |
| 1079 } | 1081 } |
| 1080 | 1082 |
| 1081 } // namespace shell_integration_linux | 1083 } // namespace shell_integration_linux |
| OLD | NEW |