#include "chrome/browser/web_applications/os_integration/web_app_shortcut_linux.h"
#include <algorithm>
#include <utility>
#include <fcntl.h>
#include "base/base_paths.h"
#include "base/check_is_test.h"
#include "base/environment.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/i18n/file_util_icu.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/nix/xdg_util.h"
#include "base/no_destructor.h"
#include "base/path_service.h"
#include "base/posix/eintr_wrapper.h"
#include "base/process/kill.h"
#include "base/process/launch.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/task/task_runner.h"
#include "base/threading/scoped_blocking_call.h"
#include "chrome/browser/shell_integration.h"
#include "chrome/browser/shell_integration_linux.h"
#include "chrome/browser/web_applications/os_integration/os_integration_test_override.h"
#include "chrome/browser/web_applications/os_integration/web_app_shortcut.h"
#include "chrome/browser/web_applications/web_app_constants.h"
#include "chrome/common/auto_start_linux.h"
#include "chrome/common/buildflags.h"
#include "chrome/common/chrome_constants.h"
#include "components/webapps/common/web_app_id.h"
namespace web_app {
namespace {
constexpr const char* kCreateShortcutResult = …;
constexpr const char* kCreateShortcutIconResult = …;
LaunchXdgUtilityForTesting& GetInstalledLaunchXdgUtilityForTesting() { … }
base::FilePath GetDesktopPath() { … }
base::FilePath GetAutostartPath(base::Environment* env) { … }
enum class CreateShortcutIconResult { … };
enum class CreateShortcutResult { … };
void RecordCreateIcon(CreateShortcutIconResult result) { … }
void RecordCreateShortcut(CreateShortcutResult result) { … }
bool LaunchXdgUtility(const std::vector<std::string>& argv, int* exit_code) { … }
const char kDirectoryFilename[] = …;
std::string CreateShortcutIcon(const gfx::ImageFamily& icon_images,
const base::FilePath& shortcut_filename) { … }
bool CreateShortcutAtLocation(const base::FilePath location_path,
const base::FilePath& shortcut_filename,
const std::string& contents) { … }
bool CreateShortcutOnDesktop(const base::FilePath& shortcut_filename,
const std::string& contents) { … }
bool CreateShortcutInAutoStart(base::Environment* env,
const base::FilePath& shortcut_filename,
const std::string& contents) { … }
bool CreateShortcutInApplicationsMenu(base::Environment* env,
const base::FilePath& shortcut_filename,
const std::string& contents,
const base::FilePath& directory_filename,
const std::string& directory_contents) { … }
}
DesktopActionInfo::DesktopActionInfo() = default;
DesktopActionInfo::DesktopActionInfo(const std::string& id,
const std::string& name,
const GURL& exec_launch_url)
: … { … }
DesktopActionInfo::DesktopActionInfo(const DesktopActionInfo&) = default;
bool DesktopActionInfo::operator<(const DesktopActionInfo& other) const { … }
DesktopActionInfo::~DesktopActionInfo() = default;
void SetLaunchXdgUtilityForTesting(
LaunchXdgUtilityForTesting launchXdgUtilityForTesting) { … }
base::FilePath GetAppShortcutFilename(const base::FilePath& profile_path,
const std::string& app_id) { … }
bool DeleteShortcutOnDesktop(const base::FilePath& shortcut_filename) { … }
bool DeleteShortcutInAutoStart(base::Environment* env,
const base::FilePath& shortcut_filename) { … }
bool DeleteShortcutInApplicationsMenu(
const base::FilePath& shortcut_filename,
const base::FilePath& directory_filename) { … }
bool CreateDesktopShortcut(base::Environment* env,
const ShortcutInfo& shortcut_info,
const ShortcutLocations& creation_locations) { … }
ShortcutLocations GetExistingShortcutLocations(
base::Environment* env,
const base::FilePath& profile_path,
const std::string& extension_id) { … }
bool DeleteDesktopShortcuts(base::Environment* env,
const base::FilePath& profile_path,
const std::string& extension_id) { … }
bool DeleteAllDesktopShortcuts(base::Environment* env,
const base::FilePath& profile_path) { … }
bool UpdateDesktopShortcuts(
base::Environment* env,
const ShortcutInfo& shortcut_info,
std::optional<ShortcutLocations> user_specified_locations) { … }
std::vector<base::FilePath> GetShortcutLocations(
base::Environment* env,
const ShortcutLocations& locations,
const base::FilePath& profile_path,
const std::string& app_id) { … }
namespace internals {
void CreatePlatformShortcuts(const base::FilePath& ,
const ShortcutLocations& creation_locations,
ShortcutCreationReason ,
const ShortcutInfo& shortcut_info,
CreateShortcutsCallback callback) { … }
ShortcutLocations GetAppExistingShortCutLocationImpl(
const ShortcutInfo& shortcut_info) { … }
void DeletePlatformShortcuts(const base::FilePath& web_app_path,
const ShortcutInfo& shortcut_info,
scoped_refptr<base::TaskRunner> result_runner,
DeleteShortcutsCallback callback) { … }
void UpdatePlatformShortcuts(
const base::FilePath& ,
const std::u16string& ,
std::optional<ShortcutLocations> user_specified_locations,
ResultCallback callback,
const ShortcutInfo& shortcut_info) { … }
void DeleteAllShortcutsForProfile(const base::FilePath& profile_path) { … }
std::vector<base::FilePath> GetShortcutLocations(
const ShortcutLocations& locations,
const base::FilePath& profile_path,
const std::string& app_id) { … }
}
}