blob: 21a3b698778c7b4918614b1c674a2f1abc5581a0 [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
8#include "base/functional/callback_forward.h"
9
10@class NSError;
11@class NSImage;
12@class NSURL;
13
14namespace base {
15class FilePath;
16}
17
18namespace shortcuts {
19
20// Wrapper around NSWorkspace setIcon:forFile: that can be called from any
21// thread. While the underlying NSWorkspace method can also be called from any
22// thread, it is not reentrancy safe (i.e. multiple calls to it need to be
23// sequenced). This wrapper takes care of the sequencing needed. The `callback`
24// will be called on the calling sequence.
25void SetIconForFile(NSImage* image,
26 const base::FilePath& file,
27 base::OnceCallback<void(bool)> callback);
28
29// Wrapper around NSWorkspace setDefaultApplicationAtURL:toOpenFileAtURL:. The
30// NSWorkspace method only exists on macOS 12.0 and newer; this method polyfills
31// its implementation for older macOS versions.
32void SetDefaultApplicationToOpenFile(
33 NSURL* file_url,
34 NSURL* application_url,
35 base::OnceCallback<void(NSError*)> callback);
36
37} // namespace shortcuts
38
39#endif // CHROME_BROWSER_SHORTCUTS_PLATFORM_UTIL_MAC_H_