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

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: Lei Zhang's comments 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.
283 // |time| is unchanged.
284 bool TimeFromKeychainTimeString(const char* time_string_bytes, 283 bool TimeFromKeychainTimeString(const char* time_string_bytes,
285 unsigned int byte_length, 284 unsigned int byte_length,
286 base::Time* time) { 285 base::Time* time) {
287 DCHECK(time); 286 DCHECK(time);
288 287
289 char* time_string = static_cast<char*>(malloc(byte_length + 1)); 288 char* time_string = static_cast<char*>(malloc(byte_length + 1));
290 memcpy(time_string, time_string_bytes, byte_length); 289 memcpy(time_string, time_string_bytes, byte_length);
291 time_string[byte_length] = '\0'; 290 time_string[byte_length] = '\0';
292 base::Time::Exploded exploded_time; 291 base::Time::Exploded exploded_time;
293 bzero(&exploded_time, sizeof(exploded_time)); 292 bzero(&exploded_time, sizeof(exploded_time));
294 // The time string is of the form "yyyyMMddHHmmss'Z", in UTC time. 293 // The time string is of the form "yyyyMMddHHmmss'Z", in UTC time.
295 int assignments = sscanf(time_string, "%4d%2d%2d%2d%2d%2dZ", 294 int assignments = sscanf(time_string, "%4d%2d%2d%2d%2d%2dZ",
296 &exploded_time.year, &exploded_time.month, 295 &exploded_time.year, &exploded_time.month,
297 &exploded_time.day_of_month, &exploded_time.hour, 296 &exploded_time.day_of_month, &exploded_time.hour,
298 &exploded_time.minute, &exploded_time.second); 297 &exploded_time.minute, &exploded_time.second);
299 free(time_string); 298 free(time_string);
300 299
301 if (assignments == 6) { 300 return assignments == 6 && base::Time::FromUTCExploded(exploded_time, time);
302 *time = base::Time::FromUTCExploded(exploded_time);
303 return true;
304 }
305 return false;
306 } 301 }
307 302
308 // Returns the PasswordForm Scheme corresponding to |auth_type|. 303 // Returns the PasswordForm Scheme corresponding to |auth_type|.
309 PasswordForm::Scheme SchemeForAuthType(SecAuthenticationType auth_type) { 304 PasswordForm::Scheme SchemeForAuthType(SecAuthenticationType auth_type) {
310 switch (auth_type) { 305 switch (auth_type) {
311 case kSecAuthenticationTypeHTMLForm: return PasswordForm::SCHEME_HTML; 306 case kSecAuthenticationTypeHTMLForm: return PasswordForm::SCHEME_HTML;
312 case kSecAuthenticationTypeHTTPBasic: return PasswordForm::SCHEME_BASIC; 307 case kSecAuthenticationTypeHTTPBasic: return PasswordForm::SCHEME_BASIC;
313 case kSecAuthenticationTypeHTTPDigest: return PasswordForm::SCHEME_DIGEST; 308 case kSecAuthenticationTypeHTTPDigest: return PasswordForm::SCHEME_DIGEST;
314 default: return PasswordForm::SCHEME_OTHER; 309 default: return PasswordForm::SCHEME_OTHER;
315 } 310 }
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 ScopedVector<PasswordForm> forms_with_keychain_entry; 1377 ScopedVector<PasswordForm> forms_with_keychain_entry;
1383 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, 1378 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms,
1384 &forms_with_keychain_entry); 1379 &forms_with_keychain_entry);
1385 1380
1386 // Clean up any orphaned database entries. 1381 // Clean up any orphaned database entries.
1387 RemoveDatabaseForms(&database_forms); 1382 RemoveDatabaseForms(&database_forms);
1388 1383
1389 // Move the orphaned DB forms to the output parameter. 1384 // Move the orphaned DB forms to the output parameter.
1390 AppendSecondToFirst(orphaned_forms, &database_forms); 1385 AppendSecondToFirst(orphaned_forms, &database_forms);
1391 } 1386 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698