Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(322)

Unified Diff: components/open_from_clipboard/clipboard_recent_content_impl_ios.h

Issue 2782823003: Rewrite implementation of ClipboardRecentContent in Objective C. (Closed)
Patch Set: sdefresne's comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/open_from_clipboard/clipboard_recent_content_impl_ios.h
diff --git a/components/open_from_clipboard/clipboard_recent_content_impl_ios.h b/components/open_from_clipboard/clipboard_recent_content_impl_ios.h
new file mode 100644
index 0000000000000000000000000000000000000000..619e1d9f1e578c26a24bc3b1994eb0f3aeafc67e
--- /dev/null
+++ b/components/open_from_clipboard/clipboard_recent_content_impl_ios.h
@@ -0,0 +1,56 @@
+// 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.
+
+#ifndef COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IMPL_IOS_H_
+#define COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IMPL_IOS_H_
+
+#import <Foundation/Foundation.h>
+
+// A protocol implemented by delegates to handle clipboard changes.
+@protocol ClipboardRecentContentDelegate<NSObject>
+
+- (void)onClipboardChanged;
+
+@end
+
+// Helper class returning a URL if the content of the clipboard can be turned
+// into a URL, and if it estimates that the content of the clipboard is not too
+// old.
+@interface ClipboardRecentContentImplIOS : NSObject
+
+// |delegate| is used for metrics logging and can be nil. |authorizedSchemes|
+// should contain all schemes considered valid. |groupUserDefaults| is the
+// NSUserDefaults used to store information on pasteboard entry expiration. This
+// information will be shared with other applications in the application group.
+- (instancetype)initWithAuthorizedSchemes:(NSSet*)authorizedSchemes
marq (ping after 24h) 2017/04/05 07:58:10 Use lightweight generics -- NSSet<NSString*>*
lody 2017/04/06 11:27:22 Done.
+ userDefaults:(NSUserDefaults*)groupUserDefaults
+ delegate:(id<ClipboardRecentContentDelegate>)
+ delegate
+ NS_DESIGNATED_INITIALIZER;
+
+- (instancetype)init NS_UNAVAILABLE;
+
+// Returns true if the clipboard contains a recent URL that has not been
marq (ping after 24h) 2017/04/05 07:58:10 This method doesn't return a boolean at all.
lody 2017/04/06 11:27:22 ... sorry :( that's what I get for lazy copy pasti
+// supressed, and copies it in |url|. Otherwise, returns false. |url| must not
+// be null.
+- (NSURL*)getRecentURLFromClipboard;
marq (ping after 24h) 2017/04/05 07:58:10 Don't use 'get' to name ObjC methods unless they
lody 2017/04/06 11:27:21 Done (also, that links gives a sorry, that page ca
marq (ping after 24h) 2017/04/06 14:40:56 It should be .html, not .htm : https://developer.a
+
+// Returns how old the content of the clipboard is.
+- (NSTimeInterval)getClipboardContentAge;
+
+// Prevent GetRecentURLFromClipboard from returning anything until the
marq (ping after 24h) 2017/04/05 07:58:10 Prevents
lody 2017/04/06 11:27:21 Done.
+// clipboard's content changes.
+- (void)suppressClipboardContent;
+
+// Methods below are exposed for testing purposes.
+
+// Estimation of the date when the pasteboard changed.
+@property(nonatomic, strong) NSDate* lastPasteboardChangeDate;
+
+// Saves information to the user defaults about the latest pasteboard entry.
+- (void)saveToUserDefaults;
+
+@end
+
+#endif // COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IMPL_IOS_H_

Powered by Google App Engine
This is Rietveld 408576698