OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IMPL_IOS_H_ |
| 6 #define COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IMPL_IOS_H_ |
| 7 |
| 8 #import <Foundation/Foundation.h> |
| 9 |
| 10 // A protocol implemented by delegates to handle clipboard changes. |
| 11 @protocol ClipboardRecentContentDelegate<NSObject> |
| 12 |
| 13 - (void)onClipboardChanged; |
| 14 |
| 15 @end |
| 16 |
| 17 // Helper class returning a URL if the content of the clipboard can be turned |
| 18 // into a URL, and if it estimates that the content of the clipboard is not too |
| 19 // old. |
| 20 @interface ClipboardRecentContentImplIOS : NSObject |
| 21 |
| 22 // |delegate| is used for metrics logging and can be nil. |authorizedSchemes| |
| 23 // should contain all schemes considered valid. |groupUserDefaults| is the |
| 24 // NSUserDefaults used to store information on pasteboard entry expiration. This |
| 25 // information will be shared with other applications in the application group. |
| 26 - (instancetype)initWithAuthorizedSchemes:(NSSet<NSString*>*)authorizedSchemes |
| 27 userDefaults:(NSUserDefaults*)groupUserDefaults |
| 28 delegate:(id<ClipboardRecentContentDelegate>) |
| 29 delegate |
| 30 NS_DESIGNATED_INITIALIZER; |
| 31 |
| 32 - (instancetype)init NS_UNAVAILABLE; |
| 33 |
| 34 // Returns the copied URL if the clipboard contains a recent URL that has not |
| 35 // been supressed. Otherwise, returns nil. |
| 36 - (NSURL*)recentURLFromClipboard; |
| 37 |
| 38 // Returns how old the content of the clipboard is. |
| 39 - (NSTimeInterval)clipboardContentAge; |
| 40 |
| 41 // Prevents GetRecentURLFromClipboard from returning anything until the |
| 42 // clipboard's content changes. |
| 43 - (void)suppressClipboardContent; |
| 44 |
| 45 // Methods below are exposed for testing purposes. |
| 46 |
| 47 // Estimation of the date when the pasteboard changed. |
| 48 @property(nonatomic, strong) NSDate* lastPasteboardChangeDate; |
| 49 |
| 50 // Saves information to the user defaults about the latest pasteboard entry. |
| 51 - (void)saveToUserDefaults; |
| 52 |
| 53 @end |
| 54 |
| 55 #endif // COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IMPL_IOS_H_ |
OLD | NEW |