platform_util.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 ATOM_COMMON_PLATFORM_UTIL_H_
  5. #define ATOM_COMMON_PLATFORM_UTIL_H_
  6. #include <string>
  7. #include "base/callback_forward.h"
  8. #include "build/build_config.h"
  9. #if defined(OS_WIN)
  10. #include "base/strings/string16.h"
  11. #endif
  12. class GURL;
  13. namespace base {
  14. class FilePath;
  15. }
  16. namespace platform_util {
  17. typedef base::Callback<void(const std::string&)> OpenExternalCallback;
  18. // Show the given file in a file manager. If possible, select the file.
  19. // Must be called from the UI thread.
  20. bool ShowItemInFolder(const base::FilePath& full_path);
  21. // Open the given file in the desktop's default manner.
  22. // Must be called from the UI thread.
  23. bool OpenItem(const base::FilePath& full_path);
  24. // Open the given external protocol URL in the desktop's default manner.
  25. // (For example, mailto: URLs in the default mail user agent.)
  26. bool OpenExternal(
  27. #if defined(OS_WIN)
  28. const base::string16& url,
  29. #else
  30. const GURL& url,
  31. #endif
  32. bool activate);
  33. // The asynchronous version of OpenExternal.
  34. void OpenExternal(
  35. #if defined(OS_WIN)
  36. const base::string16& url,
  37. #else
  38. const GURL& url,
  39. #endif
  40. bool activate,
  41. const OpenExternalCallback& callback);
  42. // Move a file to trash.
  43. bool MoveItemToTrash(const base::FilePath& full_path);
  44. void Beep();
  45. #if defined(OS_MACOSX)
  46. bool GetLoginItemEnabled();
  47. void SetLoginItemEnabled(bool enabled);
  48. #endif
  49. } // namespace platform_util
  50. #endif // ATOM_COMMON_PLATFORM_UTIL_H_