platform_util.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright (c) 2013 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef SHELL_COMMON_PLATFORM_UTIL_H_
  5. #define SHELL_COMMON_PLATFORM_UTIL_H_
  6. #include <string>
  7. #include "base/callback_forward.h"
  8. #include "base/files/file_path.h"
  9. #include "build/build_config.h"
  10. #if defined(OS_WIN)
  11. #include "base/strings/string16.h"
  12. #endif
  13. class GURL;
  14. namespace platform_util {
  15. typedef base::OnceCallback<void(const std::string&)> OpenCallback;
  16. // Show the given file in a file manager. If possible, select the file.
  17. // Must be called from the UI thread.
  18. void ShowItemInFolder(const base::FilePath& full_path);
  19. // Open the given file in the desktop's default manner.
  20. // Must be called from the UI thread.
  21. void OpenPath(const base::FilePath& full_path, OpenCallback callback);
  22. struct OpenExternalOptions {
  23. bool activate = true;
  24. base::FilePath working_dir;
  25. };
  26. // Open the given external protocol URL in the desktop's default manner.
  27. // (For example, mailto: URLs in the default mail user agent.)
  28. void OpenExternal(const GURL& url,
  29. const OpenExternalOptions& options,
  30. OpenCallback callback);
  31. // Move a file to trash.
  32. bool MoveItemToTrash(const base::FilePath& full_path, bool delete_on_fail);
  33. void Beep();
  34. #if defined(OS_MACOSX)
  35. bool GetLoginItemEnabled();
  36. bool SetLoginItemEnabled(bool enabled);
  37. #endif
  38. #if defined(OS_LINUX)
  39. // Returns a success flag.
  40. // Unlike libgtkui, does *not* use "chromium-browser.desktop" as a fallback.
  41. bool GetDesktopName(std::string* setme);
  42. #endif
  43. } // namespace platform_util
  44. #endif // SHELL_COMMON_PLATFORM_UTIL_H_