Chromium Code Reviews| Index: ios/chrome/browser/ui/clipboard_util.mm |
| diff --git a/ios/chrome/browser/ui/clipboard_util.mm b/ios/chrome/browser/ui/clipboard_util.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7f6c816f5fb46c7f9fe8cc6c2668bce0729518aa |
| --- /dev/null |
| +++ b/ios/chrome/browser/ui/clipboard_util.mm |
| @@ -0,0 +1,23 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import "ios/chrome/browser/ui/clipboard_util.h" |
| + |
| +#import <MobileCoreServices/MobileCoreServices.h> |
| +#import <UIKit/UIKit.h> |
| + |
| +#include "base/strings/sys_string_conversions.h" |
| +#import "net/base/mac/url_conversions.h" |
| +#include "url/gurl.h" |
| + |
| +void StoreURLInPasteboard(const GURL& URL) { |
|
Olivier
2017/02/01 12:22:05
nit:
choose pasteboard or clipboard for name of me
gambard
2017/02/01 17:13:37
Done.
|
| + DCHECK(URL.is_valid()); |
| + NSData* plainText = [base::SysUTF8ToNSString(URL.spec()) |
| + dataUsingEncoding:NSUTF8StringEncoding]; |
| + NSDictionary* copiedItem = @{ |
| + (NSString*)kUTTypeURL : net::NSURLWithGURL(URL), |
| + (NSString*)kUTTypeUTF8PlainText : plainText, |
| + }; |
| + [[UIPasteboard generalPasteboard] setItems:@[ copiedItem ]]; |
| +} |