| 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 #import "components/open_from_clipboard/clipboard_recent_content_ios.h" | 5 #import "components/open_from_clipboard/clipboard_recent_content_ios.h" |
| 6 | 6 |
| 7 #import <CommonCrypto/CommonDigest.h> | 7 #import <CommonCrypto/CommonDigest.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #import <UIKit/UIKit.h> | 10 #import <UIKit/UIKit.h> |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 NSString* pasteboard_string = [[UIPasteboard generalPasteboard] string]; | 199 NSString* pasteboard_string = [[UIPasteboard generalPasteboard] string]; |
| 200 if (!pasteboard_string) { | 200 if (!pasteboard_string) { |
| 201 pasteboard_string = @""; | 201 pasteboard_string = @""; |
| 202 } | 202 } |
| 203 NSData* md5 = WeakMD5FromNSString(pasteboard_string); | 203 NSData* md5 = WeakMD5FromNSString(pasteboard_string); |
| 204 BOOL md5_changed = ![md5 isEqualToData:last_pasteboard_entry_md5_]; | 204 BOOL md5_changed = ![md5 isEqualToData:last_pasteboard_entry_md5_]; |
| 205 | 205 |
| 206 return md5_changed; | 206 return md5_changed; |
| 207 } | 207 } |
| 208 | 208 |
| 209 bool ClipboardRecentContentIOS::GetCurrentURLFromClipboard(GURL* url) { |
| 210 if (HasPasteboardChanged(base::SysInfo::Uptime())) { |
| 211 PasteboardChanged(); |
| 212 } |
| 213 return GetRecentURLFromClipboard(url); |
| 214 } |
| 215 |
| 209 void ClipboardRecentContentIOS::Init(base::TimeDelta uptime) { | 216 void ClipboardRecentContentIOS::Init(base::TimeDelta uptime) { |
| 210 last_pasteboard_change_count_ = NSIntegerMax; | 217 last_pasteboard_change_count_ = NSIntegerMax; |
| 211 url_from_pasteboard_cache_ = URLFromPasteboard(); | 218 url_from_pasteboard_cache_ = URLFromPasteboard(); |
| 212 LoadFromUserDefaults(); | 219 LoadFromUserDefaults(); |
| 213 | 220 |
| 214 if (HasPasteboardChanged(uptime)) | 221 if (HasPasteboardChanged(uptime)) |
| 215 PasteboardChanged(); | 222 PasteboardChanged(); |
| 216 | 223 |
| 217 // Makes sure |last_pasteboard_change_count_| was properly initialized. | 224 // Makes sure |last_pasteboard_change_count_| was properly initialized. |
| 218 DCHECK_NE(last_pasteboard_change_count_, NSIntegerMax); | 225 DCHECK_NE(last_pasteboard_change_count_, NSIntegerMax); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 void ClipboardRecentContentIOS::SaveToUserDefaults() { | 279 void ClipboardRecentContentIOS::SaveToUserDefaults() { |
| 273 [shared_user_defaults_ setInteger:last_pasteboard_change_count_ | 280 [shared_user_defaults_ setInteger:last_pasteboard_change_count_ |
| 274 forKey:kPasteboardChangeCountKey]; | 281 forKey:kPasteboardChangeCountKey]; |
| 275 [shared_user_defaults_ setObject:last_pasteboard_change_date_ | 282 [shared_user_defaults_ setObject:last_pasteboard_change_date_ |
| 276 forKey:kPasteboardChangeDateKey]; | 283 forKey:kPasteboardChangeDateKey]; |
| 277 [shared_user_defaults_ setObject:last_pasteboard_entry_md5_ | 284 [shared_user_defaults_ setObject:last_pasteboard_entry_md5_ |
| 278 forKey:kPasteboardEntryMD5Key]; | 285 forKey:kPasteboardEntryMD5Key]; |
| 279 [shared_user_defaults_ setObject:last_displayed_pasteboard_entry_ | 286 [shared_user_defaults_ setObject:last_displayed_pasteboard_entry_ |
| 280 forKey:kLastDisplayedPasteboardEntryKey]; | 287 forKey:kLastDisplayedPasteboardEntryKey]; |
| 281 } | 288 } |
| OLD | NEW |