Bug 1646817 - Support DocumentChannel process switching in sidebars and popups r...
[gecko.git] / widget / cocoa / nsClipboard.h
blobce4b7a6675a922bc734af3dd98a795c22ba57c27
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/. */
6 #ifndef nsClipboard_h_
7 #define nsClipboard_h_
9 #include "nsIClipboard.h"
10 #include "nsString.h"
11 #include "mozilla/StaticPtr.h"
13 #import <Cocoa/Cocoa.h>
15 class nsITransferable;
17 @interface UTIHelper : NSObject
18 + (NSString*)stringFromPboardType:(NSString*)aType;
19 @end
21 class nsClipboard : public nsIClipboard {
22 public:
23 nsClipboard();
25 NS_DECL_ISUPPORTS
26 NS_DECL_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);
40 protected:
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);
47 private:
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_