Daniel Murphy | 756499db | 2024-05-02 22:37:54 | [diff] [blame] | 1 | // Copyright 2024 The Chromium Authors |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "chrome/browser/shortcuts/linux_xdg_wrapper_impl.h" |
| 6 | |
| 7 | #include <stdlib.h> |
| 8 | |
| 9 | #include <string> |
| 10 | #include <vector> |
| 11 | |
| 12 | #include "base/files/file_path.h" |
| 13 | #include "base/no_destructor.h" |
| 14 | #include "base/strings/string_number_conversions.h" |
| 15 | #include "chrome/browser/shell_integration_linux.h" |
| 16 | |
| 17 | namespace shortcuts { |
| 18 | |
| 19 | LinuxXdgWrapperImpl::LinuxXdgWrapperImpl() = default; |
| 20 | LinuxXdgWrapperImpl::~LinuxXdgWrapperImpl() = default; |
| 21 | |
| 22 | int LinuxXdgWrapperImpl::XdgDesktopMenuInstall( |
| 23 | const base::FilePath& desktop_file) { |
| 24 | std::vector<std::string> argv; |
| 25 | argv.push_back("xdg-desktop-menu"); |
| 26 | argv.push_back("install"); |
| 27 | |
| 28 | // Always install in user mode, even if someone runs the browser as root |
| 29 | // (people do that). |
| 30 | argv.push_back("--mode"); |
| 31 | argv.push_back("user"); |
| 32 | |
| 33 | argv.push_back(desktop_file.value()); |
| 34 | int exit_code = EXIT_SUCCESS; |
| 35 | shell_integration_linux::LaunchXdgUtility(argv, &exit_code); |
| 36 | return exit_code; |
| 37 | } |
| 38 | |
| 39 | } // namespace shortcuts |