1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 #include "nsIClipboard.h"
11 #include "mozilla/StaticPtr.h"
13 #import <Cocoa/Cocoa.h>
15 class nsITransferable
;
17 @interface UTIHelper
: NSObject
18 + (NSString
*)stringFromPboardType
:(NSString
*)aType
;
21 class nsClipboard
: public nsIClipboard
{
28 // On macOS, cache the transferable of the current selection (chrome/content)
29 // in the parent process. This is needed for the services menu which
30 // requires synchronous access to the current selection.
31 static mozilla::StaticRefPtr
<nsITransferable
> sSelectionCache
;
33 // Helper methods, used also by nsDragService
34 static NSDictionary
* PasteboardDictFromTransferable(nsITransferable
* aTransferable
);
35 // aPasteboardType is being retained and needs to be released by the caller.
36 static bool IsStringType(const nsCString
& aMIMEType
, NSString
** aPasteboardType
);
37 static NSString
* WrapHtmlForSystemPasteboard(NSString
* aString
);
38 static nsresult
TransferableFromPasteboard(nsITransferable
* aTransferable
, NSPasteboard
* pboard
);
41 // impelement the native clipboard behavior
42 NS_IMETHOD
SetNativeClipboardData(int32_t aWhichClipboard
);
43 NS_IMETHOD
GetNativeClipboardData(nsITransferable
* aTransferable
, int32_t aWhichClipboard
);
44 void ClearSelectionCache();
45 void SetSelectionCache(nsITransferable
* aTransferable
);
48 virtual ~nsClipboard();
49 int32_t mCachedClipboard
;
50 int32_t mChangeCount
; // Set to the native change count after any modification of the clipboard.
52 bool mIgnoreEmptyNotification
;
53 nsCOMPtr
<nsIClipboardOwner
> mClipboardOwner
;
54 nsCOMPtr
<nsITransferable
> mTransferable
;
57 #endif // nsClipboard_h_