[Media Router] Add integration tests and e2e tests for media router and presentation...
[chromium-blink-merge.git] / components / open_from_clipboard / clipboard_recent_content_ios.h
blobb3d001dd4b09926e56f30a3e3c6298a00463ca3d
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;
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 protected:
34 // Protected for testing.
35 ClipboardRecentContentIOS();
36 ~ClipboardRecentContentIOS() override;
38 private:
39 friend struct DefaultSingletonTraits<ClipboardRecentContentIOS>;
40 friend class test::ClipboardRecentContentIOSTestHelper;
42 // Loads information from the user defaults about the latest pasteboard entry.
43 void LoadFromUserDefaults();
44 // Saves information to the user defaults about the latest pasteboard entry.
45 void SaveToUserDefaults();
46 // Returns the URL contained in the clipboard (if any).
47 GURL URLFromPasteboard();
48 // Returns whether the device has restarted since the last time a pasteboard
49 // change was detected.
50 bool DeviceRestartedSincePasteboardChanged();
52 // The pasteboard's change count. Increases everytime the pasteboard changes.
53 NSInteger lastPasteboardChangeCount_;
54 // Estimation of the date when the pasteboard changed.
55 base::scoped_nsobject<NSDate> lastPasteboardChangeDate_;
56 // Cache of the GURL contained in the pasteboard (if any).
57 GURL urlFromPasteboardCache_;
58 // Bridge to receive notification when the pasteboard changes.
59 base::scoped_nsobject<PasteboardNotificationListenerBridge>
60 notificationBridge_;
62 DISALLOW_COPY_AND_ASSIGN(ClipboardRecentContentIOS);
65 #endif // COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IOS_H_