Chromium Code Reviews| Index: third_party/mozilla/NSPasteboard+Utils.mm |
| diff --git a/third_party/mozilla/NSPasteboard+Utils.mm b/third_party/mozilla/NSPasteboard+Utils.mm |
| index 0af5c48361ed0bec9d6367b7dd84eae450299e5a..93c55c34a3fb034fc529e3bbb06ead9e8048f603 100644 |
| --- a/third_party/mozilla/NSPasteboard+Utils.mm |
| +++ b/third_party/mozilla/NSPasteboard+Utils.mm |
| @@ -80,7 +80,7 @@ NSString* const kWebURLsWithTitlesPboardType = @"WebURLsWithTitlesPboardType"; |
| kCorePasteboardFlavorType_url, |
| kCorePasteboardFlavorType_urln, |
| nil]]; |
| - return [self declareTypes:allTypes owner:newOwner]; |
| + return [self declareTypes:allTypes owner:newOwner]; |
| } |
| // |
| @@ -172,10 +172,9 @@ NSString* const kWebURLsWithTitlesPboardType = @"WebURLsWithTitlesPboardType"; |
| // The arrays returned are on the auto release pool. If |convertFilenames| |
| // is YES, then the function will attempt to convert filenames in the drag |
| // to file URLs. |
| -- (void) getURLs:(NSArray**)outUrls |
| - andTitles:(NSArray**)outTitles |
| - convertingFilenames:(BOOL)convertFilenames |
| -{ |
| +- (void)getURLsFromType:(NSArray**)outUrls |
| + andTitles:(NSArray**)outTitles |
| + convertingFilenames:(BOOL)convertFilenames { |
| NSArray* types = [self types]; |
| NSURL* urlFromNSURL = nil; // Used below in getting an URL from the NSURLPboardType. |
| if ([types containsObject:kWebURLsWithTitlesPboardType]) { |
| @@ -231,8 +230,29 @@ NSString* const kWebURLsWithTitlesPboardType = @"WebURLsWithTitlesPboardType"; |
| if (!title && [types containsObject:NSStringPboardType]) |
| title = [self stringForType:NSStringPboardType]; |
| *outTitles = [NSArray arrayWithObject:(title ? title : @"")]; |
| - } else if ([types containsObject:NSStringPboardType]) { |
| - NSString* potentialURLString = [self cleanedStringWithPasteboardString:[self stringForType:NSStringPboardType]]; |
| + } else { |
| + // We don't recognise any of these formats - return empty arrays |
| + *outUrls = [NSArray array]; |
| + *outTitles = [NSArray array]; |
| + } |
| +} |
| + |
| +- (void)getURLsFromTypeOrText:(NSArray**)outUrls |
|
Mark Mentovai
2016/05/26 20:21:51
GetURLsOrTextFromType
|
| + andTitles:(NSArray**)outTitles |
|
Mark Mentovai
2016/05/26 20:21:51
align colons
|
| + convertingFilenames:(BOOL)convertFilenames |
| +{ |
| + if ([self containsURLDataInType]) { |
| + [self getURLsFromType:outUrls |
| + andTitles:outTitles |
|
Mark Mentovai
2016/05/26 20:21:51
align colons
|
| + convertingFilenames:convertFilenames]; |
| + return; |
| + } |
| + |
| + NSArray* types = [self types]; |
| + if ([types containsObject:NSStringPboardType]) { |
| + NSString* potentialURLString = |
| + [self cleanedStringWithPasteboardString: |
| + [self stringForType:NSStringPboardType]]; |
| if ([potentialURLString isValidURI]) { |
| *outUrls = [NSArray arrayWithObject:potentialURLString]; |
| NSString* title = nil; |
| @@ -246,13 +266,8 @@ NSString* const kWebURLsWithTitlesPboardType = @"WebURLsWithTitlesPboardType"; |
| *outUrls = [NSArray array]; |
| *outTitles = [NSArray array]; |
| } |
| - } else { |
| - // We don't recognise any of these formats - return empty arrays |
| - *outUrls = [NSArray array]; |
| - *outTitles = [NSArray array]; |
| } |
| } |
| - |
| // |
| // Indicates if this pasteboard contains URL data that we understand |
| // Deals with all our URL formats. Only strings that are valid URLs count. |
| @@ -261,21 +276,24 @@ NSString* const kWebURLsWithTitlesPboardType = @"WebURLsWithTitlesPboardType"; |
| // NB: Does not consider our internal bookmark list format, because callers |
| // usually need to deal with this separately because it can include folders etc. |
| // |
| -- (BOOL) containsURLData |
| +- (BOOL)containsURLDataInType |
| { |
| NSArray* types = [self types]; |
| - if ( [types containsObject:kWebURLsWithTitlesPboardType] |
| - || [types containsObject:NSURLPboardType] |
| - || [types containsObject:NSFilenamesPboardType] ) |
| + return [types containsObject:kWebURLsWithTitlesPboardType] || |
| + [types containsObject:NSURLPboardType] || |
| + [types containsObject:NSFilenamesPboardType]; |
| +} |
| + |
| +- (BOOL) containsURLDataInTypeOrText |
| +{ |
| + if([self containsURLDataInType]) |
| return YES; |
| - |
| - if ([types containsObject:NSStringPboardType]) { |
| + if ([[self types] containsObject:NSStringPboardType]) { |
| // Trim whitespace off the ends and newlines out of the middle so we don't reject otherwise-valid URLs; |
| // we'll do another cleaning when we set the URLs and titles later, so this is safe. |
| NSString* potentialURLString = [self cleanedStringWithPasteboardString:[self stringForType:NSStringPboardType]]; |
| return [potentialURLString isValidURI]; |
| } |
| - |
| return NO; |
| } |
| @end |