1 // Copyright 2015 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.
5 #ifndef COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IOS_H_
6 #define COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IOS_H_
8 #include "base/mac/scoped_nsobject.h"
9 #include "components/open_from_clipboard/clipboard_recent_content.h"
13 @
class PasteboardNotificationListenerBridge
;
16 class ClipboardRecentContentIOSTestHelper
;
20 struct DefaultSingletonTraits
;
22 // IOS implementation of ClipboardRecentContent
23 class ClipboardRecentContentIOS
: public ClipboardRecentContent
{
25 static ClipboardRecentContentIOS
* GetInstance();
26 // Notifies that the content of the pasteboard may have changed.
27 void PasteboardChanged();
29 bool GetRecentURLFromClipboard(GURL
* url
) const override
;
31 base::TimeDelta
GetClipboardContentAge() const override
;
33 void SuppressClipboardContent() override
;
36 // Protected for testing.
37 ClipboardRecentContentIOS();
38 ~ClipboardRecentContentIOS() override
;
39 // |uptime| is how long ago the device has started.
40 ClipboardRecentContentIOS(base::TimeDelta uptime
);
43 friend struct DefaultSingletonTraits
<ClipboardRecentContentIOS
>;
44 friend class test::ClipboardRecentContentIOSTestHelper
;
45 // Initializes the object. |uptime| is how long ago the device has started.
46 void Init(base::TimeDelta uptime
);
47 // Loads information from the user defaults about the latest pasteboard entry.
48 void LoadFromUserDefaults();
49 // Saves information to the user defaults about the latest pasteboard entry.
50 void SaveToUserDefaults();
51 // Returns the URL contained in the clipboard (if any).
52 GURL
URLFromPasteboard();
54 // The pasteboard's change count. Increases everytime the pasteboard changes.
55 NSInteger lastPasteboardChangeCount_
;
56 // Estimation of the date when the pasteboard changed.
57 base::scoped_nsobject
<NSDate
> lastPasteboardChangeDate_
;
58 // Cache of the GURL contained in the pasteboard (if any).
59 GURL urlFromPasteboardCache_
;
60 // A count identifying the suppressed pasteboard entry. Contains
61 // |NSIntegerMax| if there's no relevant entry to suppress.
62 NSInteger suppressedPasteboardEntryCount_
;
63 // Bridge to receive notification when the pasteboard changes.
64 base::scoped_nsobject
<PasteboardNotificationListenerBridge
>
67 DISALLOW_COPY_AND_ASSIGN(ClipboardRecentContentIOS
);
70 #endif // COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IOS_H_