diff --git a/components/open_from_clipboard/clipboard_recent_content_impl_ios.mm b/components/open_from_clipboard/clipboard_recent_content_impl_ios.mm index 2fe3035d0153a1..7f3573f5797255 100644 --- a/components/open_from_clipboard/clipboard_recent_content_impl_ios.mm +++ b/components/open_from_clipboard/clipboard_recent_content_impl_ios.mm @@ -28,6 +28,8 @@ // Key used to store the last date at which it was detected that the pasteboard // changed. It is used to evaluate the age of the pasteboard's content. NSString* const kPasteboardChangeDateKey = @"PasteboardChangeDate"; +// Default Scheme to use for urls with no scheme. +NSString* const kDefaultScheme = @"https"; } // namespace @@ -392,6 +394,16 @@ - (void)recentURLFromClipboardAsync:(void (^)(NSURL*))callback { URLWithString: values[UIPasteboardDetectionPatternProbableWebURL]]; + // |detectValuesForPatterns:| will return a url even if the url + // is missing a scheme. In this case, default to https. + if (url.scheme == nil) { + NSURLComponents* components = + [[NSURLComponents alloc] initWithURL:url + resolvingAgainstBaseURL:NO]; + components.scheme = kDefaultScheme; + url = components.URL; + } + if (![self.authorizedSchemes containsObject:url.scheme]) { weakSelf.cachedURL = nil; callback(nil);