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 namespace test { | |
sdefresne
2015/02/26 16:36:00
nit: blank line before
jif
2015/03/03 14:37:59
Done.
| |
15 class ClipboardRecentContentIOSTestHelper; | |
16 } | |
14 | 17 |
15 template <typename T> | 18 template <typename T> |
16 struct DefaultSingletonTraits; | 19 struct DefaultSingletonTraits; |
17 | 20 |
18 // IOS implementation of ClipboardRecentContent | 21 // IOS implementation of ClipboardRecentContent |
19 class ClipboardRecentContentIOS : public ClipboardRecentContent { | 22 class ClipboardRecentContentIOS : public ClipboardRecentContent { |
20 public: | 23 public: |
21 static ClipboardRecentContentIOS* GetInstance(); | 24 static ClipboardRecentContentIOS* GetInstance(); |
22 // Notifies that the content of the pasteboard may have changed. | 25 // Notifies that the content of the pasteboard may have changed. |
23 void PasteboardChanged(); | 26 void PasteboardChanged(); |
24 | 27 |
25 // ClipboardRecentContent implementation. | 28 // ClipboardRecentContent implementation. |
26 bool GetRecentURLFromClipboard(GURL* url) const override; | 29 bool GetRecentURLFromClipboard(GURL* url) const override; |
27 | 30 |
31 protected: | |
32 // Protected for testing. | |
33 ClipboardRecentContentIOS(); | |
34 ~ClipboardRecentContentIOS() override; | |
35 | |
28 private: | 36 private: |
29 friend struct DefaultSingletonTraits<ClipboardRecentContentIOS>; | 37 friend struct DefaultSingletonTraits<ClipboardRecentContentIOS>; |
38 friend class test::ClipboardRecentContentIOSTestHelper; | |
30 | 39 |
31 ClipboardRecentContentIOS(); | |
32 ~ClipboardRecentContentIOS() override; | |
33 // Loads information from the user defaults about the latest pasteboard entry. | 40 // Loads information from the user defaults about the latest pasteboard entry. |
34 void LoadFromUserDefaults(); | 41 void LoadFromUserDefaults(); |
35 // Saves information to the user defaults about the latest pasteboard entry. | 42 // Saves information to the user defaults about the latest pasteboard entry. |
36 void SaveToUserDefaults(); | 43 void SaveToUserDefaults(); |
37 // Returns the URL contained in the clipboard (if any). | 44 // Returns the URL contained in the clipboard (if any). |
38 GURL URLFromPasteboard(); | 45 GURL URLFromPasteboard(); |
39 // Returns whether the device has restarted since the last time a pasteboard | 46 // Returns whether the device has restarted since the last time a pasteboard |
40 // change was detected. | 47 // change was detected. |
41 bool DeviceRestartedSincePasteboardChanged(); | 48 bool DeviceRestartedSincePasteboardChanged(); |
42 | 49 |
43 // The pasteboard's change count. Increases everytime the pasteboard changes. | 50 // The pasteboard's change count. Increases everytime the pasteboard changes. |
44 NSInteger lastPasteboardChangeCount_; | 51 NSInteger lastPasteboardChangeCount_; |
45 // Estimation of the date when the pasteboard changed. | 52 // Estimation of the date when the pasteboard changed. |
46 base::scoped_nsobject<NSDate> lastPasteboardChangeDate_; | 53 base::scoped_nsobject<NSDate> lastPasteboardChangeDate_; |
47 // Cache of the GURL contained in the pasteboard (if any). | 54 // Cache of the GURL contained in the pasteboard (if any). |
48 GURL urlFromPasteboardCache_; | 55 GURL urlFromPasteboardCache_; |
49 // Bridge to receive notification when the pasteboard changes. | 56 // Bridge to receive notification when the pasteboard changes. |
50 base::scoped_nsobject<PasteboardNotificationListenerBridge> | 57 base::scoped_nsobject<PasteboardNotificationListenerBridge> |
51 notificationBridge_; | 58 notificationBridge_; |
52 | 59 |
53 DISALLOW_COPY_AND_ASSIGN(ClipboardRecentContentIOS); | 60 DISALLOW_COPY_AND_ASSIGN(ClipboardRecentContentIOS); |
54 }; | 61 }; |
55 | 62 |
56 #endif // COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IOS_H_ | 63 #endif // COMPONENTS_OPEN_FROM_CLIPBOARD_CLIPBOARD_RECENT_CONTENT_IOS_H_ |
OLD | NEW |