| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_BASE_CLIPBOARD_CLIPBOARD_UTIL_MAC_H_ | 5 #ifndef UI_BASE_CLIPBOARD_CLIPBOARD_UTIL_MAC_H_ |
| 6 #define UI_BASE_CLIPBOARD_CLIPBOARD_UTIL_MAC_H_ | 6 #define UI_BASE_CLIPBOARD_CLIPBOARD_UTIL_MAC_H_ |
| 7 | 7 |
| 8 #import <AppKit/AppKit.h> | 8 #import <AppKit/AppKit.h> |
| 9 | 9 |
| 10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 class UI_BASE_EXPORT ClipboardUtil { | 29 class UI_BASE_EXPORT ClipboardUtil { |
| 30 public: | 30 public: |
| 31 // Returns an NSPasteboardItem that represents the given |url|. | 31 // Returns an NSPasteboardItem that represents the given |url|. |
| 32 // |url| must not be nil. | 32 // |url| must not be nil. |
| 33 // If |title| is nil, |url| is used in its place. | 33 // If |title| is nil, |url| is used in its place. |
| 34 static base::scoped_nsobject<NSPasteboardItem> PasteboardItemFromUrl( | 34 static base::scoped_nsobject<NSPasteboardItem> PasteboardItemFromUrl( |
| 35 NSString* url, | 35 NSString* url, |
| 36 NSString* title); | 36 NSString* title); |
| 37 | 37 |
| 38 // Returns an NSPasteboardItem that represents the given |urls| and |titles|. |
| 39 static base::scoped_nsobject<NSPasteboardItem> PasteboardItemFromUrls( |
| 40 NSArray* urls, |
| 41 NSArray* titles); |
| 42 |
| 38 // Returns an NSPasteboardItem that represents the given string. | 43 // Returns an NSPasteboardItem that represents the given string. |
| 39 // |string| must not be nil. | 44 // |string| must not be nil. |
| 40 static base::scoped_nsobject<NSPasteboardItem> PasteboardItemFromString( | 45 static base::scoped_nsobject<NSPasteboardItem> PasteboardItemFromString( |
| 41 NSString* string); | 46 NSString* string); |
| 42 | 47 |
| 43 // Returns the title or url associated with a NSPasteboard which contains an | 48 // Returns the title or url associated with a NSPasteboard which contains an |
| 44 // url NSPasteboardItem. | 49 // url NSPasteboardItem. |
| 45 static NSString* GetTitleFromPasteboardURL(NSPasteboard* pboard); | 50 static NSString* GetTitleFromPasteboardURL(NSPasteboard* pboard); |
| 46 static NSString* GetURLFromPasteboardURL(NSPasteboard* pboard); | 51 static NSString* GetURLFromPasteboardURL(NSPasteboard* pboard); |
| 52 |
| 53 // Returns the UTI of a pasteboard type. |
| 54 static NSString* UTIForPasteboardType(NSString* type); |
| 55 static NSString* UTIForWebURLsAndTitles(); |
| 56 |
| 57 // For each pasteboard type in |item| that is not in |pboard|, add the type |
| 58 // and its associated data. |
| 59 static void AddDataToPasteboard(NSPasteboard* pboard, NSPasteboardItem* item); |
| 60 |
| 61 // Returns whether the operation was succesful. On success, the two arrays are |
| 62 // guaranteed to be equal length, and are populated with strings of |urls| and |
| 63 // |titles|. |
| 64 static bool URLsAndTitlesFromPasteboard(NSPasteboard* pboard, |
| 65 NSArray** urls, |
| 66 NSArray** titles); |
| 47 }; | 67 }; |
| 48 } | 68 } |
| 49 | 69 |
| 50 #endif // UI_BASE_CLIPBOARD_CLIPBOARD_UTIL_MAC_H_ | 70 #endif // UI_BASE_CLIPBOARD_CLIPBOARD_UTIL_MAC_H_ |
| OLD | NEW |