blob: 8e342d60ad29a3109403a085c567cff1daac991e [file] [log] [blame]
Marijn Kruisselbrink9aba65e2024-04-18 21:54:241// 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#ifndef CHROME_BROWSER_SHORTCUTS_PLATFORM_UTIL_MAC_H_
6#define CHROME_BROWSER_SHORTCUTS_PLATFORM_UTIL_MAC_H_
7
Marijn Kruisselbrink1bfda682024-05-02 00:23:088#include <optional>
9
10#include "base/files/safe_base_name.h"
Marijn Kruisselbrink9aba65e2024-04-18 21:54:2411#include "base/functional/callback_forward.h"
12
13@class NSError;
14@class NSImage;
15@class NSURL;
16
17namespace base {
18class FilePath;
19}
20
21namespace shortcuts {
22
23// Wrapper around NSWorkspace setIcon:forFile: that can be called from any
24// thread. While the underlying NSWorkspace method can also be called from any
25// thread, it is not reentrancy safe (i.e. multiple calls to it need to be
26// sequenced). This wrapper takes care of the sequencing needed. The `callback`
27// will be called on the calling sequence.
28void SetIconForFile(NSImage* image,
29 const base::FilePath& file,
30 base::OnceCallback<void(bool)> callback);
31
Marijn Kruisselbrink1bfda682024-05-02 00:23:0832// Return a version of `title` that is safe to use as a filename on macOS.
33std::optional<base::SafeBaseName> SanitizeTitleForFileName(
34 const std::string& title);
35
Marijn Kruisselbrink9aba65e2024-04-18 21:54:2436} // namespace shortcuts
37
38#endif // CHROME_BROWSER_SHORTCUTS_PLATFORM_UTIL_MAC_H_