Index: components/open_from_clipboard/clipboard_recent_content_ios.h |
diff --git a/components/open_from_clipboard/clipboard_recent_content_ios.h b/components/open_from_clipboard/clipboard_recent_content_ios.h |
index d4b7d7ec831d06bd80e46dea4e7c04f23f0e2080..abbf510182e92e15c77756bcfc6078ebc34dd165 100644 |
--- a/components/open_from_clipboard/clipboard_recent_content_ios.h |
+++ b/components/open_from_clipboard/clipboard_recent_content_ios.h |
@@ -11,13 +11,16 @@ |
#include "components/open_from_clipboard/clipboard_recent_content.h" |
#include "url/gurl.h" |
+@class NSArray; |
@class NSDate; |
@class NSUserDefaults; |
-@class ApplicationDidBecomeActiveNotificationListenerBridge; |
+@class ClipboardRecentContentImplIOS; |
-class ClipboardRecentContentIOSTest; |
- |
-// IOS implementation of ClipboardRecentContent |
+// IOS implementation of ClipboardRecentContent. |
+// A large part of the implementation is in clipboard_recent_content_impl_ios, |
+// a GURL-free class that is used by some of the iOS extensions. Not using GURL |
+// in extensions is preferable as GURL requires depending on ICU which makes the |
+// extensions much larger. |
class ClipboardRecentContentIOS : public ClipboardRecentContent { |
public: |
// |application_scheme| is the URL scheme that can be used to open the |
@@ -26,53 +29,22 @@ class ClipboardRecentContentIOS : public ClipboardRecentContent { |
// |group_user_defaults| is the NSUserDefaults used to store information on |
// pasteboard entry expiration. This information will be shared with other |
// application in the application group. |
- explicit ClipboardRecentContentIOS(const std::string& application_scheme, |
- NSUserDefaults* group_user_defaults); |
- ~ClipboardRecentContentIOS() override; |
+ ClipboardRecentContentIOS(const std::string& application_scheme, |
+ NSUserDefaults* group_user_defaults); |
- // If the content of the pasteboard has changed, updates the change count, |
- // change date, and md5 of the latest pasteboard entry if necessary. |
- void UpdateIfNeeded(); |
+ // Constructor that directly takes an |implementation|. For use in tests. |
+ ClipboardRecentContentIOS(ClipboardRecentContentImplIOS* implementation); |
- // Returns whether the pasteboard changed since the last time a pasteboard |
- // change was detected. |
- bool HasPasteboardChanged() const; |
- |
- // Loads information from the user defaults about the latest pasteboard entry. |
- void LoadFromUserDefaults(); |
+ ~ClipboardRecentContentIOS() override; |
// ClipboardRecentContent implementation. |
bool GetRecentURLFromClipboard(GURL* url) override; |
base::TimeDelta GetClipboardContentAge() const override; |
void SuppressClipboardContent() override; |
- protected: |
- // Returns the uptime. Override in tests to return custom value. |
- virtual base::TimeDelta Uptime() const; |
- |
private: |
- friend class ClipboardRecentContentIOSTest; |
- |
- // Saves information to the user defaults about the latest pasteboard entry. |
- void SaveToUserDefaults(); |
- |
- // Returns the URL contained in the clipboard (if any). |
- GURL URLFromPasteboard(); |
- |
- // Contains the URL scheme opening the app. May be empty. |
- std::string application_scheme_; |
- // The pasteboard's change count. Increases everytime the pasteboard changes. |
- NSInteger last_pasteboard_change_count_; |
- // Estimation of the date when the pasteboard changed. |
- base::scoped_nsobject<NSDate> last_pasteboard_change_date_; |
- // MD5 hash of the last registered pasteboard entry. |
- base::scoped_nsobject<NSData> last_pasteboard_entry_md5_; |
- // Bridge to receive notifications when the application becomes active. |
- base::scoped_nsobject<ApplicationDidBecomeActiveNotificationListenerBridge> |
- notification_bridge_; |
- // The user defaults from the app group used to optimize the pasteboard change |
- // detection. |
- base::scoped_nsobject<NSUserDefaults> shared_user_defaults_; |
+ // The implementation instance. |
+ base::scoped_nsobject<ClipboardRecentContentImplIOS> implementation_; |
DISALLOW_COPY_AND_ASSIGN(ClipboardRecentContentIOS); |
}; |