| Index: components/open_from_clipboard/clipboard_recent_content_ios.h
|
| diff --git a/components/open_from_clipboard/clipboard_recent_content_ios.h b/components/open_from_clipboard/clipboard_recent_content_ios.h
|
| index 5eba85a776ca9727af7499f954db03e2371f80f0..b0b893f6903850511897a60184f78cea71e25fd7 100644
|
| --- a/components/open_from_clipboard/clipboard_recent_content_ios.h
|
| +++ b/components/open_from_clipboard/clipboard_recent_content_ios.h
|
| @@ -6,10 +6,12 @@
|
| #define COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IOS_H_
|
|
|
| #include "base/mac/scoped_nsobject.h"
|
| +#include "base/time/time.h"
|
| #include "components/open_from_clipboard/clipboard_recent_content.h"
|
| #include "url/gurl.h"
|
|
|
| @class NSDate;
|
| +@class NSUserDefaults;
|
| @class PasteboardNotificationListenerBridge;
|
|
|
| class ClipboardRecentContentIOSTest;
|
| @@ -20,16 +22,28 @@ class ClipboardRecentContentIOS : public ClipboardRecentContent {
|
| // |application_scheme| is the URL scheme that can be used to open the
|
| // current application, may be empty if no such scheme exists. Used to
|
| // determine whether or not the clipboard contains a relevant URL.
|
| - explicit ClipboardRecentContentIOS(const std::string& application_scheme);
|
| + // |group_user_defaults| is the NSUserDefaults used to store information on
|
| + // pasteboard entry expiration. This information will be shared with other
|
| + // application in the application group.
|
| + explicit ClipboardRecentContentIOS(const std::string& application_scheme,
|
| + NSUserDefaults* group_user_defaults);
|
| ~ClipboardRecentContentIOS() override;
|
|
|
| // Notifies that the content of the pasteboard may have changed.
|
| void PasteboardChanged();
|
|
|
| + // Checks if pasteboard changed since last time a pasteboard change was
|
| + // registered.
|
| + bool HasPasteboardChanged(base::TimeDelta uptime);
|
| +
|
| + // Loads information from the user defaults about the latest pasteboard entry.
|
| + void LoadFromUserDefaults();
|
| +
|
| // ClipboardRecentContent implementation.
|
| bool GetRecentURLFromClipboard(GURL* url) const override;
|
| base::TimeDelta GetClipboardContentAge() const override;
|
| void SuppressClipboardContent() override;
|
| + void RecentURLDisplayed() override;
|
|
|
| private:
|
| friend class ClipboardRecentContentIOSTest;
|
| @@ -43,9 +57,6 @@ class ClipboardRecentContentIOS : public ClipboardRecentContent {
|
| // Initializes the object. |uptime| is how long ago the device has started.
|
| void Init(base::TimeDelta uptime);
|
|
|
| - // Loads information from the user defaults about the latest pasteboard entry.
|
| - void LoadFromUserDefaults();
|
| -
|
| // Saves information to the user defaults about the latest pasteboard entry.
|
| void SaveToUserDefaults();
|
|
|
| @@ -55,17 +66,21 @@ class ClipboardRecentContentIOS : public ClipboardRecentContent {
|
| // Contains the URL scheme opening the app. May be empty.
|
| std::string application_scheme_;
|
| // The pasteboard's change count. Increases everytime the pasteboard changes.
|
| - NSInteger lastPasteboardChangeCount_;
|
| + NSInteger last_pasteboard_change_count_;
|
| // Estimation of the date when the pasteboard changed.
|
| - base::scoped_nsobject<NSDate> lastPasteboardChangeDate_;
|
| + base::scoped_nsobject<NSDate> last_pasteboard_change_date_;
|
| + // Estimation of the copy date of the last displayed URL.
|
| + base::scoped_nsobject<NSDate> last_displayed_pasteboard_entry_;
|
| + // MD5 hash of the last registered pasteboard entry.
|
| + base::scoped_nsobject<NSData> last_pasteboard_entry_md5_;
|
| // Cache of the GURL contained in the pasteboard (if any).
|
| - GURL urlFromPasteboardCache_;
|
| - // A count identifying the suppressed pasteboard entry. Contains
|
| - // |NSIntegerMax| if there's no relevant entry to suppress.
|
| - NSInteger suppressedPasteboardEntryCount_;
|
| + GURL url_from_pasteboard_cache_;
|
| // Bridge to receive notification when the pasteboard changes.
|
| base::scoped_nsobject<PasteboardNotificationListenerBridge>
|
| - notificationBridge_;
|
| + notification_bridge_;
|
| + // The user defaults from the app group used to optimize the pasteboard change
|
| + // detection.
|
| + base::scoped_nsobject<NSUserDefaults> shared_user_defaults_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(ClipboardRecentContentIOS);
|
| };
|
|
|