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 #import <UIKit/UIKit.h> | 8 #import <UIKit/UIKit.h> |
9 | 9 |
10 #import "base/ios/ios_util.h" | 10 #import "base/ios/ios_util.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 - (void)pasteboardChangedNotification:(NSNotification*)notification { | 64 - (void)pasteboardChangedNotification:(NSNotification*)notification { |
65 if (_delegate) { | 65 if (_delegate) { |
66 _delegate->PasteboardChanged(); | 66 _delegate->PasteboardChanged(); |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 - (void)didBecomeActive:(NSNotification*)notification { | 70 - (void)didBecomeActive:(NSNotification*)notification { |
71 if (_delegate) { | 71 if (_delegate) { |
72 _delegate->LoadFromUserDefaults(); | 72 _delegate->LoadFromUserDefaults(); |
73 base::TimeDelta uptime = | 73 if (_delegate->HasPasteboardChanged(base::SysInfo::Uptime())) { |
74 base::TimeDelta::FromMilliseconds(base::SysInfo::Uptime()); | |
75 if (_delegate->HasPasteboardChanged(uptime)) { | |
76 _delegate->PasteboardChanged(); | 74 _delegate->PasteboardChanged(); |
77 } | 75 } |
78 } | 76 } |
79 } | 77 } |
80 | 78 |
81 - (void)disconnect { | 79 - (void)disconnect { |
82 _delegate = nullptr; | 80 _delegate = nullptr; |
83 } | 81 } |
84 | 82 |
85 @end | 83 @end |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 NSData* MD5 = WeakMD5FromNSString(pasteboard_string); | 159 NSData* MD5 = WeakMD5FromNSString(pasteboard_string); |
162 last_pasteboard_entry_md5_.reset([MD5 retain]); | 160 last_pasteboard_entry_md5_.reset([MD5 retain]); |
163 SaveToUserDefaults(); | 161 SaveToUserDefaults(); |
164 } | 162 } |
165 | 163 |
166 ClipboardRecentContentIOS::ClipboardRecentContentIOS( | 164 ClipboardRecentContentIOS::ClipboardRecentContentIOS( |
167 const std::string& application_scheme, | 165 const std::string& application_scheme, |
168 NSUserDefaults* group_user_defaults) | 166 NSUserDefaults* group_user_defaults) |
169 : application_scheme_(application_scheme), | 167 : application_scheme_(application_scheme), |
170 shared_user_defaults_([group_user_defaults retain]) { | 168 shared_user_defaults_([group_user_defaults retain]) { |
171 Init(base::TimeDelta::FromMilliseconds(base::SysInfo::Uptime())); | 169 Init(base::SysInfo::Uptime()); |
172 } | 170 } |
173 | 171 |
174 ClipboardRecentContentIOS::ClipboardRecentContentIOS( | 172 ClipboardRecentContentIOS::ClipboardRecentContentIOS( |
175 const std::string& application_scheme, | 173 const std::string& application_scheme, |
176 base::TimeDelta uptime) | 174 base::TimeDelta uptime) |
177 : application_scheme_(application_scheme), | 175 : application_scheme_(application_scheme), |
178 shared_user_defaults_([[NSUserDefaults standardUserDefaults] retain]) { | 176 shared_user_defaults_([[NSUserDefaults standardUserDefaults] retain]) { |
179 Init(uptime); | 177 Init(uptime); |
180 } | 178 } |
181 | 179 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 void ClipboardRecentContentIOS::SaveToUserDefaults() { | 272 void ClipboardRecentContentIOS::SaveToUserDefaults() { |
275 [shared_user_defaults_ setInteger:last_pasteboard_change_count_ | 273 [shared_user_defaults_ setInteger:last_pasteboard_change_count_ |
276 forKey:kPasteboardChangeCountKey]; | 274 forKey:kPasteboardChangeCountKey]; |
277 [shared_user_defaults_ setObject:last_pasteboard_change_date_ | 275 [shared_user_defaults_ setObject:last_pasteboard_change_date_ |
278 forKey:kPasteboardChangeDateKey]; | 276 forKey:kPasteboardChangeDateKey]; |
279 [shared_user_defaults_ setObject:last_pasteboard_entry_md5_ | 277 [shared_user_defaults_ setObject:last_pasteboard_entry_md5_ |
280 forKey:kPasteboardEntryMD5Key]; | 278 forKey:kPasteboardEntryMD5Key]; |
281 [shared_user_defaults_ setObject:last_displayed_pasteboard_entry_ | 279 [shared_user_defaults_ setObject:last_displayed_pasteboard_entry_ |
282 forKey:kLastDisplayedPasteboardEntryKey]; | 280 forKey:kLastDisplayedPasteboardEntryKey]; |
283 } | 281 } |
OLD | NEW |