Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(861)

Side by Side Diff: components/open_from_clipboard/clipboard_recent_content_ios.mm

Issue 2082513002: Add GetCurrentURL to ClipboardRecentContentIOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment feedback Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/open_from_clipboard/clipboard_recent_content_ios.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « components/open_from_clipboard/clipboard_recent_content_ios.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698