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 // ClipboardRecentContent implementation.
30 bool GetRecentURLFromClipboard(GURL
* url
) const override
;
33 // Protected for testing.
34 ClipboardRecentContentIOS();
35 ~ClipboardRecentContentIOS() override
;
38 friend struct DefaultSingletonTraits
<ClipboardRecentContentIOS
>;
39 friend class test::ClipboardRecentContentIOSTestHelper
;
41 // Loads information from the user defaults about the latest pasteboard entry.
42 void LoadFromUserDefaults();
43 // Saves information to the user defaults about the latest pasteboard entry.
44 void SaveToUserDefaults();
45 // Returns the URL contained in the clipboard (if any).
46 GURL
URLFromPasteboard();
47 // Returns whether the device has restarted since the last time a pasteboard
48 // change was detected.
49 bool DeviceRestartedSincePasteboardChanged();
51 // The pasteboard's change count. Increases everytime the pasteboard changes.
52 NSInteger lastPasteboardChangeCount_
;
53 // Estimation of the date when the pasteboard changed.
54 base::scoped_nsobject
<NSDate
> lastPasteboardChangeDate_
;
55 // Cache of the GURL contained in the pasteboard (if any).
56 GURL urlFromPasteboardCache_
;
57 // Bridge to receive notification when the pasteboard changes.
58 base::scoped_nsobject
<PasteboardNotificationListenerBridge
>
61 DISALLOW_COPY_AND_ASSIGN(ClipboardRecentContentIOS
);
64 #endif // COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IOS_H_