| 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 #include "ui/base/clipboard/clipboard_util_mac.h" | 5 #include "ui/base/clipboard/clipboard_util_mac.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #include "base/mac/scoped_cftyperef.h" | 8 #include "base/mac/scoped_cftyperef.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // https://github.com/WebKit/webkit/blob/master/Source/WebCore/platform/mac/Pl
atformPasteboardMac.mm | 60 // https://github.com/WebKit/webkit/blob/master/Source/WebCore/platform/mac/Pl
atformPasteboardMac.mm |
| 61 NSURL* base = [url baseURL]; | 61 NSURL* base = [url baseURL]; |
| 62 if (base) { | 62 if (base) { |
| 63 [item setPropertyList:@[ [url relativeString], [base absoluteString] ] | 63 [item setPropertyList:@[ [url relativeString], [base absoluteString] ] |
| 64 forType:UTIFromPboardType(NSURLPboardType)]; | 64 forType:UTIFromPboardType(NSURLPboardType)]; |
| 65 } else if (url) { | 65 } else if (url) { |
| 66 [item setPropertyList:@[ [url absoluteString], @"" ] | 66 [item setPropertyList:@[ [url absoluteString], @"" ] |
| 67 forType:UTIFromPboardType(NSURLPboardType)]; | 67 forType:UTIFromPboardType(NSURLPboardType)]; |
| 68 } | 68 } |
| 69 | 69 |
| 70 [item setString:urlString forType:UTIFromPboardType(NSStringPboardType)]; | 70 [item setString:urlString forType:NSPasteboardTypeString]; |
| 71 | 71 |
| 72 [item setData:[urlString dataUsingEncoding:NSUTF8StringEncoding] | 72 [item setData:[urlString dataUsingEncoding:NSUTF8StringEncoding] |
| 73 forType:UTIFromPboardType(kCorePasteboardFlavorType_url)]; | 73 forType:UTIFromPboardType(kCorePasteboardFlavorType_url)]; |
| 74 | 74 |
| 75 [item setData:[title dataUsingEncoding:NSUTF8StringEncoding] | 75 [item setData:[title dataUsingEncoding:NSUTF8StringEncoding] |
| 76 forType:UTIFromPboardType(kCorePasteboardFlavorType_urln)]; | 76 forType:UTIFromPboardType(kCorePasteboardFlavorType_urln)]; |
| 77 return item; | 77 return item; |
| 78 } | 78 } |
| 79 | 79 |
| 80 // static | 80 // static |
| 81 base::scoped_nsobject<NSPasteboardItem> ClipboardUtil::PasteboardItemFromUrls( | 81 base::scoped_nsobject<NSPasteboardItem> ClipboardUtil::PasteboardItemFromUrls( |
| 82 NSArray* urls, | 82 NSArray* urls, |
| 83 NSArray* titles) { | 83 NSArray* titles) { |
| 84 base::scoped_nsobject<NSPasteboardItem> item([[NSPasteboardItem alloc] init]); | 84 base::scoped_nsobject<NSPasteboardItem> item([[NSPasteboardItem alloc] init]); |
| 85 | 85 |
| 86 // Set Safari's URL + title arrays Pboard type. | 86 // Set Safari's URL + title arrays Pboard type. |
| 87 NSArray* urlsAndTitles = @[ urls, titles ]; | 87 NSArray* urlsAndTitles = @[ urls, titles ]; |
| 88 [item setPropertyList:urlsAndTitles | 88 [item setPropertyList:urlsAndTitles |
| 89 forType:UTIFromPboardType(kWebURLsWithTitlesPboardType)]; | 89 forType:UTIFromPboardType(kWebURLsWithTitlesPboardType)]; |
| 90 | 90 |
| 91 return item; | 91 return item; |
| 92 } | 92 } |
| 93 | 93 |
| 94 // static | 94 // static |
| 95 base::scoped_nsobject<NSPasteboardItem> ClipboardUtil::PasteboardItemFromString( | 95 base::scoped_nsobject<NSPasteboardItem> ClipboardUtil::PasteboardItemFromString( |
| 96 NSString* string) { | 96 NSString* string) { |
| 97 base::scoped_nsobject<NSPasteboardItem> item([[NSPasteboardItem alloc] init]); | 97 base::scoped_nsobject<NSPasteboardItem> item([[NSPasteboardItem alloc] init]); |
| 98 [item setString:string forType:UTIFromPboardType(NSStringPboardType)]; | 98 [item setString:string forType:NSPasteboardTypeString]; |
| 99 return item; | 99 return item; |
| 100 } | 100 } |
| 101 | 101 |
| 102 //static | 102 //static |
| 103 NSString* ClipboardUtil::GetTitleFromPasteboardURL(NSPasteboard* pboard) { | 103 NSString* ClipboardUtil::GetTitleFromPasteboardURL(NSPasteboard* pboard) { |
| 104 return | 104 return |
| 105 [pboard stringForType:UTIFromPboardType(kCorePasteboardFlavorType_urln)]; | 105 [pboard stringForType:UTIFromPboardType(kCorePasteboardFlavorType_urln)]; |
| 106 } | 106 } |
| 107 | 107 |
| 108 //static | 108 //static |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 if (![obj isKindOfClass:[NSString class]]) | 170 if (![obj isKindOfClass:[NSString class]]) |
| 171 return false; | 171 return false; |
| 172 } | 172 } |
| 173 | 173 |
| 174 *urls = urlsArr; | 174 *urls = urlsArr; |
| 175 *titles = titlesArr; | 175 *titles = titlesArr; |
| 176 return true; | 176 return true; |
| 177 } | 177 } |
| 178 | 178 |
| 179 } // namespace ui | 179 } // namespace ui |
| OLD | NEW |