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

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

Issue 2434473005: Use SysNSStringToUTF8 instead of UTF8String in recent clipboard. (Closed)
Patch Set: use SysNSStringToUTF8 Created 4 years, 2 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 | « no previous file | 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 url::kDataScheme, 91 url::kDataScheme,
92 url::kAboutScheme, 92 url::kAboutScheme,
93 }; 93 };
94 94
95 // Compute a hash consisting of the first 4 bytes of the MD5 hash of |string|. 95 // Compute a hash consisting of the first 4 bytes of the MD5 hash of |string|.
96 // This value is used to detect pasteboard content change. Keeping only 4 bytes 96 // This value is used to detect pasteboard content change. Keeping only 4 bytes
97 // is a privacy requirement to introduce collision and allow deniability of 97 // is a privacy requirement to introduce collision and allow deniability of
98 // having copied a given string. 98 // having copied a given string.
99 NSData* WeakMD5FromNSString(NSString* string) { 99 NSData* WeakMD5FromNSString(NSString* string) {
100 unsigned char hash[CC_MD5_DIGEST_LENGTH]; 100 unsigned char hash[CC_MD5_DIGEST_LENGTH];
101 const char* c_string = [string UTF8String]; 101 const std::string clipboard = base::SysNSStringToUTF8(string);
102 const char* c_string = clipboard.c_str();
102 CC_MD5(c_string, strlen(c_string), hash); 103 CC_MD5(c_string, strlen(c_string), hash);
103 NSData* data = [NSData dataWithBytes:hash length:4]; 104 NSData* data = [NSData dataWithBytes:hash length:4];
104 return data; 105 return data;
105 } 106 }
106 107
107 } // namespace 108 } // namespace
108 109
109 bool ClipboardRecentContentIOS::GetRecentURLFromClipboard(GURL* url) { 110 bool ClipboardRecentContentIOS::GetRecentURLFromClipboard(GURL* url) {
110 DCHECK(url); 111 DCHECK(url);
111 UpdateIfNeeded(); 112 UpdateIfNeeded();
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 forKey:kPasteboardChangeCountKey]; 238 forKey:kPasteboardChangeCountKey];
238 [shared_user_defaults_ setObject:last_pasteboard_change_date_ 239 [shared_user_defaults_ setObject:last_pasteboard_change_date_
239 forKey:kPasteboardChangeDateKey]; 240 forKey:kPasteboardChangeDateKey];
240 [shared_user_defaults_ setObject:last_pasteboard_entry_md5_ 241 [shared_user_defaults_ setObject:last_pasteboard_entry_md5_
241 forKey:kPasteboardEntryMD5Key]; 242 forKey:kPasteboardEntryMD5Key];
242 } 243 }
243 244
244 base::TimeDelta ClipboardRecentContentIOS::Uptime() const { 245 base::TimeDelta ClipboardRecentContentIOS::Uptime() const {
245 return base::SysInfo::Uptime(); 246 return base::SysInfo::Uptime();
246 } 247 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698