OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IOS_H_ | 5 #ifndef COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IOS_H_ |
6 #define COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IOS_H_ | 6 #define COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IOS_H_ |
7 | 7 |
8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
9 #include "components/open_from_clipboard/clipboard_recent_content.h" | 9 #include "components/open_from_clipboard/clipboard_recent_content.h" |
10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
11 | 11 |
12 @class NSDate; | 12 @class NSDate; |
13 @class PasteboardNotificationListenerBridge; | 13 @class PasteboardNotificationListenerBridge; |
14 | 14 |
| 15 namespace test { |
| 16 class ClipboardRecentContentIOSTestHelper; |
| 17 } |
| 18 |
15 template <typename T> | 19 template <typename T> |
16 struct DefaultSingletonTraits; | 20 struct DefaultSingletonTraits; |
17 | 21 |
18 // IOS implementation of ClipboardRecentContent | 22 // IOS implementation of ClipboardRecentContent |
19 class ClipboardRecentContentIOS : public ClipboardRecentContent { | 23 class ClipboardRecentContentIOS : public ClipboardRecentContent { |
20 public: | 24 public: |
21 static ClipboardRecentContentIOS* GetInstance(); | 25 static ClipboardRecentContentIOS* GetInstance(); |
22 // Notifies that the content of the pasteboard may have changed. | 26 // Notifies that the content of the pasteboard may have changed. |
23 void PasteboardChanged(); | 27 void PasteboardChanged(); |
24 | 28 |
25 // ClipboardRecentContent implementation. | 29 // ClipboardRecentContent implementation. |
26 bool GetRecentURLFromClipboard(GURL* url) const override; | 30 bool GetRecentURLFromClipboard(GURL* url) const override; |
27 | 31 |
| 32 protected: |
| 33 // Protected for testing. |
| 34 ClipboardRecentContentIOS(); |
| 35 ~ClipboardRecentContentIOS() override; |
| 36 |
28 private: | 37 private: |
29 friend struct DefaultSingletonTraits<ClipboardRecentContentIOS>; | 38 friend struct DefaultSingletonTraits<ClipboardRecentContentIOS>; |
| 39 friend class test::ClipboardRecentContentIOSTestHelper; |
30 | 40 |
31 ClipboardRecentContentIOS(); | |
32 ~ClipboardRecentContentIOS() override; | |
33 // Loads information from the user defaults about the latest pasteboard entry. | 41 // Loads information from the user defaults about the latest pasteboard entry. |
34 void LoadFromUserDefaults(); | 42 void LoadFromUserDefaults(); |
35 // Saves information to the user defaults about the latest pasteboard entry. | 43 // Saves information to the user defaults about the latest pasteboard entry. |
36 void SaveToUserDefaults(); | 44 void SaveToUserDefaults(); |
37 // Returns the URL contained in the clipboard (if any). | 45 // Returns the URL contained in the clipboard (if any). |
38 GURL URLFromPasteboard(); | 46 GURL URLFromPasteboard(); |
39 // Returns whether the device has restarted since the last time a pasteboard | 47 // Returns whether the device has restarted since the last time a pasteboard |
40 // change was detected. | 48 // change was detected. |
41 bool DeviceRestartedSincePasteboardChanged(); | 49 bool DeviceRestartedSincePasteboardChanged(); |
42 | 50 |
43 // The pasteboard's change count. Increases everytime the pasteboard changes. | 51 // The pasteboard's change count. Increases everytime the pasteboard changes. |
44 NSInteger lastPasteboardChangeCount_; | 52 NSInteger lastPasteboardChangeCount_; |
45 // Estimation of the date when the pasteboard changed. | 53 // Estimation of the date when the pasteboard changed. |
46 base::scoped_nsobject<NSDate> lastPasteboardChangeDate_; | 54 base::scoped_nsobject<NSDate> lastPasteboardChangeDate_; |
47 // Cache of the GURL contained in the pasteboard (if any). | 55 // Cache of the GURL contained in the pasteboard (if any). |
48 GURL urlFromPasteboardCache_; | 56 GURL urlFromPasteboardCache_; |
49 // Bridge to receive notification when the pasteboard changes. | 57 // Bridge to receive notification when the pasteboard changes. |
50 base::scoped_nsobject<PasteboardNotificationListenerBridge> | 58 base::scoped_nsobject<PasteboardNotificationListenerBridge> |
51 notificationBridge_; | 59 notificationBridge_; |
52 | 60 |
53 DISALLOW_COPY_AND_ASSIGN(ClipboardRecentContentIOS); | 61 DISALLOW_COPY_AND_ASSIGN(ClipboardRecentContentIOS); |
54 }; | 62 }; |
55 | 63 |
56 #endif // COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IOS_H_ | 64 #endif // COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IOS_H_ |
OLD | NEW |