Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: ui/base/clipboard/clipboard_util_mac.mm

Issue 1857843002: mac: Fix copying from the Omnibox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/base/clipboard/clipboard_mac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « ui/base/clipboard/clipboard_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698