[AndroidWebViewShell] Replace rebaseline script with a new version using test_runner.py
[chromium-blink-merge.git] / components / open_from_clipboard / clipboard_recent_content_ios.h
blobe2050b6dac13d88692395f175a9a676855da0c49
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"
10 #include "url/gurl.h"
12 @class NSDate;
13 @class PasteboardNotificationListenerBridge;
15 namespace test {
16 class ClipboardRecentContentIOSTestHelper;
17 } // namespace test
19 template <typename T>
20 struct DefaultSingletonTraits;
22 // IOS implementation of ClipboardRecentContent
23 class ClipboardRecentContentIOS : public ClipboardRecentContent {
24 public:
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;
35 protected:
36 // Protected for testing.
37 ClipboardRecentContentIOS();
38 ~ClipboardRecentContentIOS() override;
39 // |uptime| is how long ago the device has started.
40 ClipboardRecentContentIOS(base::TimeDelta uptime);
42 private:
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>
65 notificationBridge_;
67 DISALLOW_COPY_AND_ASSIGN(ClipboardRecentContentIOS);
70 #endif // COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IOS_H_