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: components/autofill/core/browser/autofill_profile.cc

Issue 2639403002: [Autofill] Remove direct use of base::Time::Now() in Autofill (Closed)
Patch Set: Rebase Created 3 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/autofill/core/browser/autofill_profile.h" 5 #include "components/autofill/core/browser/autofill_profile.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
11 #include <ostream> 11 #include <ostream>
12 #include <set> 12 #include <set>
13 13
14 #include "base/guid.h" 14 #include "base/guid.h"
15 #include "base/i18n/case_conversion.h" 15 #include "base/i18n/case_conversion.h"
16 #include "base/i18n/char_iterator.h" 16 #include "base/i18n/char_iterator.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/metrics/histogram_macros.h" 19 #include "base/metrics/histogram_macros.h"
20 #include "base/sha1.h" 20 #include "base/sha1.h"
21 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
22 #include "base/strings/utf_string_conversion_utils.h" 22 #include "base/strings/utf_string_conversion_utils.h"
23 #include "base/strings/utf_string_conversions.h" 23 #include "base/strings/utf_string_conversions.h"
24 #include "components/autofill/core/browser/address.h" 24 #include "components/autofill/core/browser/address.h"
25 #include "components/autofill/core/browser/address_i18n.h" 25 #include "components/autofill/core/browser/address_i18n.h"
26 #include "components/autofill/core/browser/autofill_clock.h"
26 #include "components/autofill/core/browser/autofill_country.h" 27 #include "components/autofill/core/browser/autofill_country.h"
27 #include "components/autofill/core/browser/autofill_field.h" 28 #include "components/autofill/core/browser/autofill_field.h"
28 #include "components/autofill/core/browser/autofill_metrics.h" 29 #include "components/autofill/core/browser/autofill_metrics.h"
29 #include "components/autofill/core/browser/autofill_profile_comparator.h" 30 #include "components/autofill/core/browser/autofill_profile_comparator.h"
30 #include "components/autofill/core/browser/autofill_type.h" 31 #include "components/autofill/core/browser/autofill_type.h"
31 #include "components/autofill/core/browser/contact_info.h" 32 #include "components/autofill/core/browser/contact_info.h"
32 #include "components/autofill/core/browser/phone_number.h" 33 #include "components/autofill/core/browser/phone_number.h"
33 #include "components/autofill/core/browser/phone_number_i18n.h" 34 #include "components/autofill/core/browser/phone_number_i18n.h"
34 #include "components/autofill/core/browser/state_names.h" 35 #include "components/autofill/core/browser/state_names.h"
35 #include "components/autofill/core/browser/validation.h" 36 #include "components/autofill/core/browser/validation.h"
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 contents.append(GetRawInfo(ADDRESS_HOME_SORTING_CODE)); 696 contents.append(GetRawInfo(ADDRESS_HOME_SORTING_CODE));
696 contents.append(GetRawInfo(ADDRESS_HOME_COUNTRY)); 697 contents.append(GetRawInfo(ADDRESS_HOME_COUNTRY));
697 contents.append(GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); 698 contents.append(GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
698 std::string contents_utf8 = UTF16ToUTF8(contents); 699 std::string contents_utf8 = UTF16ToUTF8(contents);
699 contents_utf8.append(language_code()); 700 contents_utf8.append(language_code());
700 server_id_ = base::SHA1HashString(contents_utf8); 701 server_id_ = base::SHA1HashString(contents_utf8);
701 } 702 }
702 703
703 void AutofillProfile::RecordAndLogUse() { 704 void AutofillProfile::RecordAndLogUse() {
704 UMA_HISTOGRAM_COUNTS_1000("Autofill.DaysSinceLastUse.Profile", 705 UMA_HISTOGRAM_COUNTS_1000("Autofill.DaysSinceLastUse.Profile",
705 (base::Time::Now() - use_date()).InDays()); 706 (AutofillClock::Now() - use_date()).InDays());
706 RecordUse(); 707 RecordUse();
707 } 708 }
708 709
709 void AutofillProfile::GetSupportedTypes( 710 void AutofillProfile::GetSupportedTypes(
710 ServerFieldTypeSet* supported_types) const { 711 ServerFieldTypeSet* supported_types) const {
711 FormGroupList info = FormGroups(); 712 FormGroupList info = FormGroups();
712 for (const auto* form_group : info) { 713 for (const auto* form_group : info) {
713 form_group->GetSupportedTypes(supported_types); 714 form_group->GetSupportedTypes(supported_types);
714 } 715 }
715 } 716 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 << " " << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY)) << " " 858 << " " << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY)) << " "
858 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) << " " 859 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) << " "
859 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) << " " 860 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) << " "
860 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) << " " 861 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) << " "
861 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) << " " 862 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) << " "
862 << profile.language_code() << " " 863 << profile.language_code() << " "
863 << UTF16ToUTF8(profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); 864 << UTF16ToUTF8(profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
864 } 865 }
865 866
866 } // namespace autofill 867 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698