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

Side by Side Diff: chrome/browser/password_manager/password_store_mac.cc

Issue 2111103002: Make callers of FromUTC(Local)Exploded in chrome/ use new time API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/password_manager/password_store_mac.h" 5 #include "chrome/browser/password_manager/password_store_mac.h"
6 6
7 #include <CoreServices/CoreServices.h> 7 #include <CoreServices/CoreServices.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 port_string = port_stringstream.str(); 272 port_string = port_stringstream.str();
273 url_components.SetPortStr(port_string); 273 url_components.SetPortStr(port_string);
274 } 274 }
275 url_components.SetPathStr(path); 275 url_components.SetPathStr(path);
276 276
277 GURL url("http://dummy.com"); // ReplaceComponents needs a valid URL. 277 GURL url("http://dummy.com"); // ReplaceComponents needs a valid URL.
278 return url.ReplaceComponents(url_components); 278 return url.ReplaceComponents(url_components);
279 } 279 }
280 280
281 // Converts a Keychain time string to a Time object, returning true if 281 // Converts a Keychain time string to a Time object, returning true if
282 // time_string_bytes was parsable. If the return value is false, the value of 282 // time_string_bytes was parsable. If the return value is false, the value of
vabr (Chromium) 2016/07/05 10:59:53 The last sentence of this comment ("If the return
maksims (do not use this acc) 2016/07/06 09:56:49 Done.
283 // |time| is unchanged. 283 // |time| is unchanged.
284 bool TimeFromKeychainTimeString(const char* time_string_bytes, 284 bool TimeFromKeychainTimeString(const char* time_string_bytes,
285 unsigned int byte_length, 285 unsigned int byte_length,
286 base::Time* time) { 286 base::Time* time) {
287 DCHECK(time); 287 DCHECK(time);
288 288
289 char* time_string = static_cast<char*>(malloc(byte_length + 1)); 289 char* time_string = static_cast<char*>(malloc(byte_length + 1));
290 memcpy(time_string, time_string_bytes, byte_length); 290 memcpy(time_string, time_string_bytes, byte_length);
291 time_string[byte_length] = '\0'; 291 time_string[byte_length] = '\0';
292 base::Time::Exploded exploded_time; 292 base::Time::Exploded exploded_time;
293 bzero(&exploded_time, sizeof(exploded_time)); 293 bzero(&exploded_time, sizeof(exploded_time));
294 // The time string is of the form "yyyyMMddHHmmss'Z", in UTC time. 294 // The time string is of the form "yyyyMMddHHmmss'Z", in UTC time.
295 int assignments = sscanf(time_string, "%4d%2d%2d%2d%2d%2dZ", 295 int assignments = sscanf(time_string, "%4d%2d%2d%2d%2d%2dZ",
296 &exploded_time.year, &exploded_time.month, 296 &exploded_time.year, &exploded_time.month,
297 &exploded_time.day_of_month, &exploded_time.hour, 297 &exploded_time.day_of_month, &exploded_time.hour,
298 &exploded_time.minute, &exploded_time.second); 298 &exploded_time.minute, &exploded_time.second);
299 free(time_string); 299 free(time_string);
300 300
301 if (assignments == 6) { 301 if (assignments == 6) {
302 *time = base::Time::FromUTCExploded(exploded_time); 302 if (base::Time::FromUTCExploded(exploded_time, time))
303 return true; 303 return true;
304 } 304 }
305 return false; 305 return false;
306 } 306 }
307 307
308 // Returns the PasswordForm Scheme corresponding to |auth_type|. 308 // Returns the PasswordForm Scheme corresponding to |auth_type|.
309 PasswordForm::Scheme SchemeForAuthType(SecAuthenticationType auth_type) { 309 PasswordForm::Scheme SchemeForAuthType(SecAuthenticationType auth_type) {
310 switch (auth_type) { 310 switch (auth_type) {
311 case kSecAuthenticationTypeHTMLForm: return PasswordForm::SCHEME_HTML; 311 case kSecAuthenticationTypeHTMLForm: return PasswordForm::SCHEME_HTML;
312 case kSecAuthenticationTypeHTTPBasic: return PasswordForm::SCHEME_BASIC; 312 case kSecAuthenticationTypeHTTPBasic: return PasswordForm::SCHEME_BASIC;
313 case kSecAuthenticationTypeHTTPDigest: return PasswordForm::SCHEME_DIGEST; 313 case kSecAuthenticationTypeHTTPDigest: return PasswordForm::SCHEME_DIGEST;
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 ScopedVector<PasswordForm> forms_with_keychain_entry; 1382 ScopedVector<PasswordForm> forms_with_keychain_entry;
1383 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, 1383 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms,
1384 &forms_with_keychain_entry); 1384 &forms_with_keychain_entry);
1385 1385
1386 // Clean up any orphaned database entries. 1386 // Clean up any orphaned database entries.
1387 RemoveDatabaseForms(&database_forms); 1387 RemoveDatabaseForms(&database_forms);
1388 1388
1389 // Move the orphaned DB forms to the output parameter. 1389 // Move the orphaned DB forms to the output parameter.
1390 AppendSecondToFirst(orphaned_forms, &database_forms); 1390 AppendSecondToFirst(orphaned_forms, &database_forms);
1391 } 1391 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698