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

Side by Side Diff: components/autofill/browser/personal_data_manager.cc

Issue 14148004: [Autofill] Move IsValidState() into validation.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't rely on a magic constant Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « components/autofill/browser/form_group.cc ('k') | components/autofill/browser/state_names.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/autofill/browser/personal_data_manager.h" 5 #include "components/autofill/browser/personal_data_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <iterator> 9 #include <iterator>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "components/autofill/browser/autofill-inl.h" 16 #include "components/autofill/browser/autofill-inl.h"
17 #include "components/autofill/browser/autofill_country.h" 17 #include "components/autofill/browser/autofill_country.h"
18 #include "components/autofill/browser/autofill_field.h" 18 #include "components/autofill/browser/autofill_field.h"
19 #include "components/autofill/browser/autofill_metrics.h" 19 #include "components/autofill/browser/autofill_metrics.h"
20 #include "components/autofill/browser/form_group.h"
21 #include "components/autofill/browser/form_structure.h" 20 #include "components/autofill/browser/form_structure.h"
22 #include "components/autofill/browser/personal_data_manager_observer.h" 21 #include "components/autofill/browser/personal_data_manager_observer.h"
23 #include "components/autofill/browser/phone_number.h" 22 #include "components/autofill/browser/phone_number.h"
24 #include "components/autofill/browser/phone_number_i18n.h" 23 #include "components/autofill/browser/phone_number_i18n.h"
25 #include "components/autofill/browser/validation.h" 24 #include "components/autofill/browser/validation.h"
26 #include "components/autofill/browser/webdata/autofill_webdata_service.h" 25 #include "components/autofill/browser/webdata/autofill_webdata_service.h"
27 #include "components/autofill/common/autofill_pref_names.h" 26 #include "components/autofill/common/autofill_pref_names.h"
28 #include "components/user_prefs/user_prefs.h" 27 #include "components/user_prefs/user_prefs.h"
29 #include "content/public/browser/browser_context.h" 28 #include "content/public/browser/browser_context.h"
30 29
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 if (!IsMinimumAddress(profile, app_locale)) 681 if (!IsMinimumAddress(profile, app_locale))
683 return false; 682 return false;
684 683
685 base::string16 email = profile.GetRawInfo(EMAIL_ADDRESS); 684 base::string16 email = profile.GetRawInfo(EMAIL_ADDRESS);
686 if (!email.empty() && !autofill::IsValidEmailAddress(email)) 685 if (!email.empty() && !autofill::IsValidEmailAddress(email))
687 return false; 686 return false;
688 687
689 // Reject profiles with invalid US state information. 688 // Reject profiles with invalid US state information.
690 base::string16 state = profile.GetRawInfo(ADDRESS_HOME_STATE); 689 base::string16 state = profile.GetRawInfo(ADDRESS_HOME_STATE);
691 if (profile.GetRawInfo(ADDRESS_HOME_COUNTRY) == ASCIIToUTF16("US") && 690 if (profile.GetRawInfo(ADDRESS_HOME_COUNTRY) == ASCIIToUTF16("US") &&
692 !state.empty() && !FormGroup::IsValidState(state)) { 691 !state.empty() && !IsValidState(state)) {
693 return false; 692 return false;
694 } 693 }
695 694
696 // Reject profiles with invalid US zip information. 695 // Reject profiles with invalid US zip information.
697 base::string16 zip = profile.GetRawInfo(ADDRESS_HOME_ZIP); 696 base::string16 zip = profile.GetRawInfo(ADDRESS_HOME_ZIP);
698 if (profile.GetRawInfo(ADDRESS_HOME_COUNTRY) == ASCIIToUTF16("US") && 697 if (profile.GetRawInfo(ADDRESS_HOME_COUNTRY) == ASCIIToUTF16("US") &&
699 !zip.empty() && !autofill::IsValidZip(zip)) 698 !zip.empty() && !autofill::IsValidZip(zip))
700 return false; 699 return false;
701 700
702 return true; 701 return true;
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 const AutofillMetrics* metric_logger) { 1003 const AutofillMetrics* metric_logger) {
1005 metric_logger_.reset(metric_logger); 1004 metric_logger_.reset(metric_logger);
1006 } 1005 }
1007 1006
1008 void PersonalDataManager::set_browser_context( 1007 void PersonalDataManager::set_browser_context(
1009 content::BrowserContext* context) { 1008 content::BrowserContext* context) {
1010 browser_context_ = context; 1009 browser_context_ = context;
1011 } 1010 }
1012 1011
1013 } // namespace autofill 1012 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/browser/form_group.cc ('k') | components/autofill/browser/state_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698