OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #import "ios/chrome/browser/ui/util/pasteboard_util.h" | 5 #import "ios/chrome/browser/ui/util/pasteboard_util.h" |
6 | 6 |
7 #import <MobileCoreServices/MobileCoreServices.h> | 7 #import <MobileCoreServices/MobileCoreServices.h> |
8 #import <UIKit/UIKit.h> | 8 #import <UIKit/UIKit.h> |
9 | 9 |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
11 #import "net/base/mac/url_conversions.h" | 11 #import "net/base/mac/url_conversions.h" |
12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
13 | 13 |
| 14 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 15 #error "This file requires ARC support." |
| 16 #endif |
| 17 |
14 void StoreURLInPasteboard(const GURL& URL) { | 18 void StoreURLInPasteboard(const GURL& URL) { |
15 DCHECK(URL.is_valid()); | 19 DCHECK(URL.is_valid()); |
16 NSData* plainText = [base::SysUTF8ToNSString(URL.spec()) | 20 NSData* plainText = [base::SysUTF8ToNSString(URL.spec()) |
17 dataUsingEncoding:NSUTF8StringEncoding]; | 21 dataUsingEncoding:NSUTF8StringEncoding]; |
18 NSDictionary* copiedItem = @{ | 22 NSDictionary* copiedItem = @{ |
19 (NSString*)kUTTypeURL : net::NSURLWithGURL(URL), | 23 (NSString*)kUTTypeURL : net::NSURLWithGURL(URL), |
20 (NSString*)kUTTypeUTF8PlainText : plainText, | 24 (NSString*)kUTTypeUTF8PlainText : plainText, |
21 }; | 25 }; |
22 [[UIPasteboard generalPasteboard] setItems:@[ copiedItem ]]; | 26 [[UIPasteboard generalPasteboard] setItems:@[ copiedItem ]]; |
23 } | 27 } |
OLD | NEW |