diff options
author | kaiwang@chromium.org <kaiwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-12 19:11:48 +0000 |
---|---|---|
committer | kaiwang@chromium.org <kaiwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-12 19:11:48 +0000 |
commit | e217c563ed3adcee9d4fd6135b260e8084c12401 (patch) | |
tree | 11191824d2cc61047e51ec89454a0f1d8c58d852 /components | |
parent | 120e89bba3abf6f96d1bad59ac1dc9c68be26b2e (diff) | |
download | chromium_src-e217c563ed3adcee9d4fd6135b260e8084c12401.zip chromium_src-e217c563ed3adcee9d4fd6135b260e8084c12401.tar.gz chromium_src-e217c563ed3adcee9d4fd6135b260e8084c12401.tar.bz2 |
Put autofill code into namepspace autofill Step 2
Move all code in components/autofill into autofill namespace.
BUG=140037, 165534
TBR=ben@chromium.org (only namespace change)
Review URL: https://chromiumcodereview.appspot.com/14089006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193982 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
154 files changed, 1244 insertions, 898 deletions
diff --git a/components/autofill/browser/address.cc b/components/autofill/browser/address.cc index 871eacb..307cd31 100644 --- a/components/autofill/browser/address.cc +++ b/components/autofill/browser/address.cc @@ -21,6 +21,8 @@ const char16 kAddressSplitChars[] = {'-', ',', '#', '.', ' ', 0}; } // namespace +namespace autofill { + Address::Address() {} Address::Address(const Address& address) : FormGroup() { @@ -127,3 +129,5 @@ void Address::GetMatchingTypes(const base::string16& text, if (!country_code.empty() && country_code_ == ASCIIToUTF16(country_code)) matching_types->insert(ADDRESS_HOME_COUNTRY); } + +} // namespace autofill diff --git a/components/autofill/browser/address.h b/components/autofill/browser/address.h index 4f22952..ba82124 100644 --- a/components/autofill/browser/address.h +++ b/components/autofill/browser/address.h @@ -13,6 +13,8 @@ #include "components/autofill/browser/field_types.h" #include "components/autofill/browser/form_group.h" +namespace autofill { + // A form group that stores address information. class Address : public FormGroup { public: @@ -48,4 +50,6 @@ class Address : public FormGroup { base::string16 zip_code_; }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_ADDRESS_H_ diff --git a/components/autofill/browser/address_field.cc b/components/autofill/browser/address_field.cc index 8632e0e..037896d 100644 --- a/components/autofill/browser/address_field.cc +++ b/components/autofill/browser/address_field.cc @@ -17,6 +17,8 @@ #include "components/autofill/browser/field_types.h" #include "ui/base/l10n/l10n_util.h" +namespace autofill { + FormField* AddressField::Parse(AutofillScanner* scanner) { if (scanner->IsEnd()) return NULL; @@ -333,3 +335,5 @@ AddressField::AddressType AddressField::AddressTypeFromText( return kShippingAddress; } + +} // namespace autofill diff --git a/components/autofill/browser/address_field.h b/components/autofill/browser/address_field.h index e2621ff..83b06c7 100644 --- a/components/autofill/browser/address_field.h +++ b/components/autofill/browser/address_field.h @@ -14,6 +14,8 @@ #include "components/autofill/browser/autofill_type.h" #include "components/autofill/browser/form_field.h" +namespace autofill { + class AutofillField; class AutofillScanner; @@ -81,4 +83,6 @@ class AddressField : public FormField { DISALLOW_COPY_AND_ASSIGN(AddressField); }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_ADDRESS_FIELD_H_ diff --git a/components/autofill/browser/address_field_unittest.cc b/components/autofill/browser/address_field_unittest.cc index 3ef26fc..a7f633a 100644 --- a/components/autofill/browser/address_field_unittest.cc +++ b/components/autofill/browser/address_field_unittest.cc @@ -12,6 +12,8 @@ #include "components/autofill/common/form_field_data.h" #include "testing/gtest/include/gtest/gtest.h" +namespace autofill { + class AddressFieldTest : public testing::Test { public: AddressFieldTest() {} @@ -292,3 +294,5 @@ TEST_F(AddressFieldTest, ParseCompany) { field_type_map_.find(ASCIIToUTF16("company1")) != field_type_map_.end()); EXPECT_EQ(COMPANY_NAME, field_type_map_[ASCIIToUTF16("company1")]); } + +} // namespace autofill diff --git a/components/autofill/browser/address_unittest.cc b/components/autofill/browser/address_unittest.cc index 5315a9e..2b74f40 100644 --- a/components/autofill/browser/address_unittest.cc +++ b/components/autofill/browser/address_unittest.cc @@ -14,6 +14,8 @@ using content::BrowserThread; +namespace autofill { + class AddressTest : public testing::Test { public: // In order to access the application locale -- which the tested functions do @@ -120,3 +122,5 @@ TEST_F(AddressTest, IsCountry) { address.GetMatchingTypes(ASCIIToUTF16("Garbage"), "US", &matching_types); EXPECT_EQ(0U, matching_types.size()); } + +} // namespace autofill diff --git a/components/autofill/browser/android/auxiliary_profile_unittest_android.cc b/components/autofill/browser/android/auxiliary_profile_unittest_android.cc index 2372102..1bfcef5 100644 --- a/components/autofill/browser/android/auxiliary_profile_unittest_android.cc +++ b/components/autofill/browser/android/auxiliary_profile_unittest_android.cc @@ -11,6 +11,8 @@ #include "components/autofill/browser/autofill_profile.h" #include "testing/gtest/include/gtest/gtest.h" +namespace autofill { + class AuxiliaryProfileAndroidTest : public testing::Test { public: AuxiliaryProfileAndroidTest() {} @@ -157,3 +159,5 @@ TEST_F(AuxiliaryProfileAndroidTest, SetAddressInfoEmpty) { EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_COUNTRY), base::string16()); } #endif + +} // namespace autofill diff --git a/components/autofill/browser/android/auxiliary_profiles_android.h b/components/autofill/browser/android/auxiliary_profiles_android.h index c624af1..0915df1 100644 --- a/components/autofill/browser/android/auxiliary_profiles_android.h +++ b/components/autofill/browser/android/auxiliary_profiles_android.h @@ -12,9 +12,9 @@ #include "base/string16.h" #include "components/autofill/browser/android/auxiliary_profile_loader_android.h" -class AutofillProfile; - namespace autofill { + +class AutofillProfile; class AuxiliaryProfileLoaderAndroid; // This class is used to populate an AutofillProfile vector with diff --git a/components/autofill/browser/android/component_jni_registrar.cc b/components/autofill/browser/android/component_jni_registrar.cc index 7bb1a66..3f9cc54 100644 --- a/components/autofill/browser/android/component_jni_registrar.cc +++ b/components/autofill/browser/android/component_jni_registrar.cc @@ -8,7 +8,7 @@ #include "base/android/jni_registrar.h" #include "components/autofill/browser/android/auxiliary_profile_loader_android.h" -namespace components { +namespace autofill { static base::android::RegistrationMethod kComponentRegisteredMethods[] = { { "RegisterAuxiliaryProfileLoader", @@ -20,4 +20,4 @@ bool RegisterAutofillAndroidJni(JNIEnv* env) { kComponentRegisteredMethods, arraysize(kComponentRegisteredMethods)); } -} // namespace components +} // namespace autofill diff --git a/components/autofill/browser/android/component_jni_registrar.h b/components/autofill/browser/android/component_jni_registrar.h index 86c1327..1870922 100644 --- a/components/autofill/browser/android/component_jni_registrar.h +++ b/components/autofill/browser/android/component_jni_registrar.h @@ -7,12 +7,12 @@ #include <jni.h> -namespace components { +namespace autofill { // Register all JNI bindings necessary for the autofill // component. bool RegisterAutofillAndroidJni(JNIEnv* env); -} // namespace components +} // namespace autofill #endif // COMPONENT_AUTOFILL_BROWSER_ANDROID_COMPONENT_JNI_REGISTRAR_H_ diff --git a/components/autofill/browser/android/java/src/org/chromium/components/browser/autofill/PersonalAutofillPopulator.java b/components/autofill/browser/android/java/src/org/chromium/components/browser/autofill/PersonalAutofillPopulator.java index b99d6dd..b00ed61 100644 --- a/components/autofill/browser/android/java/src/org/chromium/components/browser/autofill/PersonalAutofillPopulator.java +++ b/components/autofill/browser/android/java/src/org/chromium/components/browser/autofill/PersonalAutofillPopulator.java @@ -27,6 +27,7 @@ import android.widget.Button; import android.widget.Toast; import org.chromium.base.CalledByNative; +import org.chromium.base.JNINamespace; import java.util.ArrayList; @@ -34,6 +35,7 @@ import java.util.ArrayList; * Loads user profile information stored under the "Me" contact. * Requires permissions: READ_CONTACTS and READ_PROFILE. */ +@JNINamespace("autofill") public class PersonalAutofillPopulator { /** * SQL query definitions for obtaining specific profile information. diff --git a/components/autofill/browser/android/personal_data_manager_android.cc b/components/autofill/browser/android/personal_data_manager_android.cc index 2075ee5..3655314 100644 --- a/components/autofill/browser/android/personal_data_manager_android.cc +++ b/components/autofill/browser/android/personal_data_manager_android.cc @@ -8,6 +8,8 @@ #include "components/autofill/browser/android/auxiliary_profiles_android.h" #include "components/autofill/browser/personal_data_manager.h" +namespace autofill { + void PersonalDataManager::LoadAuxiliaryProfiles() { auxiliary_profiles_.clear(); autofill::AuxiliaryProfileLoaderAndroid profile_loader; @@ -19,3 +21,5 @@ void PersonalDataManager::LoadAuxiliaryProfiles() { auxiliary_profiles_.push_back(impl.LoadContactsProfile().release()); } } + +} // namespace autofill diff --git a/components/autofill/browser/android/test_auxiliary_profile_loader_android.cc b/components/autofill/browser/android/test_auxiliary_profile_loader_android.cc index 1ec9cc9..8e9b67a 100644 --- a/components/autofill/browser/android/test_auxiliary_profile_loader_android.cc +++ b/components/autofill/browser/android/test_auxiliary_profile_loader_android.cc @@ -4,6 +4,8 @@ #include "components/autofill/browser/android/test_auxiliary_profile_loader_android.h" +namespace autofill { + TestAuxiliaryProfileLoader::TestAuxiliaryProfileLoader() { } @@ -126,3 +128,5 @@ void TestAuxiliaryProfileLoader::SetPhoneNumbers( const std::vector<base::string16>& phone_numbers) { phone_numbers_ = phone_numbers; } + +} // namespace autofill diff --git a/components/autofill/browser/android/test_auxiliary_profile_loader_android.h b/components/autofill/browser/android/test_auxiliary_profile_loader_android.h index f76100b..f9e40b1 100644 --- a/components/autofill/browser/android/test_auxiliary_profile_loader_android.h +++ b/components/autofill/browser/android/test_auxiliary_profile_loader_android.h @@ -8,6 +8,8 @@ #include "base/compiler_specific.h" #include "components/autofill/browser/android/auxiliary_profile_loader_android.h" +namespace autofill { + class TestAuxiliaryProfileLoader : public autofill::AuxiliaryProfileLoaderAndroid { // Mock object for unit testing |AuxiliaryProfilesAndroid| @@ -67,4 +69,6 @@ class TestAuxiliaryProfileLoader std::vector<base::string16> phone_numbers_; }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_ANDROID_TEST_AUXILIARY_PROFILE_LOADER_ANDROID_H_ diff --git a/components/autofill/browser/autocheckout_manager.h b/components/autofill/browser/autocheckout_manager.h index 8207c21..dbbe481 100644 --- a/components/autofill/browser/autocheckout_manager.h +++ b/components/autofill/browser/autocheckout_manager.h @@ -13,17 +13,8 @@ #include "components/autofill/browser/autocheckout_page_meta_data.h" #include "components/autofill/common/autocheckout_status.h" -class AutofillField; -class AutofillManager; -class AutofillMetrics; -class AutofillProfile; -class CreditCard; -class FormStructure; class GURL; -struct FormData; -struct FormFieldData; - namespace content { struct SSLStatus; } @@ -34,6 +25,16 @@ class RectF; namespace autofill { +class AutofillField; +class AutofillManager; +class AutofillMetrics; +class AutofillProfile; +class CreditCard; +class FormStructure; + +struct FormData; +struct FormFieldData; + class AutocheckoutManager { public: explicit AutocheckoutManager(AutofillManager* autofill_manager); diff --git a/components/autofill/browser/autocomplete_history_manager.cc b/components/autofill/browser/autocomplete_history_manager.cc index 1b03cee..e1681ba0 100644 --- a/components/autofill/browser/autocomplete_history_manager.cc +++ b/components/autofill/browser/autocomplete_history_manager.cc @@ -24,6 +24,7 @@ using base::StringPiece16; using content::BrowserContext; using content::WebContents; +namespace autofill { namespace { // Limit on the number of suggestions to appear in the pop-up menu under an @@ -287,3 +288,5 @@ void AutocompleteHistoryManager::SendSuggestions( autofill_icons_.clear(); autofill_unique_ids_.clear(); } + +} // namespace autofill diff --git a/components/autofill/browser/autocomplete_history_manager.h b/components/autofill/browser/autocomplete_history_manager.h index be391a8..9a55fa4 100644 --- a/components/autofill/browser/autocomplete_history_manager.h +++ b/components/autofill/browser/autocomplete_history_manager.h @@ -13,13 +13,14 @@ #include "components/webdata/common/web_data_service_consumer.h" #include "content/public/browser/web_contents_observer.h" -struct FormData; - namespace content { class BrowserContext; } +namespace autofill { + class AutofillExternalDelegate; +struct FormData; // Per-tab Autocomplete history manager. Handles receiving form data // from the renderer and the storing and retrieving of form data @@ -89,4 +90,6 @@ class AutocompleteHistoryManager : public content::WebContentsObserver, DISALLOW_COPY_AND_ASSIGN(AutocompleteHistoryManager); }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOCOMPLETE_HISTORY_MANAGER_H_ diff --git a/components/autofill/browser/autocomplete_history_manager_unittest.cc b/components/autofill/browser/autocomplete_history_manager_unittest.cc index 14c626c..8567221 100644 --- a/components/autofill/browser/autocomplete_history_manager_unittest.cc +++ b/components/autofill/browser/autocomplete_history_manager_unittest.cc @@ -28,6 +28,8 @@ using content::BrowserThread; using content::WebContents; using testing::_; +namespace autofill { + namespace { class MockWebDataService : public AutofillWebDataService { @@ -259,3 +261,5 @@ TEST_F(AutocompleteHistoryManagerTest, ExternalDelegate) { EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _)); autocomplete_history_manager.SendSuggestions(NULL); } + +} // namespace autofill diff --git a/components/autofill/browser/autofill-inl.h b/components/autofill/browser/autofill-inl.h index 726d443..0103c7c 100644 --- a/components/autofill/browser/autofill-inl.h +++ b/components/autofill/browser/autofill-inl.h @@ -5,6 +5,8 @@ #ifndef COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_INL_H_ #define COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_INL_H_ +namespace autofill { + template<typename T> class FormGroupMatchesByCompareFunctor { public: @@ -32,4 +34,6 @@ bool FindByContents(const C& container, const T& form_group) { FormGroupMatchesByCompareFunctor<T>(form_group)) != container.end(); } +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_INL_H_ diff --git a/components/autofill/browser/autofill_common_test.cc b/components/autofill/browser/autofill_common_test.cc index ff6c135..1f60daf 100644 --- a/components/autofill/browser/autofill_common_test.cc +++ b/components/autofill/browser/autofill_common_test.cc @@ -15,7 +15,8 @@ #include "components/user_prefs/user_prefs.h" #include "components/webdata/encryptor/encryptor.h" -namespace autofill_test { +namespace autofill { +namespace test { void CreateTestFormField(const char* label, const char* name, @@ -107,4 +108,5 @@ void DisableSystemServices(Profile* profile) { } } -} // namespace autofill_test +} // namespace test +} // namespace autofill diff --git a/components/autofill/browser/autofill_common_test.h b/components/autofill/browser/autofill_common_test.h index 858d8da..d2758db 100644 --- a/components/autofill/browser/autofill_common_test.h +++ b/components/autofill/browser/autofill_common_test.h @@ -5,14 +5,16 @@ #ifndef COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_COMMON_TEST_H_ #define COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_COMMON_TEST_H_ -class AutofillProfile; -class CreditCard; class Profile; +namespace autofill { + +class AutofillProfile; +class CreditCard; struct FormFieldData; // Common utilities shared amongst Autofill tests. -namespace autofill_test { +namespace test { // Provides a quick way to populate a FormField with c-strings. void CreateTestFormField(const char* label, @@ -53,6 +55,7 @@ void SetCreditCardInfo(CreditCard* credit_card, // Disables or mocks out code that would otherwise reach out to system services. void DisableSystemServices(Profile* profile); -} // namespace autofill_test +} // namespace test +} // namespace autofill #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_COMMON_TEST_H_ diff --git a/components/autofill/browser/autofill_country.cc b/components/autofill/browser/autofill_country.cc index 5aad7a5..26cc5ca 100644 --- a/components/autofill/browser/autofill_country.cc +++ b/components/autofill/browser/autofill_country.cc @@ -26,6 +26,7 @@ #include "third_party/icu/public/i18n/unicode/ucol.h" #include "ui/base/l10n/l10n_util.h" +namespace autofill { namespace { // The maximum capacity needed to store a locale up to the country code. @@ -1110,3 +1111,5 @@ AutofillCountry::AutofillCountry(const std::string& country_code, postal_code_label_(postal_code_label), state_label_(state_label) { } + +} // namespace autofill diff --git a/components/autofill/browser/autofill_country.h b/components/autofill/browser/autofill_country.h index a93ea86..ea65911 100644 --- a/components/autofill/browser/autofill_country.h +++ b/components/autofill/browser/autofill_country.h @@ -11,6 +11,8 @@ #include "base/basictypes.h" #include "base/string16.h" +namespace autofill { + // The minimal required fields for an address to be complete for a given // country. enum AddressRequiredFields { @@ -103,4 +105,6 @@ class AutofillCountry { DISALLOW_COPY_AND_ASSIGN(AutofillCountry); }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_COUNTRY_H_ diff --git a/components/autofill/browser/autofill_country_unittest.cc b/components/autofill/browser/autofill_country_unittest.cc index 3615129..ea326e3 100644 --- a/components/autofill/browser/autofill_country_unittest.cc +++ b/components/autofill/browser/autofill_country_unittest.cc @@ -9,6 +9,8 @@ #include "components/autofill/browser/autofill_country.h" #include "testing/gtest/include/gtest/gtest.h" +namespace autofill { + // Test the constructor and accessors TEST(AutofillCountryTest, AutofillCountry) { AutofillCountry united_states_en("US", "en_US"); @@ -84,3 +86,5 @@ TEST(AutofillCountryTest, GetCountryCode) { "es")); EXPECT_EQ("US", AutofillCountry::GetCountryCode(ASCIIToUTF16("USA"), "es")); } + +} // namespace autofill diff --git a/components/autofill/browser/autofill_download.cc b/components/autofill/browser/autofill_download.cc index c8e952c..70eeed5 100644 --- a/components/autofill/browser/autofill_download.cc +++ b/components/autofill/browser/autofill_download.cc @@ -28,6 +28,8 @@ using content::BrowserContext; +namespace autofill { + namespace { const char kAutofillQueryServerNameStartInHeader[] = "GFE/"; @@ -48,7 +50,7 @@ static void LogFieldAssignments( << form_xml; } -}; +} // namespace // static std::string AutofillDownloadManager::AutofillRequestTypeToString( @@ -345,3 +347,5 @@ void AutofillDownloadManager::OnURLFetchComplete( delete it->first; url_fetchers_.erase(it); } + +} // namespace autofill diff --git a/components/autofill/browser/autofill_download.h b/components/autofill/browser/autofill_download.h index 18a237c..940fb17 100644 --- a/components/autofill/browser/autofill_download.h +++ b/components/autofill/browser/autofill_download.h @@ -18,9 +18,6 @@ #include "components/autofill/browser/autofill_type.h" #include "net/url_request/url_fetcher_delegate.h" -class AutofillMetrics; -class FormStructure; - namespace content { class BrowserContext; } // namespace content @@ -29,6 +26,11 @@ namespace net { class URLFetcher; } // namespace net +namespace autofill { + +class AutofillMetrics; +class FormStructure; + // Handles getting and updating Autofill heuristics. class AutofillDownloadManager : public net::URLFetcherDelegate { public: @@ -163,4 +165,6 @@ class AutofillDownloadManager : public net::URLFetcherDelegate { int fetcher_id_for_unittest_; }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_DOWNLOAD_H_ diff --git a/components/autofill/browser/autofill_download_unittest.cc b/components/autofill/browser/autofill_download_unittest.cc index c773dc69..2e9c405 100644 --- a/components/autofill/browser/autofill_download_unittest.cc +++ b/components/autofill/browser/autofill_download_unittest.cc @@ -26,6 +26,8 @@ using content::BrowserThread; using WebKit::WebInputElement; +namespace autofill { + namespace { class MockAutofillMetrics : public AutofillMetrics { @@ -503,3 +505,5 @@ TEST_F(AutofillDownloadTest, CacheQueryTest) { ASSERT_EQ(static_cast<size_t>(1), responses_.size()); EXPECT_EQ(responses[0], responses_.front().response); } + +} // namespace autofill diff --git a/components/autofill/browser/autofill_download_url.cc b/components/autofill/browser/autofill_download_url.cc index 8c8251b..e4a4b42 100644 --- a/components/autofill/browser/autofill_download_url.cc +++ b/components/autofill/browser/autofill_download_url.cc @@ -10,6 +10,7 @@ #include "components/autofill/common/autofill_switches.h" #include "googleurl/src/gurl.h" +namespace autofill { namespace { const char kDefaultAutofillServiceUrl[] = @@ -31,15 +32,16 @@ std::string GetBaseAutofillUrl() { return baseAutofillServiceUrl; } -} // anonymous namespace +} // namespace -GURL autofill::GetAutofillQueryUrl() { +GURL GetAutofillQueryUrl() { std::string baseAutofillServiceUrl = GetBaseAutofillUrl(); return GURL(baseAutofillServiceUrl + "query?client=" + kClientName); } -GURL autofill::GetAutofillUploadUrl() { +GURL GetAutofillUploadUrl() { std::string baseAutofillServiceUrl = GetBaseAutofillUrl(); return GURL(baseAutofillServiceUrl + "upload?client=" + kClientName); } +} // namespace autofill diff --git a/components/autofill/browser/autofill_download_url.h b/components/autofill/browser/autofill_download_url.h index 427fec3..ec892d5 100644 --- a/components/autofill/browser/autofill_download_url.h +++ b/components/autofill/browser/autofill_download_url.h @@ -12,7 +12,7 @@ namespace autofill { GURL GetAutofillQueryUrl(); GURL GetAutofillUploadUrl(); -} +} // namespace autofill #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_DOWNLOAD_URL_H_ diff --git a/components/autofill/browser/autofill_download_url_unittest.cc b/components/autofill/browser/autofill_download_url_unittest.cc index 7ae3449..f201c00 100644 --- a/components/autofill/browser/autofill_download_url_unittest.cc +++ b/components/autofill/browser/autofill_download_url_unittest.cc @@ -9,6 +9,8 @@ using testing::StartsWith; +namespace autofill { + TEST(AutofillDownloadUrlTest, CheckDefaultUrls) { std::string query_url = autofill::GetAutofillQueryUrl().spec(); @@ -21,3 +23,4 @@ TEST(AutofillDownloadUrlTest, CheckDefaultUrls) { StartsWith("https://clients1.google.com/tbproxy/af/upload?client=")); } +} // namespace autofill diff --git a/components/autofill/browser/autofill_external_delegate.cc b/components/autofill/browser/autofill_external_delegate.cc index 0af6717..9985d31 100644 --- a/components/autofill/browser/autofill_external_delegate.cc +++ b/components/autofill/browser/autofill_external_delegate.cc @@ -25,7 +25,9 @@ using content::RenderViewHost; using WebKit::WebAutofillClient; -DEFINE_WEB_CONTENTS_USER_DATA_KEY(AutofillExternalDelegate); +DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::AutofillExternalDelegate); + +namespace autofill { void AutofillExternalDelegate::CreateForWebContentsAndManager( content::WebContents* web_contents, @@ -383,3 +385,5 @@ void AutofillExternalDelegate::Observe( NOTREACHED(); } } + +} // namespace autofill diff --git a/components/autofill/browser/autofill_external_delegate.h b/components/autofill/browser/autofill_external_delegate.h index 9340ca3..57a4b8e 100644 --- a/components/autofill/browser/autofill_external_delegate.h +++ b/components/autofill/browser/autofill_external_delegate.h @@ -20,8 +20,6 @@ #include "content/public/browser/web_contents_user_data.h" #include "ui/gfx/rect.h" -class AutofillManager; - namespace gfx { class Rect; } @@ -30,6 +28,10 @@ namespace content { class WebContents; } +namespace autofill { + +class AutofillManager; + // TODO(csharp): A lot of the logic in this class is copied from autofillagent. // Once Autofill is moved out of WebKit this class should be the only home for // this logic. See http://crbug.com/51644 @@ -188,4 +190,6 @@ class AutofillExternalDelegate DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_EXTERNAL_DELEGATE_H_ diff --git a/components/autofill/browser/autofill_external_delegate_unittest.cc b/components/autofill/browser/autofill_external_delegate_unittest.cc index a63ae29..c0d40e9 100644 --- a/components/autofill/browser/autofill_external_delegate_unittest.cc +++ b/components/autofill/browser/autofill_external_delegate_unittest.cc @@ -23,6 +23,8 @@ using content::BrowserThread; using testing::_; using WebKit::WebAutofillClient; +namespace autofill { + namespace { // A constant value to use as the Autofill query ID. @@ -332,3 +334,5 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateHideWarning) { autofill_items, autofill_ids); } + +} // namespace autofill diff --git a/components/autofill/browser/autofill_field.cc b/components/autofill/browser/autofill_field.cc index 1f164b5..70aeda3 100644 --- a/components/autofill/browser/autofill_field.cc +++ b/components/autofill/browser/autofill_field.cc @@ -25,6 +25,8 @@ static std::string Hash32Bit(const std::string& str) { } // namespace +namespace autofill { + AutofillField::AutofillField() : server_type_(NO_SERVER_DATA), heuristic_type_(UNKNOWN_TYPE), @@ -82,3 +84,5 @@ std::string AutofillField::FieldSignature() const { bool AutofillField::IsFieldFillable() const { return type() != UNKNOWN_TYPE; } + +} // namespace autofill diff --git a/components/autofill/browser/autofill_field.h b/components/autofill/browser/autofill_field.h index e961919..d2b1543 100644 --- a/components/autofill/browser/autofill_field.h +++ b/components/autofill/browser/autofill_field.h @@ -12,6 +12,8 @@ #include "components/autofill/browser/field_types.h" #include "components/autofill/common/form_field_data.h" +namespace autofill { + class AutofillField : public FormFieldData { public: enum PhonePart { @@ -85,4 +87,6 @@ class AutofillField : public FormFieldData { DISALLOW_COPY_AND_ASSIGN(AutofillField); }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_FIELD_H_ diff --git a/components/autofill/browser/autofill_field_unittest.cc b/components/autofill/browser/autofill_field_unittest.cc index 66d6322..250f24d 100644 --- a/components/autofill/browser/autofill_field_unittest.cc +++ b/components/autofill/browser/autofill_field_unittest.cc @@ -8,6 +8,7 @@ #include "components/autofill/browser/field_types.h" #include "testing/gtest/include/gtest/gtest.h" +namespace autofill { namespace { TEST(AutofillFieldTest, Type) { @@ -91,3 +92,4 @@ TEST(AutofillFieldTest, IsFieldFillable) { } } // namespace +} // namespace autofill diff --git a/components/autofill/browser/autofill_ie_toolbar_import_win.cc b/components/autofill/browser/autofill_ie_toolbar_import_win.cc index 19a9f07..0d55e03 100644 --- a/components/autofill/browser/autofill_ie_toolbar_import_win.cc +++ b/components/autofill/browser/autofill_ie_toolbar_import_win.cc @@ -28,6 +28,8 @@ using base::win::RegKey; +namespace autofill { + // Forward declaration. This function is not in unnamed namespace as it // is referenced in the unittest. bool ImportCurrentUserProfiles(const std::string& app_locale, @@ -299,3 +301,5 @@ bool ImportAutofillDataWin(PersonalDataManager* pdm) { // importer will self delete. return importer->ImportProfiles(); } + +} // namespace autofill diff --git a/components/autofill/browser/autofill_ie_toolbar_import_win.h b/components/autofill/browser/autofill_ie_toolbar_import_win.h index d89604d..3c2579c 100644 --- a/components/autofill/browser/autofill_ie_toolbar_import_win.h +++ b/components/autofill/browser/autofill_ie_toolbar_import_win.h @@ -5,6 +5,8 @@ #ifndef COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_IE_TOOLBAR_IMPORT_WIN_H_ #define COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_IE_TOOLBAR_IMPORT_WIN_H_ +namespace autofill { + // This importer is here and not in chrome/browser/importer/toolbar_importer.cc // because of the following: // 1. The data is not saved in profile, but rather in registry, thus it is @@ -17,4 +19,6 @@ class PersonalDataManager; bool ImportAutofillDataWin(PersonalDataManager* pdm); +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_IE_TOOLBAR_IMPORT_WIN_H_ diff --git a/components/autofill/browser/autofill_ie_toolbar_import_win_unittest.cc b/components/autofill/browser/autofill_ie_toolbar_import_win_unittest.cc index be6aeb8..c1e09e3 100644 --- a/components/autofill/browser/autofill_ie_toolbar_import_win_unittest.cc +++ b/components/autofill/browser/autofill_ie_toolbar_import_win_unittest.cc @@ -15,6 +15,8 @@ using base::win::RegKey; +namespace autofill { + // Defined in autofill_ie_toolbar_import_win.cc. Not exposed in the header file. bool ImportCurrentUserProfiles(const std::string& app_locale, std::vector<AutofillProfile>* profiles, @@ -203,3 +205,4 @@ TEST_F(AutofillIeToolbarImportTest, TestAutofillImport) { EXPECT_EQ(0U, credit_cards.size()); } +} // namespace autofill diff --git a/components/autofill/browser/autofill_manager.cc b/components/autofill/browser/autofill_manager.cc index e766054..ceaf77c 100644 --- a/components/autofill/browser/autofill_manager.cc +++ b/components/autofill/browser/autofill_manager.cc @@ -57,6 +57,8 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/gfx/rect.h" +namespace autofill { + typedef PersonalDataManager::GUIDPair GUIDPair; using base::TimeTicks; @@ -1352,3 +1354,5 @@ void AutofillManager::UpdateInitialInteractionTimestamp( initial_interaction_timestamp_ = interaction_timestamp; } } + +} // namespace autofill diff --git a/components/autofill/browser/autofill_manager.h b/components/autofill/browser/autofill_manager.h index 7a7e386..4a2bb5f 100644 --- a/components/autofill/browser/autofill_manager.h +++ b/components/autofill/browser/autofill_manager.h @@ -34,28 +34,12 @@ #include "content/public/common/ssl_status.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h" -class AutofillExternalDelegate; -class AutofillField; -class AutofillProfile; -class AutofillMetrics; -class CreditCard; -class FormGroup; class GURL; class PrefRegistrySyncable; class ProfileSyncService; -struct FormData; -struct FormFieldData; -struct PasswordFormFillData; struct ViewHostMsg_FrameNavigate_Params; -namespace autofill { -class AutofillManagerDelegate; -class AutofillManagerTestDelegate; -class FormStructureBrowserTest; -class PasswordGenerator; -} - namespace content { class RenderViewHost; class WebContents; @@ -72,6 +56,23 @@ namespace IPC { class Message; } +namespace autofill { + +class AutofillExternalDelegate; +class AutofillField; +class AutofillProfile; +class AutofillManagerDelegate; +class AutofillManagerTestDelegate; +class AutofillMetrics; +class CreditCard; +class FormStructureBrowserTest; +class FormGroup; +class PasswordGenerator; + +struct FormData; +struct FormFieldData; +struct PasswordFormFillData; + // Manages saving and restoring the user's personal information entered into web // forms. class AutofillManager : public content::WebContentsObserver, @@ -464,4 +465,6 @@ class AutofillManager : public content::WebContentsObserver, DISALLOW_COPY_AND_ASSIGN(AutofillManager); }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_MANAGER_H_ diff --git a/components/autofill/browser/autofill_manager_delegate.h b/components/autofill/browser/autofill_manager_delegate.h index dcfacd7f..abcb421 100644 --- a/components/autofill/browser/autofill_manager_delegate.h +++ b/components/autofill/browser/autofill_manager_delegate.h @@ -10,10 +10,6 @@ #include "base/callback_forward.h" #include "base/string16.h" -namespace autofill { -class PasswordGenerator; -} - namespace content { struct PasswordForm; struct SSLStatus; @@ -24,20 +20,21 @@ class Rect; class RectF; } -class AutofillMetrics; -class AutofillPopupDelegate; -class CreditCard; -class FormStructure; class GURL; class InfoBarService; -class PersonalDataManager; class PrefService; class ProfileSyncServiceBase; -struct FormData; - namespace autofill { +class AutofillMetrics; +class AutofillPopupDelegate; +class CreditCard; +class FormStructure; +class PasswordGenerator; +class PersonalDataManager; +struct FormData; + namespace autocheckout { class WhitelistManager; } diff --git a/components/autofill/browser/autofill_manager_unittest.cc b/components/autofill/browser/autofill_manager_unittest.cc index 38ede8e..0daffb0 100644 --- a/components/autofill/browser/autofill_manager_unittest.cc +++ b/components/autofill/browser/autofill_manager_unittest.cc @@ -51,12 +51,15 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/gfx/rect.h" -typedef PersonalDataManager::GUIDPair GUIDPair; using content::BrowserThread; using content::WebContents; using testing::_; using WebKit::WebFormElement; +namespace autofill { + +typedef PersonalDataManager::GUIDPair GUIDPair; + namespace { // The page ID sent to the AutofillManager from the RenderView, used to send @@ -148,9 +151,9 @@ class TestPersonalDataManager : public PersonalDataManager { void CreateTestCreditCardsYearAndMonth(const char* year, const char* month) { ClearCreditCards(); CreditCard* credit_card = new CreditCard; - autofill_test::SetCreditCardInfo(credit_card, "Miku Hatsune", - "4234567890654321", // Visa - month, year); + test::SetCreditCardInfo(credit_card, "Miku Hatsune", + "4234567890654321", // Visa + month, year); credit_card->set_guid("00000000-0000-0000-0000-000000000007"); credit_cards_.push_back(credit_card); } @@ -158,44 +161,44 @@ class TestPersonalDataManager : public PersonalDataManager { private: void CreateTestAutofillProfiles(ScopedVector<AutofillProfile>* profiles) { AutofillProfile* profile = new AutofillProfile; - autofill_test::SetProfileInfo(profile, "Elvis", "Aaron", - "Presley", "theking@gmail.com", "RCA", - "3734 Elvis Presley Blvd.", "Apt. 10", - "Memphis", "Tennessee", "38116", "US", - "12345678901"); + test::SetProfileInfo(profile, "Elvis", "Aaron", + "Presley", "theking@gmail.com", "RCA", + "3734 Elvis Presley Blvd.", "Apt. 10", + "Memphis", "Tennessee", "38116", "US", + "12345678901"); profile->set_guid("00000000-0000-0000-0000-000000000001"); profiles->push_back(profile); profile = new AutofillProfile; - autofill_test::SetProfileInfo(profile, "Charles", "Hardin", - "Holley", "buddy@gmail.com", "Decca", - "123 Apple St.", "unit 6", "Lubbock", - "Texas", "79401", "US", "23456789012"); + test::SetProfileInfo(profile, "Charles", "Hardin", + "Holley", "buddy@gmail.com", "Decca", + "123 Apple St.", "unit 6", "Lubbock", + "Texas", "79401", "US", "23456789012"); profile->set_guid("00000000-0000-0000-0000-000000000002"); profiles->push_back(profile); profile = new AutofillProfile; - autofill_test::SetProfileInfo(profile, "", "", "", "", "", "", "", "", "", - "", "", ""); + test::SetProfileInfo( + profile, "", "", "", "", "", "", "", "", "", "", "", ""); profile->set_guid("00000000-0000-0000-0000-000000000003"); profiles->push_back(profile); } void CreateTestCreditCards(ScopedVector<CreditCard>* credit_cards) { CreditCard* credit_card = new CreditCard; - autofill_test::SetCreditCardInfo(credit_card, "Elvis Presley", - "4234 5678 9012 3456", // Visa - "04", "2012"); + test::SetCreditCardInfo(credit_card, "Elvis Presley", + "4234 5678 9012 3456", // Visa + "04", "2012"); credit_card->set_guid("00000000-0000-0000-0000-000000000004"); credit_cards->push_back(credit_card); credit_card = new CreditCard; - autofill_test::SetCreditCardInfo(credit_card, "Buddy Holly", - "5187654321098765", // Mastercard - "10", "2014"); + test::SetCreditCardInfo(credit_card, "Buddy Holly", + "5187654321098765", // Mastercard + "10", "2014"); credit_card->set_guid("00000000-0000-0000-0000-000000000005"); credit_cards->push_back(credit_card); credit_card = new CreditCard; - autofill_test::SetCreditCardInfo(credit_card, "", "", "", ""); + test::SetCreditCardInfo(credit_card, "", "", "", ""); credit_card->set_guid("00000000-0000-0000-0000-000000000006"); credit_cards->push_back(credit_card); } @@ -212,18 +215,14 @@ void CreateTestFormWithAutocompleteAttribute(FormData* form) { form->user_submitted = true; FormFieldData field; - autofill_test::CreateTestFormField( - "First Name", "firstname", "", "text", &field); + test::CreateTestFormField("First Name", "firstname", "", "text", &field); form->fields.push_back(field); - autofill_test::CreateTestFormField( - "Middle Name", "middlename", "", "text", &field); + test::CreateTestFormField("Middle Name", "middlename", "", "text", &field); form->fields.push_back(field); - autofill_test::CreateTestFormField( - "Last Name", "lastname", "", "text", &field); + test::CreateTestFormField("Last Name", "lastname", "", "text", &field); form->fields.push_back(field); field.autocomplete_attribute="cc-type"; - autofill_test::CreateTestFormField( - "cc-type", "cc-type", "", "text", &field); + test::CreateTestFormField("cc-type", "cc-type", "", "text", &field); form->fields.push_back(field); } @@ -236,11 +235,9 @@ void CreateTestShippingOptionsFormData(FormData* form) { form->user_submitted = true; FormFieldData field; - autofill_test::CreateTestFormField( - "Shipping1", "option", "option1", "radio", &field); + test::CreateTestFormField("Shipping1", "option", "option1", "radio", &field); form->fields.push_back(field); - autofill_test::CreateTestFormField( - "Shipping2", "option", "option2", "radio", &field); + test::CreateTestFormField("Shipping2", "option", "option2", "radio", &field); form->fields.push_back(field); } @@ -255,38 +252,27 @@ void CreateTestAddressFormData(FormData* form) { form->user_submitted = true; FormFieldData field; - autofill_test::CreateTestFormField( - "First Name", "firstname", "", "text", &field); + test::CreateTestFormField("First Name", "firstname", "", "text", &field); form->fields.push_back(field); - autofill_test::CreateTestFormField( - "Middle Name", "middlename", "", "text", &field); + test::CreateTestFormField("Middle Name", "middlename", "", "text", &field); form->fields.push_back(field); - autofill_test::CreateTestFormField( - "Last Name", "lastname", "", "text", &field); + test::CreateTestFormField("Last Name", "lastname", "", "text", &field); form->fields.push_back(field); - autofill_test::CreateTestFormField( - "Address Line 1", "addr1", "", "text", &field); + test::CreateTestFormField("Address Line 1", "addr1", "", "text", &field); form->fields.push_back(field); - autofill_test::CreateTestFormField( - "Address Line 2", "addr2", "", "text", &field); + test::CreateTestFormField("Address Line 2", "addr2", "", "text", &field); form->fields.push_back(field); - autofill_test::CreateTestFormField( - "City", "city", "", "text", &field); + test::CreateTestFormField("City", "city", "", "text", &field); form->fields.push_back(field); - autofill_test::CreateTestFormField( - "State", "state", "", "text", &field); + test::CreateTestFormField("State", "state", "", "text", &field); form->fields.push_back(field); - autofill_test::CreateTestFormField( - "Postal Code", "zipcode", "", "text", &field); + test::CreateTestFormField("Postal Code", "zipcode", "", "text", &field); form->fields.push_back(field); - autofill_test::CreateTestFormField( - "Country", "country", "", "text", &field); + test::CreateTestFormField("Country", "country", "", "text", &field); form->fields.push_back(field); - autofill_test::CreateTestFormField( - "Phone Number", "phonenumber", "", "tel", &field); + test::CreateTestFormField("Phone Number", "phonenumber", "", "tel", &field); form->fields.push_back(field); - autofill_test::CreateTestFormField( - "Email", "email", "", "email", &field); + test::CreateTestFormField("Email", "email", "", "email", &field); form->fields.push_back(field); } @@ -308,22 +294,18 @@ void CreateTestCreditCardFormData(FormData* form, form->user_submitted = true; FormFieldData field; - autofill_test::CreateTestFormField( - "Name on Card", "nameoncard", "", "text", &field); + test::CreateTestFormField("Name on Card", "nameoncard", "", "text", &field); form->fields.push_back(field); - autofill_test::CreateTestFormField( - "Card Number", "cardnumber", "", "text", &field); + test::CreateTestFormField("Card Number", "cardnumber", "", "text", &field); form->fields.push_back(field); if (use_month_type) { - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Expiration Date", "ccmonth", "", "month", &field); form->fields.push_back(field); } else { - autofill_test::CreateTestFormField( - "Expiration Date", "ccmonth", "", "text", &field); + test::CreateTestFormField("Expiration Date", "ccmonth", "", "text", &field); form->fields.push_back(field); - autofill_test::CreateTestFormField( - "", "ccyear", "", "text", &field); + test::CreateTestFormField("", "ccyear", "", "text", &field); form->fields.push_back(field); } } @@ -974,8 +956,7 @@ TEST_F(AutofillManagerTest, GetProfileSuggestionsMatchCharacter) { FormsSeen(forms); FormFieldData field; - autofill_test::CreateTestFormField("First Name", "firstname", "E", "text", - &field); + test::CreateTestFormField("First Name", "firstname", "E", "text",&field); GetAutofillSuggestions(form, field); // No suggestions provided, so send an empty vector as the results. @@ -1011,15 +992,13 @@ TEST_F(AutofillManagerTest, GetProfileSuggestionsUnknownFields) { form.user_submitted = true; FormFieldData field; - autofill_test::CreateTestFormField("Username", "username", "", "text", - &field); + test::CreateTestFormField("Username", "username", "", "text",&field); form.fields.push_back(field); - autofill_test::CreateTestFormField("Password", "password", "", "password", - &field); + test::CreateTestFormField("Password", "password", "", "password",&field); form.fields.push_back(field); - autofill_test::CreateTestFormField("Quest", "quest", "", "quest", &field); + test::CreateTestFormField("Quest", "quest", "", "quest", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField("Color", "color", "", "text", &field); + test::CreateTestFormField("Color", "color", "", "text", &field); form.fields.push_back(field); std::vector<FormData> forms(1, form); @@ -1215,8 +1194,7 @@ TEST_F(AutofillManagerTest, GetCreditCardSuggestionsMatchCharacter) { FormsSeen(forms); FormFieldData field; - autofill_test::CreateTestFormField( - "Card Number", "cardnumber", "4", "text", &field); + test::CreateTestFormField("Card Number", "cardnumber", "4", "text", &field); GetAutofillSuggestions(form, field); // No suggestions provided, so send an empty vector as the results. @@ -1358,9 +1336,9 @@ TEST_F(AutofillManagerTest, GetCreditCardSuggestionsRepeatedObfuscatedNumber) { // Add a credit card with the same obfuscated number as Elvis's. // |credit_card| will be owned by the mock PersonalDataManager. CreditCard* credit_card = new CreditCard; - autofill_test::SetCreditCardInfo(credit_card, "Elvis Presley", - "5231567890123456", // Mastercard - "04", "2012"); + test::SetCreditCardInfo(credit_card, "Elvis Presley", + "5231567890123456", // Mastercard + "04", "2012"); credit_card->set_guid("00000000-0000-0000-0000-000000000007"); autofill_manager_->AddCreditCard(credit_card); @@ -1451,8 +1429,7 @@ TEST_F(AutofillManagerTest, GetAddressAndCreditCardSuggestions) { expected_labels, expected_icons, expected_unique_ids); const int kPageID2 = 2; - autofill_test::CreateTestFormField( - "Card Number", "cardnumber", "", "text", &field); + test::CreateTestFormField("Card Number", "cardnumber", "", "text", &field); GetAutofillSuggestions(kPageID2, form, field); // No suggestions provided, so send an empty vector as the results. @@ -1525,8 +1502,7 @@ TEST_F(AutofillManagerTest, GetAddressAndCreditCardSuggestionsNonHttps) { kDefaultPageID, arraysize(expected_values), expected_values, expected_labels, expected_icons, expected_unique_ids); - autofill_test::CreateTestFormField( - "Card Number", "cardnumber", "", "text", &field); + test::CreateTestFormField("Card Number", "cardnumber", "", "text", &field); const int kPageID2 = 2; GetAutofillSuggestions(kPageID2, form, field); @@ -1648,8 +1624,7 @@ TEST_F(AutofillManagerTest, GetFieldSuggestionsForAutocompleteOnly) { FormData form; CreateTestAddressFormData(&form); FormFieldData field; - autofill_test::CreateTestFormField( - "Some Field", "somefield", "", "text", &field); + test::CreateTestFormField("Some Field", "somefield", "", "text", &field); form.fields.push_back(field); std::vector<FormData> forms(1, form); FormsSeen(forms); @@ -1695,8 +1670,8 @@ TEST_F(AutofillManagerTest, GetFieldSuggestionsWithDuplicateValues) { // |profile| will be owned by the mock PersonalDataManager. AutofillProfile* profile = new AutofillProfile; - autofill_test::SetProfileInfo(profile, "Elvis", "", "", "", "", "", "", "", - "", "", "", ""); + test::SetProfileInfo( + profile, "Elvis", "", "", "", "", "", "", "", "", "", "", ""); profile->set_guid("00000000-0000-0000-0000-000000000101"); autofill_manager_->AddProfile(profile); @@ -1738,8 +1713,8 @@ TEST_F(AutofillManagerTest, GetFieldSuggestionsForMultiValuedProfileUnfilled) { // |profile| will be owned by the mock PersonalDataManager. AutofillProfile* profile = new AutofillProfile; - autofill_test::SetProfileInfo(profile, "Elvis", "", "Presley", "me@x.com", "", - "", "", "", "", "", "", ""); + test::SetProfileInfo(profile, "Elvis", "", "Presley", "me@x.com", "", + "", "", "", "", "", "", ""); profile->set_guid("00000000-0000-0000-0000-000000000101"); std::vector<base::string16> multi_values(2); multi_values[0] = ASCIIToUTF16("Elvis Presley"); @@ -1942,7 +1917,7 @@ TEST_F(AutofillManagerTest, FillAddressForm) { TEST_F(AutofillManagerTest, FillAddressFormFromAuxiliaryProfile) { personal_data_.ClearAutofillProfiles(); PrefService* prefs = components::UserPrefs::Get(profile()); - prefs->SetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled, true); + prefs->SetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled, true); personal_data_.CreateTestAuxiliaryProfiles(); // Set up our form data. @@ -2202,47 +2177,47 @@ TEST_F(AutofillManagerTest, FillFormWithAuthorSpecifiedSections) { FormFieldData field; - autofill_test::CreateTestFormField("", "country", "", "text", &field); + test::CreateTestFormField("", "country", "", "text", &field); field.autocomplete_attribute = "section-billing country"; form.fields.push_back(field); - autofill_test::CreateTestFormField("", "firstname", "", "text", &field); + test::CreateTestFormField("", "firstname", "", "text", &field); field.autocomplete_attribute = "given-name"; form.fields.push_back(field); - autofill_test::CreateTestFormField("", "lastname", "", "text", &field); + test::CreateTestFormField("", "lastname", "", "text", &field); field.autocomplete_attribute = "family-name"; form.fields.push_back(field); - autofill_test::CreateTestFormField("", "address", "", "text", &field); + test::CreateTestFormField("", "address", "", "text", &field); field.autocomplete_attribute = "section-billing street-address"; form.fields.push_back(field); - autofill_test::CreateTestFormField("", "city", "", "text", &field); + test::CreateTestFormField("", "city", "", "text", &field); field.autocomplete_attribute = "section-billing locality"; form.fields.push_back(field); - autofill_test::CreateTestFormField("", "state", "", "text", &field); + test::CreateTestFormField("", "state", "", "text", &field); field.autocomplete_attribute = "section-billing region"; form.fields.push_back(field); - autofill_test::CreateTestFormField("", "zip", "", "text", &field); + test::CreateTestFormField("", "zip", "", "text", &field); field.autocomplete_attribute = "section-billing postal-code"; form.fields.push_back(field); - autofill_test::CreateTestFormField("", "ccname", "", "text", &field); + test::CreateTestFormField("", "ccname", "", "text", &field); field.autocomplete_attribute = "section-billing cc-name"; form.fields.push_back(field); - autofill_test::CreateTestFormField("", "ccnumber", "", "text", &field); + test::CreateTestFormField("", "ccnumber", "", "text", &field); field.autocomplete_attribute = "section-billing cc-number"; form.fields.push_back(field); - autofill_test::CreateTestFormField("", "ccexp", "", "text", &field); + test::CreateTestFormField("", "ccexp", "", "text", &field); field.autocomplete_attribute = "section-billing cc-exp"; form.fields.push_back(field); - autofill_test::CreateTestFormField("", "email", "", "text", &field); + test::CreateTestFormField("", "email", "", "text", &field); field.autocomplete_attribute = "email"; form.fields.push_back(field); @@ -2355,8 +2330,7 @@ TEST_F(AutofillManagerTest, FillFormWithMultipleEmails) { FormData form; CreateTestAddressFormData(&form); FormFieldData field; - autofill_test::CreateTestFormField( - "Confirm email", "email2", "", "text", &field); + test::CreateTestFormField("Confirm email", "email2", "", "text", &field); form.fields.push_back(field); std::vector<FormData> forms(1, form); @@ -2522,7 +2496,7 @@ TEST_F(AutofillManagerTest, FillPhoneNumber) { FormFieldData field; const size_t default_max_length = field.max_length; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_fields); ++i) { - autofill_test::CreateTestFormField( + test::CreateTestFormField( test_fields[i].label, test_fields[i].name, "", "text", &field); field.max_length = test_fields[i].max_length; field.autocomplete_attribute = std::string(); @@ -2650,7 +2624,7 @@ TEST_F(AutofillManagerTest, FormChangesRemoveField) { // Add a field -- we'll remove it again later. FormFieldData field; - autofill_test::CreateTestFormField("Some", "field", "", "text", &field); + test::CreateTestFormField("Some", "field", "", "text", &field); form.fields.insert(form.fields.begin() + 3, field); std::vector<FormData> forms(1, form); @@ -2840,15 +2814,20 @@ TEST_F(AutofillManagerTest, AuxiliaryProfilesReset) { // Auxiliary profiles is implemented on Mac and Android only. // OSX: enables Mac Address Book integration. // Android: enables integration with user's contact profile. - ASSERT_TRUE(prefs->GetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled)); - prefs->SetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled, false); - prefs->ClearPref(prefs::kAutofillAuxiliaryProfilesEnabled); - ASSERT_TRUE(prefs->GetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled)); + ASSERT_TRUE( + prefs->GetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled)); + prefs->SetBoolean( + ::autofill::prefs::kAutofillAuxiliaryProfilesEnabled, false); + prefs->ClearPref(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled); + ASSERT_TRUE( + prefs->GetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled)); #else - ASSERT_FALSE(prefs->GetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled)); - prefs->SetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled, true); - prefs->ClearPref(prefs::kAutofillAuxiliaryProfilesEnabled); - ASSERT_FALSE(prefs->GetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled)); + ASSERT_FALSE( + prefs->GetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled)); + prefs->SetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled, true); + prefs->ClearPref(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled); + ASSERT_FALSE( + prefs->GetBoolean(::autofill::prefs::kAutofillAuxiliaryProfilesEnabled)); #endif } @@ -2865,212 +2844,212 @@ TEST_F(AutofillManagerTest, DeterminePossibleFieldTypesForUpload) { // These fields should all match. FormFieldData field; FieldTypeSet types; - autofill_test::CreateTestFormField("", "1", "Elvis", "text", &field); + test::CreateTestFormField("", "1", "Elvis", "text", &field); types.clear(); types.insert(NAME_FIRST); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "2", "Aaron", "text", &field); + test::CreateTestFormField("", "2", "Aaron", "text", &field); types.clear(); types.insert(NAME_MIDDLE); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "3", "A", "text", &field); + test::CreateTestFormField("", "3", "A", "text", &field); types.clear(); types.insert(NAME_MIDDLE_INITIAL); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "4", "Presley", "text", &field); + test::CreateTestFormField("", "4", "Presley", "text", &field); types.clear(); types.insert(NAME_LAST); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "5", "Elvis Presley", "text", &field); + test::CreateTestFormField("", "5", "Elvis Presley", "text", &field); types.clear(); types.insert(CREDIT_CARD_NAME); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "6", "Elvis Aaron Presley", "text", + test::CreateTestFormField("", "6", "Elvis Aaron Presley", "text", &field); types.clear(); types.insert(NAME_FULL); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "7", "theking@gmail.com", "email", + test::CreateTestFormField("", "7", "theking@gmail.com", "email", &field); types.clear(); types.insert(EMAIL_ADDRESS); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "8", "RCA", "text", &field); + test::CreateTestFormField("", "8", "RCA", "text", &field); types.clear(); types.insert(COMPANY_NAME); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "9", "3734 Elvis Presley Blvd.", + test::CreateTestFormField("", "9", "3734 Elvis Presley Blvd.", "text", &field); types.clear(); types.insert(ADDRESS_HOME_LINE1); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "10", "Apt. 10", "text", &field); + test::CreateTestFormField("", "10", "Apt. 10", "text", &field); types.clear(); types.insert(ADDRESS_HOME_LINE2); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "11", "Memphis", "text", &field); + test::CreateTestFormField("", "11", "Memphis", "text", &field); types.clear(); types.insert(ADDRESS_HOME_CITY); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "12", "Tennessee", "text", &field); + test::CreateTestFormField("", "12", "Tennessee", "text", &field); types.clear(); types.insert(ADDRESS_HOME_STATE); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "13", "38116", "text", &field); + test::CreateTestFormField("", "13", "38116", "text", &field); types.clear(); types.insert(ADDRESS_HOME_ZIP); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "14", "USA", "text", &field); + test::CreateTestFormField("", "14", "USA", "text", &field); types.clear(); types.insert(ADDRESS_HOME_COUNTRY); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "15", "United States", "text", &field); + test::CreateTestFormField("", "15", "United States", "text", &field); types.clear(); types.insert(ADDRESS_HOME_COUNTRY); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "16", "+1 (234) 567-8901", "text", + test::CreateTestFormField("", "16", "+1 (234) 567-8901", "text", &field); types.clear(); types.insert(PHONE_HOME_WHOLE_NUMBER); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "17", "2345678901", "text", &field); + test::CreateTestFormField("", "17", "2345678901", "text", &field); types.clear(); types.insert(PHONE_HOME_CITY_AND_NUMBER); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "18", "1", "text", &field); + test::CreateTestFormField("", "18", "1", "text", &field); types.clear(); types.insert(PHONE_HOME_COUNTRY_CODE); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "19", "234", "text", &field); + test::CreateTestFormField("", "19", "234", "text", &field); types.clear(); types.insert(PHONE_HOME_CITY_CODE); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "20", "5678901", "text", &field); + test::CreateTestFormField("", "20", "5678901", "text", &field); types.clear(); types.insert(PHONE_HOME_NUMBER); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "21", "567", "text", &field); + test::CreateTestFormField("", "21", "567", "text", &field); types.clear(); types.insert(PHONE_HOME_NUMBER); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "22", "8901", "text", &field); + test::CreateTestFormField("", "22", "8901", "text", &field); types.clear(); types.insert(PHONE_HOME_NUMBER); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "23", "4234-5678-9012-3456", "text", + test::CreateTestFormField("", "23", "4234-5678-9012-3456", "text", &field); types.clear(); types.insert(CREDIT_CARD_NUMBER); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "24", "04", "text", &field); + test::CreateTestFormField("", "24", "04", "text", &field); types.clear(); types.insert(CREDIT_CARD_EXP_MONTH); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "25", "April", "text", &field); + test::CreateTestFormField("", "25", "April", "text", &field); types.clear(); types.insert(CREDIT_CARD_EXP_MONTH); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "26", "2012", "text", &field); + test::CreateTestFormField("", "26", "2012", "text", &field); types.clear(); types.insert(CREDIT_CARD_EXP_4_DIGIT_YEAR); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "27", "12", "text", &field); + test::CreateTestFormField("", "27", "12", "text", &field); types.clear(); types.insert(CREDIT_CARD_EXP_2_DIGIT_YEAR); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "28", "04/2012", "text", &field); + test::CreateTestFormField("", "28", "04/2012", "text", &field); types.clear(); types.insert(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR); form.fields.push_back(field); expected_types.push_back(types); // Make sure that we trim whitespace properly. - autofill_test::CreateTestFormField("", "29", "", "text", &field); + test::CreateTestFormField("", "29", "", "text", &field); types.clear(); types.insert(EMPTY_TYPE); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "30", " ", "text", &field); + test::CreateTestFormField("", "30", " ", "text", &field); types.clear(); types.insert(EMPTY_TYPE); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "31", " Elvis", "text", &field); + test::CreateTestFormField("", "31", " Elvis", "text", &field); types.clear(); types.insert(NAME_FIRST); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "32", "Elvis ", "text", &field); + test::CreateTestFormField("", "32", "Elvis ", "text", &field); types.clear(); types.insert(NAME_FIRST); form.fields.push_back(field); expected_types.push_back(types); // These fields should not match, as they differ by case. - autofill_test::CreateTestFormField("", "33", "elvis", "text", &field); + test::CreateTestFormField("", "33", "elvis", "text", &field); types.clear(); types.insert(UNKNOWN_TYPE); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "34", "3734 Elvis Presley BLVD", + test::CreateTestFormField("", "34", "3734 Elvis Presley BLVD", "text", &field); types.clear(); types.insert(UNKNOWN_TYPE); @@ -3078,50 +3057,50 @@ TEST_F(AutofillManagerTest, DeterminePossibleFieldTypesForUpload) { expected_types.push_back(types); // These fields should not match, as they are unsupported variants. - autofill_test::CreateTestFormField("", "35", "Elvis Aaron", "text", &field); + test::CreateTestFormField("", "35", "Elvis Aaron", "text", &field); types.clear(); types.insert(UNKNOWN_TYPE); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "36", "Mr. Presley", "text", &field); + test::CreateTestFormField("", "36", "Mr. Presley", "text", &field); types.clear(); types.insert(UNKNOWN_TYPE); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "37", "3734 Elvis Presley", "text", + test::CreateTestFormField("", "37", "3734 Elvis Presley", "text", &field); types.clear(); types.insert(UNKNOWN_TYPE); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "38", "TN", "text", &field); + test::CreateTestFormField("", "38", "TN", "text", &field); types.clear(); types.insert(UNKNOWN_TYPE); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "39", "38116-1023", "text", &field); + test::CreateTestFormField("", "39", "38116-1023", "text", &field); types.clear(); types.insert(UNKNOWN_TYPE); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "20", "5", "text", &field); + test::CreateTestFormField("", "20", "5", "text", &field); types.clear(); types.insert(UNKNOWN_TYPE); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "20", "56", "text", &field); + test::CreateTestFormField("", "20", "56", "text", &field); types.clear(); types.insert(UNKNOWN_TYPE); form.fields.push_back(field); expected_types.push_back(types); - autofill_test::CreateTestFormField("", "20", "901", "text", &field); + test::CreateTestFormField("", "20", "901", "text", &field); types.clear(); types.insert(UNKNOWN_TYPE); form.fields.push_back(field); @@ -3140,10 +3119,10 @@ TEST_F(AutofillManagerTest, UpdatePasswordSyncState) { PrefService* prefs = components::UserPrefs::Get(profile()); // Allow this test to control what should get synced. - prefs->SetBoolean(prefs::kSyncKeepEverythingSynced, false); + prefs->SetBoolean(::prefs::kSyncKeepEverythingSynced, false); // Always set password generation enabled check box so we can test the // behavior of password sync. - prefs->SetBoolean(prefs::kPasswordGenerationEnabled, true); + prefs->SetBoolean(::autofill::prefs::kPasswordGenerationEnabled, true); // Sync some things, but not passwords. Shouldn't send anything since // password generation is disabled by default. @@ -3198,10 +3177,10 @@ TEST_F(IncognitoAutofillManagerTest, UpdatePasswordSyncStateIncognito) { PrefService* prefs = components::UserPrefs::Get(profile()); // Allow this test to control what should get synced. - prefs->SetBoolean(prefs::kSyncKeepEverythingSynced, false); + prefs->SetBoolean(::prefs::kSyncKeepEverythingSynced, false); // Always set password generation enabled check box so we can test the // behavior of password sync. - prefs->SetBoolean(prefs::kPasswordGenerationEnabled, true); + prefs->SetBoolean(::autofill::prefs::kPasswordGenerationEnabled, true); browser_sync::SyncPrefs sync_prefs(profile()->GetPrefs()); sync_prefs.SetSyncSetupCompleted(); @@ -3219,7 +3198,7 @@ TEST_F(AutofillManagerTest, UpdatePasswordGenerationState) { // Always set password sync enabled so we can test the behavior of password // generation. - prefs->SetBoolean(prefs::kSyncKeepEverythingSynced, false); + prefs->SetBoolean(::prefs::kSyncKeepEverythingSynced, false); ProfileSyncService* sync_service = ProfileSyncServiceFactory::GetForProfile( profile()); sync_service->SetSyncSetupCompleted(); @@ -3228,24 +3207,24 @@ TEST_F(AutofillManagerTest, UpdatePasswordGenerationState) { sync_service->ChangePreferredDataTypes(preferred_set); // Enabled state remains false, should not sent. - prefs->SetBoolean(prefs::kPasswordGenerationEnabled, false); + prefs->SetBoolean(::autofill::prefs::kPasswordGenerationEnabled, false); UpdatePasswordGenerationState(false); EXPECT_EQ(0u, autofill_manager_->GetSentStates().size()); // Enabled state from false to true, should sent true. - prefs->SetBoolean(prefs::kPasswordGenerationEnabled, true); + prefs->SetBoolean(::autofill::prefs::kPasswordGenerationEnabled, true); UpdatePasswordGenerationState(false); EXPECT_EQ(1u, autofill_manager_->GetSentStates().size()); EXPECT_TRUE(autofill_manager_->GetSentStates()[0]); autofill_manager_->ClearSentStates(); // Enabled states remains true, should not sent. - prefs->SetBoolean(prefs::kPasswordGenerationEnabled, true); + prefs->SetBoolean(::autofill::prefs::kPasswordGenerationEnabled, true); UpdatePasswordGenerationState(false); EXPECT_EQ(0u, autofill_manager_->GetSentStates().size()); // Enabled states from true to false, should sent false. - prefs->SetBoolean(prefs::kPasswordGenerationEnabled, false); + prefs->SetBoolean(::autofill::prefs::kPasswordGenerationEnabled, false); UpdatePasswordGenerationState(false); EXPECT_EQ(1u, autofill_manager_->GetSentStates().size()); EXPECT_FALSE(autofill_manager_->GetSentStates()[0]); @@ -3359,3 +3338,5 @@ TEST_F(AutofillManagerTest, TestExternalDelegate) { autofill_manager_->SetExternalDelegate(NULL); } + +} // namespace autofill diff --git a/components/autofill/browser/autofill_merge_unittest.cc b/components/autofill/browser/autofill_merge_unittest.cc index e3f6bc8..5b021bd 100644 --- a/components/autofill/browser/autofill_merge_unittest.cc +++ b/components/autofill/browser/autofill_merge_unittest.cc @@ -18,6 +18,8 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" +namespace autofill { + namespace { const base::FilePath::CharType kTestName[] = FILE_PATH_LITERAL("merge"); @@ -142,7 +144,7 @@ AutofillMergeTest::~AutofillMergeTest() { } void AutofillMergeTest::SetUp() { - autofill_test::DisableSystemServices(NULL); + test::DisableSystemServices(NULL); } void AutofillMergeTest::GenerateResults(const std::string& input, @@ -217,3 +219,5 @@ TEST_F(AutofillMergeTest, DataDrivenMergeProfiles) { RunDataDrivenTest(GetInputDirectory(kTestName), GetOutputDirectory(kTestName), kFileNamePattern); } + +} // namespace autofill diff --git a/components/autofill/browser/autofill_metrics.cc b/components/autofill/browser/autofill_metrics.cc index c062df9..e83ae02 100644 --- a/components/autofill/browser/autofill_metrics.cc +++ b/components/autofill/browser/autofill_metrics.cc @@ -11,6 +11,8 @@ #include "components/autofill/browser/form_structure.h" #include "components/autofill/common/form_data.h" +namespace autofill { + namespace { // Server experiments we support. @@ -132,13 +134,13 @@ int GetFieldTypeGroupMetric(const AutofillFieldType field_type, case AutofillType::CREDIT_CARD: switch (field_type) { - case ::CREDIT_CARD_NAME: + case ::autofill::CREDIT_CARD_NAME: group = CREDIT_CARD_NAME; break; - case ::CREDIT_CARD_NUMBER: + case ::autofill::CREDIT_CARD_NUMBER: group = CREDIT_CARD_NUMBER; break; - case ::CREDIT_CARD_TYPE: + case ::autofill::CREDIT_CARD_TYPE: group = CREDIT_CARD_TYPE; default: group = CREDIT_CARD_DATE; @@ -556,3 +558,5 @@ void AutofillMetrics::LogServerExperimentIdForUpload( const std::string& experiment_id) const { LogServerExperimentId("Autofill.ServerExperimentId.Upload", experiment_id); } + +} // namespace autofill diff --git a/components/autofill/browser/autofill_metrics.h b/components/autofill/browser/autofill_metrics.h index 5f8f4e4..ddd16b9 100644 --- a/components/autofill/browser/autofill_metrics.h +++ b/components/autofill/browser/autofill_metrics.h @@ -16,6 +16,8 @@ namespace base { class TimeDelta; } +namespace autofill { + class AutofillMetrics { public: // The possible results of an Autocheckout flow. @@ -410,4 +412,6 @@ class AutofillMetrics { DISALLOW_COPY_AND_ASSIGN(AutofillMetrics); }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_METRICS_H_ diff --git a/components/autofill/browser/autofill_metrics_unittest.cc b/components/autofill/browser/autofill_metrics_unittest.cc index 1c20057..5888b8c 100644 --- a/components/autofill/browser/autofill_metrics_unittest.cc +++ b/components/autofill/browser/autofill_metrics_unittest.cc @@ -35,6 +35,8 @@ using ::testing::Mock; using base::TimeTicks; using base::TimeDelta; +namespace autofill { + namespace { class MockAutofillMetrics : public AutofillMetrics { @@ -125,18 +127,18 @@ class TestPersonalDataManager : public PersonalDataManager { private: void CreateTestAutofillProfiles(ScopedVector<AutofillProfile>* profiles) { AutofillProfile* profile = new AutofillProfile; - autofill_test::SetProfileInfo(profile, "Elvis", "Aaron", - "Presley", "theking@gmail.com", "RCA", - "3734 Elvis Presley Blvd.", "Apt. 10", - "Memphis", "Tennessee", "38116", "US", - "12345678901"); + test::SetProfileInfo(profile, "Elvis", "Aaron", + "Presley", "theking@gmail.com", "RCA", + "3734 Elvis Presley Blvd.", "Apt. 10", + "Memphis", "Tennessee", "38116", "US", + "12345678901"); profile->set_guid("00000000-0000-0000-0000-000000000001"); profiles->push_back(profile); profile = new AutofillProfile; - autofill_test::SetProfileInfo(profile, "Charles", "Hardin", - "Holley", "buddy@gmail.com", "Decca", - "123 Apple St.", "unit 6", "Lubbock", - "Texas", "79401", "US", "2345678901"); + test::SetProfileInfo(profile, "Charles", "Hardin", + "Holley", "buddy@gmail.com", "Decca", + "123 Apple St.", "unit 6", "Lubbock", + "Texas", "79401", "US", "2345678901"); profile->set_guid("00000000-0000-0000-0000-000000000002"); profiles->push_back(profile); } @@ -182,7 +184,7 @@ class TestFormStructure : public FormStructure { class TestAutofillManager : public AutofillManager { public: TestAutofillManager(content::WebContents* web_contents, - autofill::AutofillManagerDelegate* manager_delegate, + AutofillManagerDelegate* manager_delegate, TestPersonalDataManager* personal_manager) : AutofillManager(web_contents, manager_delegate, personal_manager), autofill_enabled_(true), @@ -306,18 +308,17 @@ void AutofillMetricsTest::SetUp() { TestingProfile* profile = new TestingProfile(); profile->CreateRequestContext(); browser_context_.reset(profile); - autofill::PersonalDataManagerFactory::GetInstance()->SetTestingFactory( - profile, NULL); + PersonalDataManagerFactory::GetInstance()->SetTestingFactory( profile, NULL); ChromeRenderViewHostTestHarness::SetUp(); io_thread_.StartIOThread(); - autofill::TabAutofillManagerDelegate::CreateForWebContents(web_contents()); + TabAutofillManagerDelegate::CreateForWebContents(web_contents()); personal_data_.reset(new TestPersonalDataManager()); personal_data_->SetBrowserContext(profile); autofill_manager_.reset(new TestAutofillManager( web_contents(), - autofill::TabAutofillManagerDelegate::FromWebContents(web_contents()), + TabAutofillManagerDelegate::FromWebContents(web_contents()), personal_data_.get())); file_thread_.Start(); @@ -342,7 +343,7 @@ scoped_ptr<ConfirmInfoBarDelegate> AutofillMetricsTest::CreateDelegate( LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN)); CreditCard credit_card; - return autofill::AutofillCCInfoBarDelegate::CreateForTesting( + return AutofillCCInfoBarDelegate::CreateForTesting( metric_logger, base::Bind(&TestPersonalDataManager::SaveImportedCreditCard, base::Unretained(personal_data_.get()), credit_card)); @@ -361,43 +362,39 @@ TEST_F(AutofillMetricsTest, QualityMetrics) { std::vector<AutofillFieldType> heuristic_types, server_types; FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Autofilled", "autofilled", "Elvis Aaron Presley", "text", &field); field.is_autofilled = true; form.fields.push_back(field); heuristic_types.push_back(NAME_FULL); server_types.push_back(NAME_FIRST); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Autofill Failed", "autofillfailed", "buddy@gmail.com", "text", &field); field.is_autofilled = false; form.fields.push_back(field); heuristic_types.push_back(PHONE_HOME_NUMBER); server_types.push_back(EMAIL_ADDRESS); - autofill_test::CreateTestFormField( - "Empty", "empty", "", "text", &field); + test::CreateTestFormField("Empty", "empty", "", "text", &field); field.is_autofilled = false; form.fields.push_back(field); heuristic_types.push_back(NAME_FULL); server_types.push_back(NAME_FIRST); - autofill_test::CreateTestFormField( - "Unknown", "unknown", "garbage", "text", &field); + test::CreateTestFormField("Unknown", "unknown", "garbage", "text", &field); field.is_autofilled = false; form.fields.push_back(field); heuristic_types.push_back(PHONE_HOME_NUMBER); server_types.push_back(EMAIL_ADDRESS); - autofill_test::CreateTestFormField( - "Select", "select", "USA", "select-one", &field); + test::CreateTestFormField("Select", "select", "USA", "select-one", &field); field.is_autofilled = false; form.fields.push_back(field); heuristic_types.push_back(UNKNOWN_TYPE); server_types.push_back(NO_SERVER_DATA); - autofill_test::CreateTestFormField( - "Phone", "phone", "2345678901", "tel", &field); + test::CreateTestFormField("Phone", "phone", "2345678901", "tel", &field); field.is_autofilled = true; form.fields.push_back(field); heuristic_types.push_back(PHONE_HOME_CITY_AND_NUMBER); @@ -575,9 +572,9 @@ TEST_F(AutofillMetricsTest, QualityMetricsForFailure) { std::vector<AutofillFieldType> heuristic_types, server_types; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(failure_cases); ++i) { FormFieldData field; - autofill_test::CreateTestFormField(failure_cases[i].label, - failure_cases[i].name, - failure_cases[i].value, "text", &field); + test::CreateTestFormField(failure_cases[i].label, + failure_cases[i].name, + failure_cases[i].value, "text", &field); form.fields.push_back(field); heuristic_types.push_back(failure_cases[i].heuristic_type); server_types.push_back(failure_cases[i].server_type); @@ -628,26 +625,25 @@ TEST_F(AutofillMetricsTest, SaneMetricsWithCacheMismatch) { std::vector<AutofillFieldType> heuristic_types, server_types; FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Both match", "match", "Elvis Aaron Presley", "text", &field); field.is_autofilled = true; form.fields.push_back(field); heuristic_types.push_back(NAME_FULL); server_types.push_back(NAME_FULL); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Both mismatch", "mismatch", "buddy@gmail.com", "text", &field); field.is_autofilled = false; form.fields.push_back(field); heuristic_types.push_back(PHONE_HOME_NUMBER); server_types.push_back(PHONE_HOME_NUMBER); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Only heuristics match", "mixed", "Memphis", "text", &field); field.is_autofilled = false; form.fields.push_back(field); heuristic_types.push_back(ADDRESS_HOME_CITY); server_types.push_back(PHONE_HOME_NUMBER); - autofill_test::CreateTestFormField( - "Unknown", "unknown", "garbage", "text", &field); + test::CreateTestFormField("Unknown", "unknown", "garbage", "text", &field); field.is_autofilled = false; form.fields.push_back(field); heuristic_types.push_back(UNKNOWN_TYPE); @@ -662,7 +658,7 @@ TEST_F(AutofillMetricsTest, SaneMetricsWithCacheMismatch) { // Add a field and re-arrange the remaining form fields before submitting. std::vector<FormFieldData> cached_fields = form.fields; form.fields.clear(); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "New field", "new field", "Tennessee", "text", &field); form.fields.push_back(field); form.fields.push_back(cached_fields[2]); @@ -782,9 +778,9 @@ TEST_F(AutofillMetricsTest, DeveloperEngagement) { form.action = GURL("http://example.com/submit.html"); FormFieldData field; - autofill_test::CreateTestFormField("Name", "name", "", "text", &field); + test::CreateTestFormField("Name", "name", "", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField("Email", "email", "", "text", &field); + test::CreateTestFormField("Email", "email", "", "text", &field); form.fields.push_back(field); std::vector<FormData> forms(1, form); @@ -799,7 +795,7 @@ TEST_F(AutofillMetricsTest, DeveloperEngagement) { } // Add another field to the form, so that it becomes fillable. - autofill_test::CreateTestFormField("Phone", "phone", "", "text", &field); + test::CreateTestFormField("Phone", "phone", "", "text", &field); forms.back().fields.push_back(field); // Expect only the "form parsed" metric to be logged; no metrics about @@ -823,13 +819,13 @@ TEST_F(AutofillMetricsTest, DeveloperEngagement) { // three fillable fields to be considered to be autofillable; and if at least // one field specifies an explicit type hint, we don't apply any of our usual // local heuristics to detect field types in the rest of the form. - autofill_test::CreateTestFormField("", "", "", "text", &field); + test::CreateTestFormField("", "", "", "text", &field); field.autocomplete_attribute = "given-name"; forms.back().fields.push_back(field); - autofill_test::CreateTestFormField("", "", "", "text", &field); + test::CreateTestFormField("", "", "", "text", &field); field.autocomplete_attribute = "email"; forms.back().fields.push_back(field); - autofill_test::CreateTestFormField("", "", "", "text", &field); + test::CreateTestFormField("", "", "", "text", &field); field.autocomplete_attribute = "street-address"; forms.back().fields.push_back(field); @@ -861,11 +857,11 @@ TEST_F(AutofillMetricsTest, NoQualityMetricsForNonAutofillableForms) { form.user_submitted = true; FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Autofilled", "autofilled", "Elvis Presley", "text", &field); field.is_autofilled = true; form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Autofill Failed", "autofillfailed", "buddy@gmail.com", "text", &field); form.fields.push_back(field); @@ -878,8 +874,7 @@ TEST_F(AutofillMetricsTest, NoQualityMetricsForNonAutofillableForms) { // Search forms are not auto-fillable. form.action = GURL("http://example.com/search?q=Elvis%20Presley"); - autofill_test::CreateTestFormField( - "Empty", "empty", "", "text", &field); + test::CreateTestFormField("Empty", "empty", "", "text", &field); form.fields.push_back(field); // Simulate form submission. @@ -903,36 +898,33 @@ TEST_F(AutofillMetricsTest, QualityMetricsWithExperimentId) { std::vector<AutofillFieldType> heuristic_types, server_types; FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Autofilled", "autofilled", "Elvis Aaron Presley", "text", &field); field.is_autofilled = true; form.fields.push_back(field); heuristic_types.push_back(NAME_FULL); server_types.push_back(NAME_FIRST); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Autofill Failed", "autofillfailed", "buddy@gmail.com", "text", &field); field.is_autofilled = false; form.fields.push_back(field); heuristic_types.push_back(PHONE_HOME_NUMBER); server_types.push_back(EMAIL_ADDRESS); - autofill_test::CreateTestFormField( - "Empty", "empty", "", "text", &field); + test::CreateTestFormField("Empty", "empty", "", "text", &field); field.is_autofilled = false; form.fields.push_back(field); heuristic_types.push_back(NAME_FULL); server_types.push_back(NAME_FIRST); - autofill_test::CreateTestFormField( - "Unknown", "unknown", "garbage", "text", &field); + test::CreateTestFormField("Unknown", "unknown", "garbage", "text", &field); field.is_autofilled = false; form.fields.push_back(field); heuristic_types.push_back(PHONE_HOME_NUMBER); server_types.push_back(EMAIL_ADDRESS); - autofill_test::CreateTestFormField( - "Select", "select", "USA", "select-one", &field); + test::CreateTestFormField("Select", "select", "USA", "select-one", &field); field.is_autofilled = false; form.fields.push_back(field); heuristic_types.push_back(UNKNOWN_TYPE); @@ -1057,13 +1049,13 @@ TEST_F(AutofillMetricsTest, AddressSuggestionsCount) { FormFieldData field; std::vector<AutofillFieldType> field_types; - autofill_test::CreateTestFormField("Name", "name", "", "text", &field); + test::CreateTestFormField("Name", "name", "", "text", &field); form.fields.push_back(field); field_types.push_back(NAME_FULL); - autofill_test::CreateTestFormField("Email", "email", "", "email", &field); + test::CreateTestFormField("Email", "email", "", "email", &field); form.fields.push_back(field); field_types.push_back(EMAIL_ADDRESS); - autofill_test::CreateTestFormField("Phone", "phone", "", "tel", &field); + test::CreateTestFormField("Phone", "phone", "", "tel", &field); form.fields.push_back(field); field_types.push_back(PHONE_HOME_NUMBER); @@ -1083,7 +1075,7 @@ TEST_F(AutofillMetricsTest, AddressSuggestionsCount) { // Simulate activating the autofill popup for the email field after typing. // No new metric should be logged, since we're still on the same page. - autofill_test::CreateTestFormField("Email", "email", "b", "email", &field); + test::CreateTestFormField("Email", "email", "b", "email", &field); autofill_manager_->OnQueryFormFieldAutofill( 0, form, field, gfx::Rect(), false); @@ -1199,7 +1191,7 @@ TEST_F(AutofillMetricsTest, ServerQueryExperimentIdForQuery) { EXPECT_CALL(metric_logger, LogServerQueryMetric( AutofillMetrics::QUERY_RESPONSE_MATCHED_LOCAL_HEURISTICS)); - autofill::AutocheckoutPageMetaData page_meta_data; + AutocheckoutPageMetaData page_meta_data; FormStructure::ParseQueryResponse( "<autofillqueryresponse></autofillqueryresponse>", std::vector<FormStructure*>(), @@ -1235,9 +1227,9 @@ TEST_F(AutofillMetricsTest, UserHappinessFormLoadAndSubmission) { form.user_submitted = true; FormFieldData field; - autofill_test::CreateTestFormField("Name", "name", "", "text", &field); + test::CreateTestFormField("Name", "name", "", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField("Email", "email", "", "text", &field); + test::CreateTestFormField("Email", "email", "", "text", &field); form.fields.push_back(field); std::vector<FormData> forms(1, form); @@ -1272,9 +1264,9 @@ TEST_F(AutofillMetricsTest, UserHappinessFormLoadAndSubmission) { } // Add more fields to the form. - autofill_test::CreateTestFormField("Phone", "phone", "", "text", &field); + test::CreateTestFormField("Phone", "phone", "", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField("Unknown", "unknown", "", "text", &field); + test::CreateTestFormField("Unknown", "unknown", "", "text", &field); form.fields.push_back(field); forms.front() = form; @@ -1369,11 +1361,11 @@ TEST_F(AutofillMetricsTest, UserHappinessFormInteraction) { form.user_submitted = true; FormFieldData field; - autofill_test::CreateTestFormField("Name", "name", "", "text", &field); + test::CreateTestFormField("Name", "name", "", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField("Email", "email", "", "text", &field); + test::CreateTestFormField("Email", "email", "", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField("Phone", "phone", "", "text", &field); + test::CreateTestFormField("Phone", "phone", "", "text", &field); form.fields.push_back(field); std::vector<FormData> forms(1, form); @@ -1475,11 +1467,11 @@ TEST_F(AutofillMetricsTest, FormFillDuration) { form.user_submitted = true; FormFieldData field; - autofill_test::CreateTestFormField("Name", "name", "", "text", &field); + test::CreateTestFormField("Name", "name", "", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField("Email", "email", "", "text", &field); + test::CreateTestFormField("Email", "email", "", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField("Phone", "phone", "", "text", &field); + test::CreateTestFormField("Phone", "phone", "", "text", &field); form.fields.push_back(field); std::vector<FormData> forms(1, form); @@ -1576,3 +1568,5 @@ TEST_F(AutofillMetricsTest, FormFillDuration) { Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); } } + +} // namespace autofill diff --git a/components/autofill/browser/autofill_popup_delegate.h b/components/autofill/browser/autofill_popup_delegate.h index 595a0e0..78237fe 100644 --- a/components/autofill/browser/autofill_popup_delegate.h +++ b/components/autofill/browser/autofill_popup_delegate.h @@ -11,6 +11,8 @@ namespace content { class KeyboardListener; } +namespace autofill { + // An interface for interaction with AutofillPopupController. Will be notified // of events by the controller. class AutofillPopupDelegate { @@ -39,4 +41,6 @@ class AutofillPopupDelegate { virtual void ClearPreviewedForm() = 0; }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_POPUP_DELEGATE_H_ diff --git a/components/autofill/browser/autofill_profile.cc b/components/autofill/browser/autofill_profile.cc index 6faeeb2..9b76b4b 100644 --- a/components/autofill/browser/autofill_profile.cc +++ b/components/autofill/browser/autofill_profile.cc @@ -26,6 +26,7 @@ #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" +namespace autofill { namespace { // Like |AutofillType::GetEquivalentFieldType()|, but also returns |NAME_FULL| @@ -196,13 +197,11 @@ class FindByPhone { } bool operator()(const base::string16& phone) { - return autofill_i18n::PhoneNumbersMatch( - phone, phone_, country_code_, app_locale_); + return i18n::PhoneNumbersMatch(phone, phone_, country_code_, app_locale_); } bool operator()(const base::string16* phone) { - return autofill_i18n::PhoneNumbersMatch( - *phone, phone_, country_code_, app_locale_); + return i18n::PhoneNumbersMatch(*phone, phone_, country_code_, app_locale_); } private: @@ -487,7 +486,7 @@ bool AutofillProfile::IsSubsetOf(const AutofillProfile& profile, // Phone numbers should be canonicalized prior to being compared. if (*iter != PHONE_HOME_WHOLE_NUMBER) { continue; - } else if (!autofill_i18n::PhoneNumbersMatch( + } else if (!i18n::PhoneNumbersMatch( GetRawInfo(*iter), profile.GetRawInfo(*iter), UTF16ToASCII(GetRawInfo(ADDRESS_HOME_COUNTRY)), @@ -860,3 +859,5 @@ std::ostream& operator<<(std::ostream& os, const AutofillProfile& profile) { << " " << UTF16ToUTF8(MultiString(profile, PHONE_HOME_WHOLE_NUMBER)); } + +} // namespace autofill diff --git a/components/autofill/browser/autofill_profile.h b/components/autofill/browser/autofill_profile.h index 538a6f9..a3127b8 100644 --- a/components/autofill/browser/autofill_profile.h +++ b/components/autofill/browser/autofill_profile.h @@ -20,6 +20,8 @@ #include "components/autofill/browser/form_group.h" #include "components/autofill/browser/phone_number.h" +namespace autofill { + struct FormFieldData; // A collection of FormGroups stored in a profile. AutofillProfile also @@ -210,4 +212,6 @@ class AutofillProfile : public FormGroup { // So we can compare AutofillProfiles with EXPECT_EQ(). std::ostream& operator<<(std::ostream& os, const AutofillProfile& profile); +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_PROFILE_H_ diff --git a/components/autofill/browser/autofill_profile_unittest.cc b/components/autofill/browser/autofill_profile_unittest.cc index 71c03cc..212fea5 100644 --- a/components/autofill/browser/autofill_profile_unittest.cc +++ b/components/autofill/browser/autofill_profile_unittest.cc @@ -16,6 +16,8 @@ #include "grit/generated_resources.h" #include "testing/gtest/include/gtest/gtest.h" +namespace autofill { + namespace { bool UpdateProfileLabel(AutofillProfile *profile) { @@ -39,7 +41,7 @@ TEST(AutofillProfileTest, PreviewSummaryString) { // Case 0a/empty name and address, so the first two fields of the rest of the // data is used: "Hollywood, CA" AutofillProfile profile00; - autofill_test::SetProfileInfo(&profile00, "", "", "", + test::SetProfileInfo(&profile00, "", "", "", "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", "91601", "US", "16505678910"); EXPECT_TRUE(UpdateProfileLabel(&profile00)); @@ -48,7 +50,7 @@ TEST(AutofillProfileTest, PreviewSummaryString) { // Case 1: "<address>" without line 2. AutofillProfile profile1; - autofill_test::SetProfileInfo(&profile1, "", "", "", + test::SetProfileInfo(&profile1, "", "", "", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "", "Hollywood", "CA", "91601", "US", "16505678910"); EXPECT_TRUE(UpdateProfileLabel(&profile1)); @@ -57,7 +59,7 @@ TEST(AutofillProfileTest, PreviewSummaryString) { // Case 1a: "<address>" with line 2. AutofillProfile profile1a; - autofill_test::SetProfileInfo(&profile1a, "", "", "", + test::SetProfileInfo(&profile1a, "", "", "", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", "91601", "US", "16505678910"); EXPECT_TRUE(UpdateProfileLabel(&profile1a)); @@ -66,7 +68,7 @@ TEST(AutofillProfileTest, PreviewSummaryString) { // Case 2: "<lastname>" AutofillProfile profile2; - autofill_test::SetProfileInfo(&profile2, "", "Mitchell", + test::SetProfileInfo(&profile2, "", "Mitchell", "Morrison", "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", "91601", "US", "16505678910"); EXPECT_TRUE(UpdateProfileLabel(&profile2)); @@ -76,7 +78,7 @@ TEST(AutofillProfileTest, PreviewSummaryString) { // Case 3: "<lastname>, <address>" AutofillProfile profile3; - autofill_test::SetProfileInfo(&profile3, "", "Mitchell", + test::SetProfileInfo(&profile3, "", "Mitchell", "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "", "Hollywood", "CA", "91601", "US", "16505678910"); EXPECT_TRUE(UpdateProfileLabel(&profile3)); @@ -85,7 +87,7 @@ TEST(AutofillProfileTest, PreviewSummaryString) { // Case 4: "<firstname>" AutofillProfile profile4; - autofill_test::SetProfileInfo(&profile4, "Marion", "Mitchell", "", + test::SetProfileInfo(&profile4, "Marion", "Mitchell", "", "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", "91601", "US", "16505678910"); EXPECT_TRUE(UpdateProfileLabel(&profile4)); @@ -94,7 +96,7 @@ TEST(AutofillProfileTest, PreviewSummaryString) { // Case 5: "<firstname>, <address>" AutofillProfile profile5; - autofill_test::SetProfileInfo(&profile5, "Marion", "Mitchell", "", + test::SetProfileInfo(&profile5, "Marion", "Mitchell", "", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", "91601", "US", "16505678910"); EXPECT_TRUE(UpdateProfileLabel(&profile5)); @@ -103,7 +105,7 @@ TEST(AutofillProfileTest, PreviewSummaryString) { // Case 6: "<firstname> <lastname>" AutofillProfile profile6; - autofill_test::SetProfileInfo(&profile6, "Marion", "Mitchell", + test::SetProfileInfo(&profile6, "Marion", "Mitchell", "Morrison", "johnwayne@me.xyz", "Fox", "", "", "Hollywood", "CA", "91601", "US", "16505678910"); EXPECT_TRUE(UpdateProfileLabel(&profile6)); @@ -113,18 +115,17 @@ TEST(AutofillProfileTest, PreviewSummaryString) { // Case 7: "<firstname> <lastname>, <address>" AutofillProfile profile7; - autofill_test::SetProfileInfo(&profile7, "Marion", "Mitchell", + test::SetProfileInfo(&profile7, "Marion", "Mitchell", "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", "91601", "US", "16505678910"); EXPECT_TRUE(UpdateProfileLabel(&profile7)); base::string16 summary7 = profile7.Label(); - EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison, 123 Zoo St."), - summary7); + EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison, 123 Zoo St."), summary7); // Case 7a: "<firstname> <lastname>, <address>" - same as #7, except for // e-mail. AutofillProfile profile7a; - autofill_test::SetProfileInfo(&profile7a, "Marion", "Mitchell", + test::SetProfileInfo(&profile7a, "Marion", "Mitchell", "Morrison", "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", "91601", "US", "16505678910"); std::vector<AutofillProfile*> profiles; @@ -142,7 +143,7 @@ TEST(AutofillProfileTest, PreviewSummaryString) { TEST(AutofillProfileTest, AdjustInferredLabels) { std::vector<AutofillProfile*> profiles; profiles.push_back(new AutofillProfile); - autofill_test::SetProfileInfo( + test::SetProfileInfo( profiles[0], "John", "", @@ -156,7 +157,7 @@ TEST(AutofillProfileTest, AdjustInferredLabels) { "US", "16502111111"); profiles.push_back(new AutofillProfile); - autofill_test::SetProfileInfo( + test::SetProfileInfo( profiles[1], "Jane", "", @@ -179,7 +180,7 @@ TEST(AutofillProfileTest, AdjustInferredLabels) { profiles[1]->Label()); profiles.push_back(new AutofillProfile); - autofill_test::SetProfileInfo( + test::SetProfileInfo( profiles[2], "John", "", @@ -206,7 +207,7 @@ TEST(AutofillProfileTest, AdjustInferredLabels) { profiles.pop_back(); profiles.push_back(new AutofillProfile); - autofill_test::SetProfileInfo( + test::SetProfileInfo( profiles[2], "John", "", @@ -231,7 +232,7 @@ TEST(AutofillProfileTest, AdjustInferredLabels) { profiles[2]->Label()); profiles.push_back(new AutofillProfile); - autofill_test::SetProfileInfo( + test::SetProfileInfo( profiles[3], "John", "", @@ -259,7 +260,7 @@ TEST(AutofillProfileTest, AdjustInferredLabels) { profiles[3]->Label()); profiles.push_back(new AutofillProfile); - autofill_test::SetProfileInfo( + test::SetProfileInfo( profiles[4], "John", "", @@ -299,31 +300,31 @@ TEST(AutofillProfileTest, AdjustInferredLabels) { TEST(AutofillProfileTest, CreateInferredLabels) { std::vector<AutofillProfile*> profiles; profiles.push_back(new AutofillProfile); - autofill_test::SetProfileInfo(profiles[0], - "John", - "", - "Doe", - "johndoe@hades.com", - "Underworld", - "666 Erebus St.", - "", - "Elysium", "CA", - "91111", - "US", - "16502111111"); + test::SetProfileInfo(profiles[0], + "John", + "", + "Doe", + "johndoe@hades.com", + "Underworld", + "666 Erebus St.", + "", + "Elysium", "CA", + "91111", + "US", + "16502111111"); profiles.push_back(new AutofillProfile); - autofill_test::SetProfileInfo(profiles[1], - "Jane", - "", - "Doe", - "janedoe@tertium.com", - "Pluto Inc.", - "123 Letha Shore.", - "", - "Dis", "CA", - "91222", - "US", - "12345678910"); + test::SetProfileInfo(profiles[1], + "Jane", + "", + "Doe", + "janedoe@tertium.com", + "Pluto Inc.", + "123 Letha Shore.", + "", + "Dis", "CA", + "91222", + "US", + "12345678910"); std::vector<base::string16> labels; // Two fields at least - no filter. AutofillProfile::CreateInferredLabels(&profiles, NULL, UNKNOWN_TYPE, 2, @@ -408,13 +409,13 @@ TEST(AutofillProfileTest, CreateInferredLabels) { TEST(AutofillProfileTest, CreateInferredLabelsFallsBackToFullName) { ScopedVector<AutofillProfile> profiles; profiles.push_back(new AutofillProfile); - autofill_test::SetProfileInfo(profiles[0], - "John", "", "Doe", "doe@example.com", "", - "88 Nowhere Ave.", "", "", "", "", "", ""); + test::SetProfileInfo(profiles[0], + "John", "", "Doe", "doe@example.com", "", + "88 Nowhere Ave.", "", "", "", "", "", ""); profiles.push_back(new AutofillProfile); - autofill_test::SetProfileInfo(profiles[1], - "Johnny", "K", "Doe", "doe@example.com", "", - "88 Nowhere Ave.", "", "", "", "", "", ""); + test::SetProfileInfo(profiles[1], + "Johnny", "K", "Doe", "doe@example.com", "", + "88 Nowhere Ave.", "", "", "", "", "", ""); // If the only name field in the suggested fields is the excluded field, we // should not fall back to the full name as a distinguishing field. @@ -442,13 +443,13 @@ TEST(AutofillProfileTest, CreateInferredLabelsFallsBackToFullName) { TEST(AutofillProfileTest, CreateInferredLabelsNoDuplicatedFields) { ScopedVector<AutofillProfile> profiles; profiles.push_back(new AutofillProfile); - autofill_test::SetProfileInfo(profiles[0], - "John", "", "Doe", "doe@example.com", "", - "88 Nowhere Ave.", "", "", "", "", "", ""); + test::SetProfileInfo(profiles[0], + "John", "", "Doe", "doe@example.com", "", + "88 Nowhere Ave.", "", "", "", "", "", ""); profiles.push_back(new AutofillProfile); - autofill_test::SetProfileInfo(profiles[1], - "John", "", "Doe", "dojo@example.com", "", - "88 Nowhere Ave.", "", "", "", "", "", ""); + test::SetProfileInfo(profiles[1], + "John", "", "Doe", "dojo@example.com", "", + "88 Nowhere Ave.", "", "", "", "", "", ""); // If the only name field in the suggested fields is the excluded field, we // should not fall back to the full name as a distinguishing field. @@ -468,17 +469,17 @@ TEST(AutofillProfileTest, CreateInferredLabelsNoDuplicatedFields) { TEST(AutofillProfileTest, CreateInferredLabelsSkipsEmptyFields) { ScopedVector<AutofillProfile> profiles; profiles.push_back(new AutofillProfile); - autofill_test::SetProfileInfo(profiles[0], - "John", "", "Doe", "doe@example.com", - "Gogole", "", "", "", "", "", "", ""); + test::SetProfileInfo(profiles[0], + "John", "", "Doe", "doe@example.com", + "Gogole", "", "", "", "", "", "", ""); profiles.push_back(new AutofillProfile); - autofill_test::SetProfileInfo(profiles[1], - "John", "", "Doe", "doe@example.com", - "Ggoole", "", "", "", "", "", "", ""); + test::SetProfileInfo(profiles[1], + "John", "", "Doe", "doe@example.com", + "Ggoole", "", "", "", "", "", "", ""); profiles.push_back(new AutofillProfile); - autofill_test::SetProfileInfo(profiles[2], - "John", "", "Doe", "john.doe@example.com", - "Goolge", "", "", "", "", "", "", ""); + test::SetProfileInfo(profiles[2], + "John", "", "Doe", "john.doe@example.com", + "Goolge", "", "", "", "", "", "", ""); std::vector<base::string16> labels; AutofillProfile::CreateInferredLabels(&profiles.get(), NULL, UNKNOWN_TYPE, 3, @@ -506,10 +507,10 @@ TEST(AutofillProfileTest, IsSubsetOf) { // |a| is a subset of |b|. a.reset(new AutofillProfile); b.reset(new AutofillProfile); - autofill_test::SetProfileInfo(a.get(), "Thomas", NULL, "Jefferson", + test::SetProfileInfo(a.get(), "Thomas", NULL, "Jefferson", "declaration_guy@gmail.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); - autofill_test::SetProfileInfo(b.get(), "Thomas", NULL, "Jefferson", + test::SetProfileInfo(b.get(), "Thomas", NULL, "Jefferson", "declaration_guy@gmail.com", "United States Government", "Monticello", NULL, "Charlottesville", "Virginia", "22902", NULL, NULL); EXPECT_TRUE(a->IsSubsetOf(*b, "en-US")); @@ -523,10 +524,10 @@ TEST(AutofillProfileTest, IsSubsetOf) { // One field in |b| is different. a.reset(new AutofillProfile); b.reset(new AutofillProfile); - autofill_test::SetProfileInfo(a.get(), "Thomas", NULL, "Jefferson", + test::SetProfileInfo(a.get(), "Thomas", NULL, "Jefferson", "declaration_guy@gmail.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); - autofill_test::SetProfileInfo(a.get(), "Thomas", NULL, "Adams", + test::SetProfileInfo(a.get(), "Thomas", NULL, "Adams", "declaration_guy@gmail.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); EXPECT_FALSE(a->IsSubsetOf(*b, "en-US")); @@ -536,10 +537,10 @@ TEST(AutofillProfileTest, AssignmentOperator) { AutofillProfile a, b; // Result of assignment should be logically equal to the original profile. - autofill_test::SetProfileInfo(&a, "Marion", "Mitchell", "Morrison", - "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5", - "Hollywood", "CA", "91601", "US", - "12345678910"); + test::SetProfileInfo(&a, "Marion", "Mitchell", "Morrison", + "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5", + "Hollywood", "CA", "91601", "US", + "12345678910"); b = a; EXPECT_TRUE(a == b); @@ -552,10 +553,10 @@ TEST(AutofillProfileTest, Copy) { AutofillProfile a; // Clone should be logically equal to the original. - autofill_test::SetProfileInfo(&a, "Marion", "Mitchell", "Morrison", - "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5", - "Hollywood", "CA", "91601", "US", - "12345678910"); + test::SetProfileInfo(&a, "Marion", "Mitchell", "Morrison", + "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5", + "Hollywood", "CA", "91601", "US", + "12345678910"); AutofillProfile b(a); EXPECT_TRUE(a == b); } @@ -572,18 +573,18 @@ TEST(AutofillProfileTest, Compare) { EXPECT_EQ(0, a.Compare(b)); // Different values produce non-zero results. - autofill_test::SetProfileInfo(&a, "Jimmy", NULL, NULL, NULL, + test::SetProfileInfo(&a, "Jimmy", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); - autofill_test::SetProfileInfo(&b, "Ringo", NULL, NULL, NULL, + test::SetProfileInfo(&b, "Ringo", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); EXPECT_GT(0, a.Compare(b)); EXPECT_LT(0, b.Compare(a)); // Phone numbers are compared by the full number, including the area code. // This is a regression test for http://crbug.com/163024 - autofill_test::SetProfileInfo(&a, NULL, NULL, NULL, NULL, + test::SetProfileInfo(&a, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "650.555.4321"); - autofill_test::SetProfileInfo(&b, NULL, NULL, NULL, NULL, + test::SetProfileInfo(&b, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "408.555.4321"); EXPECT_GT(0, a.Compare(b)); EXPECT_LT(0, b.Compare(a)); @@ -838,3 +839,5 @@ TEST(AutofillProfileTest, FillByContents) { profile.FillSelectControl(ADDRESS_HOME_STATE, "en-US", &field); EXPECT_EQ(ASCIIToUTF16("2"), field.value); } + +} // namespace autofill diff --git a/components/autofill/browser/autofill_regexes_unittest.cc b/components/autofill/browser/autofill_regexes_unittest.cc index 1c2cbab..fe6a6b3 100644 --- a/components/autofill/browser/autofill_regexes_unittest.cc +++ b/components/autofill/browser/autofill_regexes_unittest.cc @@ -9,6 +9,8 @@ #include "components/autofill/browser/autofill_regex_constants.h" #include "testing/gtest/include/gtest/gtest.h" +namespace autofill { + TEST(AutofillRegexesTest, AutofillRegexes) { struct TestCase { const char* const input; @@ -58,3 +60,5 @@ TEST(AutofillRegexesTest, AutofillRegexes) { ASCIIToUTF16(test_case.pattern))); } } + +} // namespace autofill diff --git a/components/autofill/browser/autofill_scanner.cc b/components/autofill/browser/autofill_scanner.cc index fafdbab..cad418c 100644 --- a/components/autofill/browser/autofill_scanner.cc +++ b/components/autofill/browser/autofill_scanner.cc @@ -7,6 +7,8 @@ #include "base/logging.h" #include "components/autofill/browser/autofill_field.h" +namespace autofill { + AutofillScanner::AutofillScanner( const std::vector<const AutofillField*>& fields) : cursor_(fields.begin()), @@ -52,3 +54,5 @@ size_t AutofillScanner::SaveCursor() { saved_cursor_ = cursor_; return static_cast<size_t>(cursor_ - begin_); } + +} // namespace autofill diff --git a/components/autofill/browser/autofill_scanner.h b/components/autofill/browser/autofill_scanner.h index c099910..eac38b1 100644 --- a/components/autofill/browser/autofill_scanner.h +++ b/components/autofill/browser/autofill_scanner.h @@ -10,6 +10,8 @@ #include "base/basictypes.h" #include "base/string16.h" +namespace autofill { + class AutofillField; // A helper class for parsing a stream of |AutofillField|'s with lookahead. @@ -54,4 +56,6 @@ class AutofillScanner { DISALLOW_COPY_AND_ASSIGN(AutofillScanner); }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_SCANNER_H_ diff --git a/components/autofill/browser/autofill_server_field_info.h b/components/autofill/browser/autofill_server_field_info.h index 34f7ea6..bd36d8c 100644 --- a/components/autofill/browser/autofill_server_field_info.h +++ b/components/autofill/browser/autofill_server_field_info.h @@ -9,6 +9,8 @@ #include "components/autofill/browser/field_types.h" +namespace autofill { + struct AutofillServerFieldInfo { // The predicted type returned by the Autofill server for this field. AutofillFieldType field_type; @@ -17,4 +19,6 @@ struct AutofillServerFieldInfo { std::string default_value; }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_SERVER_FIELD_INFO_H_ diff --git a/components/autofill/browser/autofill_type.cc b/components/autofill/browser/autofill_type.cc index a715cbc..c0d2f64 100644 --- a/components/autofill/browser/autofill_type.cc +++ b/components/autofill/browser/autofill_type.cc @@ -8,6 +8,8 @@ #include "base/logging.h" +namespace autofill { + AutofillType::AutofillType(AutofillFieldType field_type) { if ((field_type < NO_SERVER_DATA || field_type >= MAX_VALID_FIELD_TYPE) || (field_type >= 15 && field_type <= 19) || @@ -292,3 +294,5 @@ AutofillFieldType AutofillType::StringToFieldType(const std::string& str) { NOTREACHED() << "Unknown AutofillFieldType " << str; return UNKNOWN_TYPE; } + +} // namespace autofill diff --git a/components/autofill/browser/autofill_type.h b/components/autofill/browser/autofill_type.h index 0598c4e..2ae0c6c 100644 --- a/components/autofill/browser/autofill_type.h +++ b/components/autofill/browser/autofill_type.h @@ -12,6 +12,8 @@ #include "base/string16.h" #include "components/autofill/browser/field_types.h" +namespace autofill { + // The high-level description of Autofill types, used to categorize form fields // and for associating form fields with form values in the Web Database. class AutofillType { @@ -51,4 +53,6 @@ typedef AutofillType::FieldTypeGroup FieldTypeGroup; typedef std::set<AutofillFieldType> FieldTypeSet; typedef std::map<base::string16, AutofillFieldType> FieldTypeMap; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_TYPE_H_ diff --git a/components/autofill/browser/autofill_type_unittest.cc b/components/autofill/browser/autofill_type_unittest.cc index 12654aa..32a18de 100644 --- a/components/autofill/browser/autofill_type_unittest.cc +++ b/components/autofill/browser/autofill_type_unittest.cc @@ -5,6 +5,7 @@ #include "components/autofill/browser/autofill_type.h" #include "testing/gtest/include/gtest/gtest.h" +namespace autofill { namespace { TEST(AutofillTypeTest, AutofillTypes) { @@ -50,3 +51,4 @@ TEST(AutofillTypeTest, AutofillTypes) { } } // namespace +} // namespace autofill diff --git a/components/autofill/browser/autofill_xml_parser.cc b/components/autofill/browser/autofill_xml_parser.cc index a4e5a3d..5ac92fd 100644 --- a/components/autofill/browser/autofill_xml_parser.cc +++ b/components/autofill/browser/autofill_xml_parser.cc @@ -11,6 +11,8 @@ #include "components/autofill/browser/autofill_server_field_info.h" #include "third_party/libjingle/source/talk/xmllite/qname.h" +namespace autofill { + AutofillXmlParser::AutofillXmlParser() : succeeded_(true) { } @@ -195,3 +197,5 @@ double AutofillUploadXmlParser::GetDoubleValue(buzz::XmlParseContext* context, } return value; } + +} // namespace autofill diff --git a/components/autofill/browser/autofill_xml_parser.h b/components/autofill/browser/autofill_xml_parser.h index fc914f3..69e019c 100644 --- a/components/autofill/browser/autofill_xml_parser.h +++ b/components/autofill/browser/autofill_xml_parser.h @@ -17,6 +17,8 @@ #include "components/autofill/common/web_element_descriptor.h" #include "third_party/libjingle/source/talk/xmllite/xmlparser.h" +namespace autofill { + // The base class that contains common functionality between // AutofillQueryXmlParser and AutofillUploadXmlParser. class AutofillXmlParser : public buzz::XmlParseHandler { @@ -164,4 +166,6 @@ class AutofillUploadXmlParser : public AutofillXmlParser { DISALLOW_COPY_AND_ASSIGN(AutofillUploadXmlParser); }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_XML_PARSER_H_ diff --git a/components/autofill/browser/autofill_xml_parser_unittest.cc b/components/autofill/browser/autofill_xml_parser_unittest.cc index 3649e54..4086475 100644 --- a/components/autofill/browser/autofill_xml_parser_unittest.cc +++ b/components/autofill/browser/autofill_xml_parser_unittest.cc @@ -12,6 +12,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/libjingle/source/talk/xmllite/xmlparser.h" +namespace autofill { namespace { TEST(AutofillQueryXmlParserTest, BasicQuery) { @@ -365,3 +366,4 @@ TEST(AutofillUploadXmlParser, TestFailedResponse) { } } // namespace +} // namespace autofill diff --git a/components/autofill/browser/contact_info.cc b/components/autofill/browser/contact_info.cc index 019d076..a3cdc07 100644 --- a/components/autofill/browser/contact_info.cc +++ b/components/autofill/browser/contact_info.cc @@ -15,6 +15,8 @@ #include "components/autofill/browser/autofill_type.h" #include "components/autofill/browser/field_types.h" +namespace autofill { + static const AutofillFieldType kAutofillNameInfoTypes[] = { NAME_FIRST, NAME_MIDDLE, @@ -196,3 +198,5 @@ void CompanyInfo::SetRawInfo(AutofillFieldType type, DCHECK_EQ(COMPANY_NAME, type); company_name_ = value; } + +} // namespace autofill diff --git a/components/autofill/browser/contact_info.h b/components/autofill/browser/contact_info.h index 5686f34..cfb381f 100644 --- a/components/autofill/browser/contact_info.h +++ b/components/autofill/browser/contact_info.h @@ -12,6 +12,8 @@ #include "components/autofill/browser/field_types.h" #include "components/autofill/browser/form_group.h" +namespace autofill { + // A form group that stores name information. class NameInfo : public FormGroup { public: @@ -91,4 +93,6 @@ class CompanyInfo : public FormGroup { base::string16 company_name_; }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_CONTACT_INFO_H_ diff --git a/components/autofill/browser/contact_info_unittest.cc b/components/autofill/browser/contact_info_unittest.cc index 27d990d..bd85626 100644 --- a/components/autofill/browser/contact_info_unittest.cc +++ b/components/autofill/browser/contact_info_unittest.cc @@ -11,6 +11,8 @@ #include "components/autofill/browser/field_types.h" #include "testing/gtest/include/gtest/gtest.h" +namespace autofill { + TEST(NameInfoTest, SetFullName) { NameInfo name; name.SetRawInfo(NAME_FULL, ASCIIToUTF16("Virgil")); @@ -99,3 +101,5 @@ TEST(NameInfoTest, GetFullName) { EXPECT_EQ(name.GetRawInfo(NAME_LAST), ASCIIToUTF16("Last")); EXPECT_EQ(name.GetRawInfo(NAME_FULL), ASCIIToUTF16("First Middle Last")); } + +} // namespace autofill diff --git a/components/autofill/browser/credit_card.cc b/components/autofill/browser/credit_card.cc index 576d282..78765d9 100644 --- a/components/autofill/browser/credit_card.cc +++ b/components/autofill/browser/credit_card.cc @@ -29,6 +29,8 @@ #include "third_party/icu/public/i18n/unicode/dtfmtsym.h" #include "ui/base/l10n/l10n_util.h" +namespace autofill { + namespace { const char16 kCreditCardObfuscationSymbol = '*'; @@ -680,3 +682,5 @@ const char* const kJCBCard = "jcbCC"; const char* const kMasterCard = "masterCardCC"; const char* const kSoloCard = "soloCC"; const char* const kVisaCard = "visaCC"; + +} // namespace autofill diff --git a/components/autofill/browser/credit_card.h b/components/autofill/browser/credit_card.h index 8c17af7..d3c770d 100644 --- a/components/autofill/browser/credit_card.h +++ b/components/autofill/browser/credit_card.h @@ -13,6 +13,8 @@ #include "components/autofill/browser/field_types.h" #include "components/autofill/browser/form_group.h" +namespace autofill { + struct FormFieldData; // A form group that stores credit card information. @@ -157,4 +159,6 @@ extern const char* const kMasterCard; extern const char* const kSoloCard; extern const char* const kVisaCard; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_CREDIT_CARD_H_ diff --git a/components/autofill/browser/credit_card_field.cc b/components/autofill/browser/credit_card_field.cc index 9d68d98..3b7e923 100644 --- a/components/autofill/browser/credit_card_field.cc +++ b/components/autofill/browser/credit_card_field.cc @@ -17,6 +17,8 @@ #include "components/autofill/browser/field_types.h" #include "ui/base/l10n/l10n_util.h" +namespace autofill { + // static FormField* CreditCardField::Parse(AutofillScanner* scanner) { if (scanner->IsEnd()) @@ -227,3 +229,5 @@ bool CreditCardField::ClassifyField(FieldTypeMap* map) const { return ok; } + +} // namespace autofill diff --git a/components/autofill/browser/credit_card_field.h b/components/autofill/browser/credit_card_field.h index 777aa16..ecf9eb2 100644 --- a/components/autofill/browser/credit_card_field.h +++ b/components/autofill/browser/credit_card_field.h @@ -13,6 +13,8 @@ #include "components/autofill/browser/autofill_type.h" #include "components/autofill/browser/form_field.h" +namespace autofill { + class AutofillField; class AutofillScanner; @@ -68,4 +70,6 @@ class CreditCardField : public FormField { DISALLOW_COPY_AND_ASSIGN(CreditCardField); }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_CREDIT_CARD_FIELD_H_ diff --git a/components/autofill/browser/credit_card_field_unittest.cc b/components/autofill/browser/credit_card_field_unittest.cc index b077b70..92a1cd3 100644 --- a/components/autofill/browser/credit_card_field_unittest.cc +++ b/components/autofill/browser/credit_card_field_unittest.cc @@ -11,6 +11,8 @@ #include "components/autofill/common/form_field_data.h" #include "testing/gtest/include/gtest/gtest.h" +namespace autofill { + class CreditCardFieldTest : public testing::Test { public: CreditCardFieldTest() {} @@ -316,3 +318,5 @@ TEST_F(CreditCardFieldTest, ParseCreditCardHolderNameWithCCFullName) { field_type_map_.find(ASCIIToUTF16("name1")) != field_type_map_.end()); EXPECT_EQ(CREDIT_CARD_NAME, field_type_map_[ASCIIToUTF16("name1")]); } + +} // namespace autofill diff --git a/components/autofill/browser/credit_card_unittest.cc b/components/autofill/browser/credit_card_unittest.cc index 636b013..5278a18 100644 --- a/components/autofill/browser/credit_card_unittest.cc +++ b/components/autofill/browser/credit_card_unittest.cc @@ -9,6 +9,7 @@ #include "components/autofill/common/form_field_data.h" #include "testing/gtest/include/gtest/gtest.h" +namespace autofill { namespace { // From https://www.paypalobjects.com/en_US/vhelp/paypalmanager_help/credit_card_numbers.htm @@ -53,8 +54,7 @@ TEST(CreditCardTest, PreviewSummaryAndObfuscatedNumberStrings) { // Case 00: Empty credit card with empty strings. CreditCard credit_card00; - autofill_test::SetCreditCardInfo(&credit_card00, - "John Dillinger", "", "", ""); + test::SetCreditCardInfo(&credit_card00,"John Dillinger", "", "", ""); base::string16 summary00 = credit_card00.Label(); EXPECT_EQ(base::string16(ASCIIToUTF16("John Dillinger")), summary00); base::string16 obfuscated00 = credit_card00.ObfuscatedNumber(); @@ -62,8 +62,7 @@ TEST(CreditCardTest, PreviewSummaryAndObfuscatedNumberStrings) { // Case 1: No credit card number. CreditCard credit_card1; - autofill_test::SetCreditCardInfo(&credit_card1, - "John Dillinger", "", "01", "2010"); + test::SetCreditCardInfo(&credit_card1,"John Dillinger", "", "01", "2010"); base::string16 summary1 = credit_card1.Label(); EXPECT_EQ(base::string16(ASCIIToUTF16("John Dillinger")), summary1); base::string16 obfuscated1 = credit_card1.ObfuscatedNumber(); @@ -71,8 +70,8 @@ TEST(CreditCardTest, PreviewSummaryAndObfuscatedNumberStrings) { // Case 2: No month. CreditCard credit_card2; - autofill_test::SetCreditCardInfo(&credit_card2, - "John Dillinger", "5105 1051 0510 5100", "", "2010"); + test::SetCreditCardInfo( + &credit_card2, "John Dillinger", "5105 1051 0510 5100", "", "2010"); base::string16 summary2 = credit_card2.Label(); EXPECT_EQ(ASCIIToUTF16("************5100"), summary2); base::string16 obfuscated2 = credit_card2.ObfuscatedNumber(); @@ -80,8 +79,8 @@ TEST(CreditCardTest, PreviewSummaryAndObfuscatedNumberStrings) { // Case 3: No year. CreditCard credit_card3; - autofill_test::SetCreditCardInfo(&credit_card3, - "John Dillinger", "5105 1051 0510 5100", "01", ""); + test::SetCreditCardInfo( + &credit_card3, "John Dillinger", "5105 1051 0510 5100", "01", ""); base::string16 summary3 = credit_card3.Label(); EXPECT_EQ(ASCIIToUTF16("************5100"), summary3); base::string16 obfuscated3 = credit_card3.ObfuscatedNumber(); @@ -89,8 +88,8 @@ TEST(CreditCardTest, PreviewSummaryAndObfuscatedNumberStrings) { // Case 4: Have everything. CreditCard credit_card4; - autofill_test::SetCreditCardInfo(&credit_card4, - "John Dillinger", "5105 1051 0510 5100", "01", "2010"); + test::SetCreditCardInfo( + &credit_card4, "John Dillinger", "5105 1051 0510 5100", "01", "2010"); base::string16 summary4 = credit_card4.Label(); EXPECT_EQ(ASCIIToUTF16("************5100, Exp: 01/2010"), summary4); base::string16 obfuscated4 = credit_card4.ObfuscatedNumber(); @@ -98,7 +97,8 @@ TEST(CreditCardTest, PreviewSummaryAndObfuscatedNumberStrings) { // Case 5: Very long credit card CreditCard credit_card5; - autofill_test::SetCreditCardInfo(&credit_card5, + test::SetCreditCardInfo( + &credit_card5, "John Dillinger", "0123456789 0123456789 0123456789 5105 1051 0510 5100", "01", "2010"); base::string16 summary5 = credit_card5.Label(); @@ -111,8 +111,7 @@ TEST(CreditCardTest, AssignmentOperator) { CreditCard a, b; // Result of assignment should be logically equal to the original profile. - autofill_test::SetCreditCardInfo(&a, "John Dillinger", - "123456789012", "01", "2010"); + test::SetCreditCardInfo(&a, "John Dillinger", "123456789012", "01", "2010"); b = a; EXPECT_TRUE(a == b); @@ -145,8 +144,8 @@ TEST(CreditCardTest, IsComplete) { TEST(CreditCardTest, InvalidMastercardNumber) { CreditCard card; - autofill_test::SetCreditCardInfo(&card, "Baby Face Nelson", - "5200000000000004", "01", "2010"); + test::SetCreditCardInfo(&card, "Baby Face Nelson", + "5200000000000004", "01", "2010"); EXPECT_EQ("genericCC", card.type()); } @@ -154,8 +153,8 @@ TEST(CreditCardTest, InvalidMastercardNumber) { TEST(CreditCardTest, SetRawInfoCreditCardNumber) { CreditCard card; - autofill_test::SetCreditCardInfo(&card, "Bob Dylan", - "4321-5432-6543-xxxx", "07", "2013"); + test::SetCreditCardInfo(&card, "Bob Dylan", + "4321-5432-6543-xxxx", "07", "2013"); EXPECT_EQ(ASCIIToUTF16("4321-5432-6543-xxxx"), card.GetRawInfo(CREDIT_CARD_NUMBER)); } @@ -363,3 +362,5 @@ TEST(CreditCardTest, CreditCardTypeSelectControl) { EXPECT_EQ(ASCIIToUTF16("discover"), field.value); } } + +} // namespace autofill diff --git a/components/autofill/browser/crypto/rc4_decryptor.h b/components/autofill/browser/crypto/rc4_decryptor.h index fb680b5..1918312 100644 --- a/components/autofill/browser/crypto/rc4_decryptor.h +++ b/components/autofill/browser/crypto/rc4_decryptor.h @@ -9,6 +9,8 @@ #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" +namespace autofill { + // This is modified RC4 decryption used for import of Toolbar autofill data // only. The difference from the Crypto Api implementation is twofold: // First, it uses a non-standard key size (160 bit), not supported by Microsoft @@ -103,4 +105,6 @@ class RC4Decryptor { Rc4Key key_; }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_CRYPTO_RC4_DECRYPTOR_H_ diff --git a/components/autofill/browser/data_driven_test.cc b/components/autofill/browser/data_driven_test.cc index 0936445..7717cf7 100644 --- a/components/autofill/browser/data_driven_test.cc +++ b/components/autofill/browser/data_driven_test.cc @@ -10,6 +10,7 @@ #include "chrome/common/chrome_paths.h" #include "testing/gtest/include/gtest/gtest.h" +namespace autofill { namespace { // Reads |file| into |content|, and converts Windows line-endings to Unix ones. @@ -88,3 +89,5 @@ DataDrivenTest::DataDrivenTest() { DataDrivenTest::~DataDrivenTest() { } + +} // namespace autofill diff --git a/components/autofill/browser/data_driven_test.h b/components/autofill/browser/data_driven_test.h index 36cf872..27fa2f9 100644 --- a/components/autofill/browser/data_driven_test.h +++ b/components/autofill/browser/data_driven_test.h @@ -10,6 +10,8 @@ #include "base/files/file_path.h" #include "base/string16.h" +namespace autofill { + // A convenience class for implementing data-driven tests. Subclassers need only // implement the conversion of serialized input data to serialized output data // and provide a set of input files. For each input file, on the first run, a @@ -47,4 +49,6 @@ class DataDrivenTest { DISALLOW_COPY_AND_ASSIGN(DataDrivenTest); }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_DATA_DRIVEN_TEST_H_ diff --git a/components/autofill/browser/email_field.cc b/components/autofill/browser/email_field.cc index bf01266..a24ac178 100644 --- a/components/autofill/browser/email_field.cc +++ b/components/autofill/browser/email_field.cc @@ -9,6 +9,8 @@ #include "components/autofill/browser/autofill_scanner.h" #include "ui/base/l10n/l10n_util.h" +namespace autofill { + // static FormField* EmailField::Parse(AutofillScanner* scanner) { const AutofillField* field; @@ -26,3 +28,5 @@ EmailField::EmailField(const AutofillField* field) : field_(field) { bool EmailField::ClassifyField(FieldTypeMap* map) const { return AddClassification(field_, EMAIL_ADDRESS, map); } + +} // namespace autofill diff --git a/components/autofill/browser/email_field.h b/components/autofill/browser/email_field.h index d04a1a1..7e01cfb 100644 --- a/components/autofill/browser/email_field.h +++ b/components/autofill/browser/email_field.h @@ -9,6 +9,8 @@ #include "base/compiler_specific.h" #include "components/autofill/browser/form_field.h" +namespace autofill { + class EmailField : public FormField { public: static FormField* Parse(AutofillScanner* scanner); @@ -25,4 +27,6 @@ class EmailField : public FormField { DISALLOW_COPY_AND_ASSIGN(EmailField); }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_EMAIL_FIELD_H_ diff --git a/components/autofill/browser/field_types.h b/components/autofill/browser/field_types.h index 87dcfe8..c84dad0 100644 --- a/components/autofill/browser/field_types.h +++ b/components/autofill/browser/field_types.h @@ -8,6 +8,8 @@ #include <set> #include <string> +namespace autofill { + // NOTE: This list MUST not be modified. The server aggregates and stores these // types over several versions, so we must remain fully compatible with the // Autofill server, which is itself backward-compatible. The list must be kept @@ -88,4 +90,6 @@ enum AutofillFieldType { typedef std::set<AutofillFieldType> FieldTypeSet; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_FIELD_TYPES_H_ diff --git a/components/autofill/browser/form_field.cc b/components/autofill/browser/form_field.cc index 348b060..2887aa2 100644 --- a/components/autofill/browser/form_field.cc +++ b/components/autofill/browser/form_field.cc @@ -25,6 +25,7 @@ #include "components/autofill/browser/phone_field.h" #include "ui/base/l10n/l10n_util.h" +namespace autofill { namespace { bool IsTextField(const std::string& type) { @@ -195,3 +196,5 @@ void FormField::ParseFormFieldsPass(ParseFunction parse, std::swap(*fields, remaining_fields); } + +} // namespace autofill diff --git a/components/autofill/browser/form_field.h b/components/autofill/browser/form_field.h index 1c24904..fc295e3 100644 --- a/components/autofill/browser/form_field.h +++ b/components/autofill/browser/form_field.h @@ -12,6 +12,8 @@ #include "base/string16.h" #include "components/autofill/browser/autofill_type.h" +namespace autofill { + class AutofillField; class AutofillScanner; @@ -117,4 +119,6 @@ class FormField { DISALLOW_COPY_AND_ASSIGN(FormField); }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_FORM_FIELD_H_ diff --git a/components/autofill/browser/form_field_unittest.cc b/components/autofill/browser/form_field_unittest.cc index f6b979e..08018e4 100644 --- a/components/autofill/browser/form_field_unittest.cc +++ b/components/autofill/browser/form_field_unittest.cc @@ -9,6 +9,8 @@ #include "components/autofill/browser/form_field.h" #include "testing/gtest/include/gtest/gtest.h" +namespace autofill { + TEST(FormFieldTest, Match) { AutofillField field; @@ -146,3 +148,5 @@ TEST(FormFieldTest, ParseFormFields) { EXPECT_EQ(ADDRESS_HOME_LINE2, field_type_map.find(ASCIIToUTF16("Address line2"))->second); } + +} // namespace autofill diff --git a/components/autofill/browser/form_group.cc b/components/autofill/browser/form_group.cc index 4ed49c7..82031f0 100644 --- a/components/autofill/browser/form_group.cc +++ b/components/autofill/browser/form_group.cc @@ -16,6 +16,7 @@ #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" +namespace autofill { namespace { // TODO(jhawkins): Add more states/provinces. See http://crbug.com/45039. @@ -322,3 +323,5 @@ bool FormGroup::FillCountrySelectControl(const std::string& app_locale, bool FormGroup::IsValidState(const base::string16& value) { return !State::Abbreviation(value).empty() || !State::FullName(value).empty(); } + +} // namespace autofill diff --git a/components/autofill/browser/form_group.h b/components/autofill/browser/form_group.h index 4adda2f..931b51f 100644 --- a/components/autofill/browser/form_group.h +++ b/components/autofill/browser/form_group.h @@ -12,6 +12,8 @@ #include "base/string_util.h" #include "components/autofill/browser/field_types.h" +namespace autofill { + class AutofillField; struct FormFieldData; @@ -93,4 +95,6 @@ class FormGroup { FormFieldData* field_data) const; }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_FORM_GROUP_H_ diff --git a/components/autofill/browser/form_structure.cc b/components/autofill/browser/form_structure.cc index 46f36d3..ba4f3a8 100644 --- a/components/autofill/browser/form_structure.cc +++ b/components/autofill/browser/form_structure.cc @@ -29,8 +29,7 @@ #include "components/autofill/common/form_field_data_predictions.h" #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" -using components::autofill::kRequiredAutofillFields; - +namespace autofill { namespace { const char kFormMethodPost[] = "post"; @@ -1219,3 +1218,5 @@ void FormStructure::IdentifySections(bool has_author_specified_sections) { (*field)->set_section((*field)->section() + "-default"); } } + +} // namespace autofill diff --git a/components/autofill/browser/form_structure.h b/components/autofill/browser/form_structure.h index 2f50bfc..3c4541f 100644 --- a/components/autofill/browser/form_structure.h +++ b/components/autofill/browser/form_structure.h @@ -17,9 +17,6 @@ #include "components/autofill/common/web_element_descriptor.h" #include "googleurl/src/gurl.h" -struct FormData; -struct FormDataPredictions; - enum RequestMethod { GET, POST @@ -31,12 +28,6 @@ enum UploadRequired { USE_UPLOAD_RATES }; -class AutofillMetrics; - -namespace autofill { -struct AutocheckoutPageMetaData; -} - namespace base { class TimeTicks; } @@ -45,6 +36,14 @@ namespace buzz { class XmlElement; } +namespace autofill { + +class AutofillMetrics; + +struct AutocheckoutPageMetaData; +struct FormData; +struct FormDataPredictions; + // FormStructure stores a single HTML form together with the values entered // in the fields along with additional information needed by Autofill. class FormStructure { @@ -255,4 +254,6 @@ class FormStructure { DISALLOW_COPY_AND_ASSIGN(FormStructure); }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_FORM_STRUCTURE_H_ diff --git a/components/autofill/browser/form_structure_unittest.cc b/components/autofill/browser/form_structure_unittest.cc index ad79a14..8691e82 100644 --- a/components/autofill/browser/form_structure_unittest.cc +++ b/components/autofill/browser/form_structure_unittest.cc @@ -16,6 +16,7 @@ using WebKit::WebInputElement; +namespace autofill { namespace { // Unlike the base AutofillMetrics, exposes copy and assignment constructors, @@ -2220,3 +2221,5 @@ TEST(FormStructureTest, ToFormData) { form.user_submitted = true; EXPECT_NE(form, FormStructure(form, std::string()).ToFormData()); } + +} // namespace autofill diff --git a/components/autofill/browser/name_field.cc b/components/autofill/browser/name_field.cc index 8d29111..a0e8d1a 100644 --- a/components/autofill/browser/name_field.cc +++ b/components/autofill/browser/name_field.cc @@ -13,6 +13,7 @@ #include "components/autofill/browser/autofill_type.h" #include "ui/base/l10n/l10n_util.h" +namespace autofill { namespace { // A form field that can parse a full name field. @@ -212,3 +213,5 @@ bool FirstLastNameField::ClassifyField(FieldTypeMap* map) const { ok = ok && AddClassification(middle_name_, type, map); return ok; } + +} // namespace autofill diff --git a/components/autofill/browser/name_field.h b/components/autofill/browser/name_field.h index e62b62f..a434bc1 100644 --- a/components/autofill/browser/name_field.h +++ b/components/autofill/browser/name_field.h @@ -12,6 +12,8 @@ #include "components/autofill/browser/autofill_field.h" #include "components/autofill/browser/form_field.h" +namespace autofill { + class AutofillScanner; // A form field that can parse either a FullNameField or a FirstLastNameField. @@ -39,4 +41,6 @@ class NameField : public FormField { DISALLOW_COPY_AND_ASSIGN(NameField); }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_NAME_FIELD_H_ diff --git a/components/autofill/browser/name_field_unittest.cc b/components/autofill/browser/name_field_unittest.cc index d0bcf87..1dce028 100644 --- a/components/autofill/browser/name_field_unittest.cc +++ b/components/autofill/browser/name_field_unittest.cc @@ -11,6 +11,8 @@ #include "components/autofill/common/form_field_data.h" #include "testing/gtest/include/gtest/gtest.h" +namespace autofill { + class NameFieldTest : public testing::Test { public: NameFieldTest() {} @@ -305,3 +307,5 @@ TEST_F(NameFieldTest, MiddleInitialAtEnd) { field_type_map_.find(ASCIIToUTF16("name3")) != field_type_map_.end()); EXPECT_EQ(NAME_LAST, field_type_map_[ASCIIToUTF16("name3")]); } + +} // namespace autofill diff --git a/components/autofill/browser/password_autofill_manager.cc b/components/autofill/browser/password_autofill_manager.cc index a17168f..bdd0971 100644 --- a/components/autofill/browser/password_autofill_manager.cc +++ b/components/autofill/browser/password_autofill_manager.cc @@ -8,6 +8,8 @@ #include "content/public/browser/web_contents.h" #include "ui/base/keycodes/keyboard_codes.h" +namespace autofill { + //////////////////////////////////////////////////////////////////////////////// // PasswordAutofillManager, public: @@ -81,3 +83,5 @@ bool PasswordAutofillManager::FindLoginInfo( *found_password = iter->second; return true; } + +} // namespace autofill diff --git a/components/autofill/browser/password_autofill_manager.h b/components/autofill/browser/password_autofill_manager.h index e1d7b5a..9f5bd93 100644 --- a/components/autofill/browser/password_autofill_manager.h +++ b/components/autofill/browser/password_autofill_manager.h @@ -20,6 +20,8 @@ namespace content { class WebContents; } // namespace content +namespace autofill { + // This class is responsible for filling password forms. class PasswordAutofillManager { public: @@ -68,4 +70,6 @@ class PasswordAutofillManager { DISALLOW_COPY_AND_ASSIGN(PasswordAutofillManager); }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_PASSWORD_AUTOFILL_MANAGER_H_ diff --git a/components/autofill/browser/password_autofill_manager_unittest.cc b/components/autofill/browser/password_autofill_manager_unittest.cc index 919dc32..7aea70f 100644 --- a/components/autofill/browser/password_autofill_manager_unittest.cc +++ b/components/autofill/browser/password_autofill_manager_unittest.cc @@ -21,6 +21,8 @@ const char* const kValue = "password"; } // namespace +namespace autofill { + class PasswordAutofillManagerTest : public testing::Test { protected: PasswordAutofillManagerTest() : password_autofill_manager_(NULL) {} @@ -72,3 +74,5 @@ TEST_F(PasswordAutofillManagerTest, DidAcceptAutofillSuggestion) { EXPECT_FALSE(password_autofill_manager()->DidAcceptAutofillSuggestion( username_field(), ASCIIToUTF16(kAliceUsername))); } + +} // namespace autofill diff --git a/components/autofill/browser/personal_data_manager.cc b/components/autofill/browser/personal_data_manager.cc index df8571d..c80d85e 100644 --- a/components/autofill/browser/personal_data_manager.cc +++ b/components/autofill/browser/personal_data_manager.cc @@ -30,6 +30,7 @@ using content::BrowserContext; +namespace autofill { namespace { const base::string16::value_type kCreditCardPrefix[] = {'*', 0}; @@ -1008,3 +1009,5 @@ void PersonalDataManager::set_browser_context( content::BrowserContext* context) { browser_context_ = context; } + +} // namespace autofill diff --git a/components/autofill/browser/personal_data_manager.h b/components/autofill/browser/personal_data_manager.h index 9b1dc14..1c25d38 100644 --- a/components/autofill/browser/personal_data_manager.h +++ b/components/autofill/browser/personal_data_manager.h @@ -19,23 +19,26 @@ #include "components/autofill/browser/webdata/autofill_webdata_service_observer.h" #include "components/webdata/common/web_data_service_consumer.h" -class AutofillMetrics; -class FormStructure; -class PersonalDataManagerObserver; +class RemoveAutofillTester; + +namespace content { +class BrowserContext; +} namespace autofill { +class AutofillMetrics; class AutofillTest; +class FormStructure; +class PersonalDataManagerObserver; class PersonalDataManagerFactory; -} +} // namespace autofill namespace autofill_helper { -void SetProfiles(int, std::vector<AutofillProfile>*); -void SetCreditCards(int, std::vector<CreditCard>*); -} +void SetProfiles(int, std::vector<autofill::AutofillProfile>*); +void SetCreditCards(int, std::vector<autofill::CreditCard>*); +} // namespace autofill_helper -namespace content { -class BrowserContext; -} +namespace autofill { // Handles loading and saving Autofill profile information to the web database. // This class also stores the profiles loaded from the database for use during @@ -183,11 +186,13 @@ class PersonalDataManager : public WebDataServiceConsumer, friend class autofill::PersonalDataManagerFactory; friend class PersonalDataManagerTest; friend class ProfileSyncServiceAutofillTest; - friend class RemoveAutofillTester; + friend class ::RemoveAutofillTester; friend class TestingAutomationProvider; friend struct base::DefaultDeleter<PersonalDataManager>; - friend void autofill_helper::SetProfiles(int, std::vector<AutofillProfile>*); - friend void autofill_helper::SetCreditCards(int, std::vector<CreditCard>*); + friend void autofill_helper::SetProfiles( + int, std::vector<autofill::AutofillProfile>*); + friend void autofill_helper::SetCreditCards( + int, std::vector<autofill::CreditCard>*); // Sets |web_profiles_| to the contents of |profiles| and updates the web // database by adding, updating and removing profiles. @@ -281,4 +286,6 @@ class PersonalDataManager : public WebDataServiceConsumer, DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_PERSONAL_DATA_MANAGER_H_ diff --git a/components/autofill/browser/personal_data_manager_mac.mm b/components/autofill/browser/personal_data_manager_mac.mm index 4642206..c60db13 100644 --- a/components/autofill/browser/personal_data_manager_mac.mm +++ b/components/autofill/browser/personal_data_manager_mac.mm @@ -22,6 +22,7 @@ #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util_mac.h" +namespace autofill { namespace { // This implementation makes use of the Address Book API. Profiles are @@ -264,3 +265,5 @@ void PersonalDataManager::LoadAuxiliaryProfiles() { AuxiliaryProfilesImpl impl(&auxiliary_profiles_); impl.GetAddressBookMeCard(app_locale_); } + +} // namespace autofill diff --git a/components/autofill/browser/personal_data_manager_observer.h b/components/autofill/browser/personal_data_manager_observer.h index f2becb6..b8fea94 100644 --- a/components/autofill/browser/personal_data_manager_observer.h +++ b/components/autofill/browser/personal_data_manager_observer.h @@ -5,6 +5,8 @@ #ifndef COMPONENTS_AUTOFILL_BROWSER_PERSONAL_DATA_MANAGER_OBSERVER_H_ #define COMPONENTS_AUTOFILL_BROWSER_PERSONAL_DATA_MANAGER_OBSERVER_H_ +namespace autofill { + // An interface the PersonalDataManager uses to notify its clients (observers) // when it has finished loading personal data from the web database. Register // observers via PersonalDataManager::AddObserver. @@ -18,4 +20,6 @@ class PersonalDataManagerObserver { virtual ~PersonalDataManagerObserver() {} }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_PERSONAL_DATA_MANAGER_OBSERVER_H_ diff --git a/components/autofill/browser/personal_data_manager_unittest.cc b/components/autofill/browser/personal_data_manager_unittest.cc index 70c8111..99ad374 100644 --- a/components/autofill/browser/personal_data_manager_unittest.cc +++ b/components/autofill/browser/personal_data_manager_unittest.cc @@ -32,6 +32,7 @@ using content::BrowserThread; +namespace autofill { namespace { ACTION(QuitUIMessageLoop) { @@ -71,7 +72,7 @@ class PersonalDataManagerTest : public testing::Test { profile_.reset(new TestingProfile); profile_->CreateWebDataService(); - autofill_test::DisableSystemServices(profile_.get()); + test::DisableSystemServices(profile_.get()); ResetPersonalDataManager(); } @@ -114,7 +115,7 @@ class PersonalDataManagerTest : public testing::Test { TEST_F(PersonalDataManagerTest, AddProfile) { AutofillProfile profile0; - autofill_test::SetProfileInfo(&profile0, + test::SetProfileInfo(&profile0, "John", "Mitchell", "Smith", "j@s.com", "Acme Inc.", "1 Main", "Apt A", "San Francisco", "CA", "94102", "US", "4158889999"); @@ -165,19 +166,19 @@ TEST_F(PersonalDataManagerTest, AddProfile) { TEST_F(PersonalDataManagerTest, AddUpdateRemoveProfiles) { AutofillProfile profile0; - autofill_test::SetProfileInfo(&profile0, + test::SetProfileInfo(&profile0, "Marion", "Mitchell", "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", "91601", "US", "12345678910"); AutofillProfile profile1; - autofill_test::SetProfileInfo(&profile1, + test::SetProfileInfo(&profile1, "Josephine", "Alicia", "Saenz", "joewayne@me.xyz", "Fox", "903 Apple Ct.", NULL, "Orlando", "FL", "32801", "US", "19482937549"); AutofillProfile profile2; - autofill_test::SetProfileInfo(&profile2, + test::SetProfileInfo(&profile2, "Josephine", "Alicia", "Saenz", "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", "32801", "US", "19482937549"); @@ -226,15 +227,15 @@ TEST_F(PersonalDataManagerTest, AddUpdateRemoveProfiles) { TEST_F(PersonalDataManagerTest, AddUpdateRemoveCreditCards) { CreditCard credit_card0; - autofill_test::SetCreditCardInfo(&credit_card0, + test::SetCreditCardInfo(&credit_card0, "John Dillinger", "423456789012" /* Visa */, "01", "2010"); CreditCard credit_card1; - autofill_test::SetCreditCardInfo(&credit_card1, + test::SetCreditCardInfo(&credit_card1, "Bonnie Parker", "518765432109" /* Mastercard */, "12", "2012"); CreditCard credit_card2; - autofill_test::SetCreditCardInfo(&credit_card2, + test::SetCreditCardInfo(&credit_card2, "Clyde Barrow", "347666888555" /* American Express */, "04", "2015"); // Add two test credit cards to the database. @@ -281,23 +282,23 @@ TEST_F(PersonalDataManagerTest, AddUpdateRemoveCreditCards) { TEST_F(PersonalDataManagerTest, AddProfilesAndCreditCards) { AutofillProfile profile0; - autofill_test::SetProfileInfo(&profile0, + test::SetProfileInfo(&profile0, "Marion", "Mitchell", "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", "91601", "US", "12345678910"); AutofillProfile profile1; - autofill_test::SetProfileInfo(&profile1, + test::SetProfileInfo(&profile1, "Josephine", "Alicia", "Saenz", "joewayne@me.xyz", "Fox", "903 Apple Ct.", NULL, "Orlando", "FL", "32801", "US", "19482937549"); CreditCard credit_card0; - autofill_test::SetCreditCardInfo(&credit_card0, + test::SetCreditCardInfo(&credit_card0, "John Dillinger", "423456789012" /* Visa */, "01", "2010"); CreditCard credit_card1; - autofill_test::SetCreditCardInfo(&credit_card1, + test::SetCreditCardInfo(&credit_card1, "Bonnie Parker", "518765432109" /* Mastercard */, "12", "2012"); // Add two test profiles to the database. @@ -342,7 +343,7 @@ TEST_F(PersonalDataManagerTest, AddProfilesAndCreditCards) { // correctly on load. TEST_F(PersonalDataManagerTest, PopulateUniqueIDsOnLoad) { AutofillProfile profile0; - autofill_test::SetProfileInfo(&profile0, + test::SetProfileInfo(&profile0, "y", "", "", "", "", "", "", "", "", "", "", ""); // Add the profile0 to the db. @@ -360,7 +361,7 @@ TEST_F(PersonalDataManagerTest, PopulateUniqueIDsOnLoad) { // Add a new profile. AutofillProfile profile1; - autofill_test::SetProfileInfo(&profile1, + test::SetProfileInfo(&profile1, "z", "", "", "", "", "", "", "", "", "", "", ""); personal_data_->AddProfile(profile1); @@ -379,7 +380,7 @@ TEST_F(PersonalDataManagerTest, PopulateUniqueIDsOnLoad) { TEST_F(PersonalDataManagerTest, SetEmptyProfile) { AutofillProfile profile0; - autofill_test::SetProfileInfo(&profile0, + test::SetProfileInfo(&profile0, "", "", "", "", "", "", "", "", "", "", "", ""); // Add the empty profile to the database. @@ -399,7 +400,7 @@ TEST_F(PersonalDataManagerTest, SetEmptyProfile) { TEST_F(PersonalDataManagerTest, SetEmptyCreditCard) { CreditCard credit_card0; - autofill_test::SetCreditCardInfo(&credit_card0, "", "", "", ""); + test::SetCreditCardInfo(&credit_card0, "", "", "", ""); // Add the empty credit card to the database. personal_data_->AddCreditCard(credit_card0); @@ -418,13 +419,13 @@ TEST_F(PersonalDataManagerTest, SetEmptyCreditCard) { TEST_F(PersonalDataManagerTest, Refresh) { AutofillProfile profile0; - autofill_test::SetProfileInfo(&profile0, + test::SetProfileInfo(&profile0, "Marion", "Mitchell", "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", "91601", "US", "12345678910"); AutofillProfile profile1; - autofill_test::SetProfileInfo(&profile1, + test::SetProfileInfo(&profile1, "Josephine", "Alicia", "Saenz", "joewayne@me.xyz", "Fox", "903 Apple Ct.", NULL, "Orlando", "FL", "32801", "US", "19482937549"); @@ -450,7 +451,7 @@ TEST_F(PersonalDataManagerTest, Refresh) { EXPECT_EQ(profile1, *results1[1]); AutofillProfile profile2; - autofill_test::SetProfileInfo(&profile2, + test::SetProfileInfo(&profile2, "Josephine", "Alicia", "Saenz", "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", "32801", "US", "19482937549"); @@ -503,26 +504,23 @@ TEST_F(PersonalDataManagerTest, Refresh) { TEST_F(PersonalDataManagerTest, ImportFormData) { FormData form; FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "First name:", "first_name", "George", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Last name:", "last_name", "Washington", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Email:", "email", "theprez@gmail.com", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Address:", "address1", "21 Laussat St", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "City:", "city", "San Francisco", "text", &field); + test::CreateTestFormField("City:", "city", "San Francisco", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "State:", "state", "California", "text", &field); + test::CreateTestFormField("State:", "state", "California", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "Zip:", "zip", "94102", "text", &field); + test::CreateTestFormField("Zip:", "zip", "94102", "text", &field); form.fields.push_back(field); FormStructure form_structure(form, std::string()); form_structure.DetermineHeuristicTypes(TestAutofillMetrics()); @@ -537,7 +535,7 @@ TEST_F(PersonalDataManagerTest, ImportFormData) { MessageLoop::current()->Run(); AutofillProfile expected; - autofill_test::SetProfileInfo(&expected, "George", NULL, + test::SetProfileInfo(&expected, "George", NULL, "Washington", "theprez@gmail.com", NULL, "21 Laussat St", NULL, "San Francisco", "California", "94102", NULL, NULL); const std::vector<AutofillProfile*>& results = personal_data_->GetProfiles(); @@ -548,26 +546,22 @@ TEST_F(PersonalDataManagerTest, ImportFormData) { TEST_F(PersonalDataManagerTest, ImportFormDataBadEmail) { FormData form; FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "First name:", "first_name", "George", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Last name:", "last_name", "Washington", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "Email:", "email", "bogus", "text", &field); + test::CreateTestFormField("Email:", "email", "bogus", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Address:", "address1", "21 Laussat St", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "City:", "city", "San Francisco", "text", &field); + test::CreateTestFormField("City:", "city", "San Francisco", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "State:", "state", "California", "text", &field); + test::CreateTestFormField("State:", "state", "California", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "Zip:", "zip", "94102", "text", &field); + test::CreateTestFormField("Zip:", "zip", "94102", "text", &field); form.fields.push_back(field); FormStructure form_structure(form, std::string()); form_structure.DetermineHeuristicTypes(TestAutofillMetrics()); @@ -584,25 +578,22 @@ TEST_F(PersonalDataManagerTest, ImportFormDataBadEmail) { TEST_F(PersonalDataManagerTest, ImportFormDataTwoEmails) { FormData form; FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Name:", "name", "George Washington", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Address:", "address1", "21 Laussat St", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "City:", "city", "San Francisco", "text", &field); + test::CreateTestFormField("City:", "city", "San Francisco", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "State:", "state", "California", "text", &field); + test::CreateTestFormField("State:", "state", "California", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "Zip:", "zip", "94102", "text", &field); + test::CreateTestFormField("Zip:", "zip", "94102", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Email:", "email", "example@example.com", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Confirm email:", "confirm_email", "example@example.com", "text", &field); form.fields.push_back(field); FormStructure form_structure(form, std::string()); @@ -618,25 +609,22 @@ TEST_F(PersonalDataManagerTest, ImportFormDataTwoEmails) { TEST_F(PersonalDataManagerTest, ImportFormDataTwoDifferentEmails) { FormData form; FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Name:", "name", "George Washington", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Address:", "address1", "21 Laussat St", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "City:", "city", "San Francisco", "text", &field); + test::CreateTestFormField("City:", "city", "San Francisco", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "State:", "state", "California", "text", &field); + test::CreateTestFormField("State:", "state", "California", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "Zip:", "zip", "94102", "text", &field); + test::CreateTestFormField("Zip:", "zip", "94102", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Email:", "email", "example@example.com", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Email:", "email2", "example2@example.com", "text", &field); form.fields.push_back(field); FormStructure form_structure(form, std::string()); @@ -651,13 +639,13 @@ TEST_F(PersonalDataManagerTest, ImportFormDataTwoDifferentEmails) { TEST_F(PersonalDataManagerTest, ImportFormDataNotEnoughFilledFields) { FormData form; FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "First name:", "first_name", "George", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Last name:", "last_name", "Washington", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Card number:", "card_number", "4111 1111 1111 1111", "text", &field); form.fields.push_back(field); FormStructure form_structure(form, std::string()); @@ -678,23 +666,18 @@ TEST_F(PersonalDataManagerTest, ImportFormMinimumAddressUSA) { // zip code. FormData form; FormFieldData field; - autofill_test::CreateTestFormField( - "Name:", "name", "Barack Obama", "text", &field); + test::CreateTestFormField("Name:", "name", "Barack Obama", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Address:", "address", "1600 Pennsylvania Avenue", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "City:", "city", "Washington", "text", &field); + test::CreateTestFormField("City:", "city", "Washington", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "State:", "state", "DC", "text", &field); + test::CreateTestFormField("State:", "state", "DC", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "Zip:", "zip", "20500", "text", &field); + test::CreateTestFormField("Zip:", "zip", "20500", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "Country:", "country", "USA", "text", &field); + test::CreateTestFormField("Country:", "country", "USA", "text", &field); form.fields.push_back(field); FormStructure form_structure(form, std::string()); form_structure.DetermineHeuristicTypes(TestAutofillMetrics()); @@ -710,19 +693,17 @@ TEST_F(PersonalDataManagerTest, ImportFormMinimumAddressGB) { // not requested on forms. FormData form; FormFieldData field; - autofill_test::CreateTestFormField( - "Name:", "name", "David Cameron", "text", &field); + test::CreateTestFormField("Name:", "name", "David Cameron", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Address:", "address", "10 Downing Street", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "City:", "city", "London", "text", &field); + test::CreateTestFormField("City:", "city", "London", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Postcode:", "postcode", "SW1A 2AA", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Country:", "country", "United Kingdom", "text", &field); form.fields.push_back(field); FormStructure form_structure(form, std::string()); @@ -739,14 +720,13 @@ TEST_F(PersonalDataManagerTest, ImportFormMinimumAddressGI) { // There are no cities or provinces and no postal/zip code system. FormData form; FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Name:", "name", "Sir Adrian Johns", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Address:", "address", "The Convent, Main Street", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "Country:", "country", "Gibraltar", "text", &field); + test::CreateTestFormField("Country:", "country", "Gibraltar", "text", &field); form.fields.push_back(field); FormStructure form_structure(form, std::string()); form_structure.DetermineHeuristicTypes(TestAutofillMetrics()); @@ -760,35 +740,32 @@ TEST_F(PersonalDataManagerTest, ImportFormMinimumAddressGI) { TEST_F(PersonalDataManagerTest, ImportPhoneNumberSplitAcrossMultipleFields) { FormData form; FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "First name:", "first_name", "George", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Last name:", "last_name", "Washington", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Phone #:", "home_phone_area_code", "650", "text", &field); field.max_length = 3; form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Phone #:", "home_phone_prefix", "555", "text", &field); field.max_length = 3; form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Phone #:", "home_phone_suffix", "0000", "text", &field); field.max_length = 4; form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Address:", "address1", "21 Laussat St", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "City:", "city", "San Francisco", "text", &field); + test::CreateTestFormField("City:", "city", "San Francisco", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "State:", "state", "California", "text", &field); + test::CreateTestFormField("State:", "state", "California", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "Zip:", "zip", "94102", "text", &field); + test::CreateTestFormField("Zip:", "zip", "94102", "text", &field); form.fields.push_back(field); FormStructure form_structure(form, std::string()); form_structure.DetermineHeuristicTypes(TestAutofillMetrics()); @@ -803,7 +780,7 @@ TEST_F(PersonalDataManagerTest, ImportPhoneNumberSplitAcrossMultipleFields) { MessageLoop::current()->Run(); AutofillProfile expected; - autofill_test::SetProfileInfo(&expected, "George", NULL, + test::SetProfileInfo(&expected, "George", NULL, "Washington", NULL, NULL, "21 Laussat St", NULL, "San Francisco", "California", "94102", NULL, "(650) 555-0000"); const std::vector<AutofillProfile*>& results = personal_data_->GetProfiles(); @@ -851,26 +828,23 @@ TEST_F(PersonalDataManagerTest, SetUniqueCreditCardLabels) { TEST_F(PersonalDataManagerTest, AggregateTwoDifferentProfiles) { FormData form1; FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "First name:", "first_name", "George", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Last name:", "last_name", "Washington", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Email:", "email", "theprez@gmail.com", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Address:", "address1", "21 Laussat St", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "City:", "city", "San Francisco", "text", &field); + test::CreateTestFormField("City:", "city", "San Francisco", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "State:", "state", "California", "text", &field); + test::CreateTestFormField("State:", "state", "California", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "Zip:", "zip", "94102", "text", &field); + test::CreateTestFormField("Zip:", "zip", "94102", "text", &field); form1.fields.push_back(field); FormStructure form_structure1(form1, std::string()); @@ -886,7 +860,7 @@ TEST_F(PersonalDataManagerTest, AggregateTwoDifferentProfiles) { MessageLoop::current()->Run(); AutofillProfile expected; - autofill_test::SetProfileInfo(&expected, "George", NULL, + test::SetProfileInfo(&expected, "George", NULL, "Washington", "theprez@gmail.com", NULL, "21 Laussat St", NULL, "San Francisco", "California", "94102", NULL, NULL); const std::vector<AutofillProfile*>& results1 = personal_data_->GetProfiles(); @@ -895,26 +869,23 @@ TEST_F(PersonalDataManagerTest, AggregateTwoDifferentProfiles) { // Now create a completely different profile. FormData form2; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "First name:", "first_name", "John", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Last name:", "last_name", "Adams", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Email:", "email", "second@gmail.com", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Address:", "address1", "22 Laussat St", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "City:", "city", "San Francisco", "text", &field); + test::CreateTestFormField("City:", "city", "San Francisco", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "State:", "state", "California", "text", &field); + test::CreateTestFormField("State:", "state", "California", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "Zip:", "zip", "94102", "text", &field); + test::CreateTestFormField("Zip:", "zip", "94102", "text", &field); form2.fields.push_back(field); FormStructure form_structure2(form2, std::string()); @@ -931,7 +902,7 @@ TEST_F(PersonalDataManagerTest, AggregateTwoDifferentProfiles) { const std::vector<AutofillProfile*>& results2 = personal_data_->GetProfiles(); AutofillProfile expected2; - autofill_test::SetProfileInfo(&expected2, "John", NULL, + test::SetProfileInfo(&expected2, "John", NULL, "Adams", "second@gmail.com", NULL, "22 Laussat St", NULL, "San Francisco", "California", "94102", NULL, NULL); ASSERT_EQ(2U, results2.size()); @@ -942,26 +913,23 @@ TEST_F(PersonalDataManagerTest, AggregateTwoDifferentProfiles) { TEST_F(PersonalDataManagerTest, AggregateTwoProfilesWithMultiValue) { FormData form1; FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "First name:", "first_name", "George", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Last name:", "last_name", "Washington", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Email:", "email", "theprez@gmail.com", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Address:", "address1", "21 Laussat St", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "City:", "city", "San Francisco", "text", &field); + test::CreateTestFormField("City:", "city", "San Francisco", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "State:", "state", "California", "text", &field); + test::CreateTestFormField("State:", "state", "California", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "Zip:", "zip", "94102", "text", &field); + test::CreateTestFormField("Zip:", "zip", "94102", "text", &field); form1.fields.push_back(field); FormStructure form_structure1(form1, std::string()); @@ -977,7 +945,7 @@ TEST_F(PersonalDataManagerTest, AggregateTwoProfilesWithMultiValue) { MessageLoop::current()->Run(); AutofillProfile expected; - autofill_test::SetProfileInfo(&expected, "George", NULL, + test::SetProfileInfo(&expected, "George", NULL, "Washington", "theprez@gmail.com", NULL, "21 Laussat St", NULL, "San Francisco", "California", "94102", NULL, NULL); const std::vector<AutofillProfile*>& results1 = personal_data_->GetProfiles(); @@ -986,26 +954,22 @@ TEST_F(PersonalDataManagerTest, AggregateTwoProfilesWithMultiValue) { // Now create a completely different profile. FormData form2; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "First name:", "first_name", "John", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "Last name:", "last_name", "Adams", "text", &field); + test::CreateTestFormField("Last name:", "last_name", "Adams", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Email:", "email", "second@gmail.com", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Address:", "address1", "21 Laussat St", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "City:", "city", "San Francisco", "text", &field); + test::CreateTestFormField("City:", "city", "San Francisco", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "State:", "state", "California", "text", &field); + test::CreateTestFormField("State:", "state", "California", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "Zip:", "zip", "94102", "text", &field); + test::CreateTestFormField("Zip:", "zip", "94102", "text", &field); form2.fields.push_back(field); FormStructure form_structure2(form2, std::string()); @@ -1037,32 +1001,28 @@ TEST_F(PersonalDataManagerTest, AggregateTwoProfilesWithMultiValue) { TEST_F(PersonalDataManagerTest, AggregateSameProfileWithConflict) { FormData form1; FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "First name:", "first_name", "George", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Last name:", "last_name", "Washington", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Address:", "address", "1600 Pennsylvania Avenue", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Address Line 2:", "address2", "Suite A", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "City:", "city", "San Francisco", "text", &field); + test::CreateTestFormField("City:", "city", "San Francisco", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "State:", "state", "California", "text", &field); + test::CreateTestFormField("State:", "state", "California", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "Zip:", "zip", "94102", "text", &field); + test::CreateTestFormField("Zip:", "zip", "94102", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Email:", "email", "theprez@gmail.com", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "Phone:", "phone", "6505556666", "text", &field); + test::CreateTestFormField("Phone:", "phone", "6505556666", "text", &field); form1.fields.push_back(field); FormStructure form_structure1(form1, std::string()); @@ -1078,7 +1038,7 @@ TEST_F(PersonalDataManagerTest, AggregateSameProfileWithConflict) { MessageLoop::current()->Run(); AutofillProfile expected; - autofill_test::SetProfileInfo( + test::SetProfileInfo( &expected, "George", NULL, "Washington", "theprez@gmail.com", NULL, "1600 Pennsylvania Avenue", "Suite A", "San Francisco", "California", "94102", NULL, "(650) 555-6666"); @@ -1088,37 +1048,32 @@ TEST_F(PersonalDataManagerTest, AggregateSameProfileWithConflict) { // Now create an updated profile. FormData form2; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "First name:", "first_name", "George", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Last name:", "last_name", "Washington", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Address:", "address", "1600 Pennsylvania Avenue", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Address Line 2:", "address2", "Suite A", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "City:", "city", "San Francisco", "text", &field); + test::CreateTestFormField("City:", "city", "San Francisco", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "State:", "state", "California", "text", &field); + test::CreateTestFormField("State:", "state", "California", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "Zip:", "zip", "94102", "text", &field); + test::CreateTestFormField("Zip:", "zip", "94102", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Email:", "email", "theprez@gmail.com", "text", &field); form2.fields.push_back(field); // Country gets added. - autofill_test::CreateTestFormField( - "Country:", "country", "USA", "text", &field); + test::CreateTestFormField("Country:", "country", "USA", "text", &field); form2.fields.push_back(field); // Phone gets updated. - autofill_test::CreateTestFormField( - "Phone:", "phone", "6502231234", "text", &field); + test::CreateTestFormField("Phone:", "phone", "6502231234", "text", &field); form2.fields.push_back(field); FormStructure form_structure2(form2, std::string()); @@ -1147,23 +1102,20 @@ TEST_F(PersonalDataManagerTest, AggregateSameProfileWithConflict) { TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInOld) { FormData form1; FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "First name:", "first_name", "George", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Last name:", "last_name", "Washington", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Address Line 1:", "address", "190 High Street", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "City:", "city", "Philadelphia", "text", &field); + test::CreateTestFormField("City:", "city", "Philadelphia", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "State:", "state", "Pennsylvania", "text", &field); + test::CreateTestFormField("State:", "state", "Pennsylvania", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "Zip:", "zipcode", "19106", "text", &field); + test::CreateTestFormField("Zip:", "zipcode", "19106", "text", &field); form1.fields.push_back(field); FormStructure form_structure1(form1, std::string()); @@ -1179,7 +1131,7 @@ TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInOld) { MessageLoop::current()->Run(); AutofillProfile expected; - autofill_test::SetProfileInfo(&expected, "George", NULL, + test::SetProfileInfo(&expected, "George", NULL, "Washington", NULL, NULL, "190 High Street", NULL, "Philadelphia", "Pennsylvania", "19106", NULL, NULL); const std::vector<AutofillProfile*>& results1 = personal_data_->GetProfiles(); @@ -1188,26 +1140,23 @@ TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInOld) { // Submit a form with new data for the first profile. FormData form2; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "First name:", "first_name", "George", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Last name:", "last_name", "Washington", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Email:", "email", "theprez@gmail.com", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Address Line 1:", "address", "190 High Street", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "City:", "city", "Philadelphia", "text", &field); + test::CreateTestFormField("City:", "city", "Philadelphia", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "State:", "state", "Pennsylvania", "text", &field); + test::CreateTestFormField("State:", "state", "Pennsylvania", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "Zip:", "zipcode", "19106", "text", &field); + test::CreateTestFormField("Zip:", "zipcode", "19106", "text", &field); form2.fields.push_back(field); FormStructure form_structure2(form2, std::string()); @@ -1224,7 +1173,7 @@ TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInOld) { const std::vector<AutofillProfile*>& results2 = personal_data_->GetProfiles(); AutofillProfile expected2; - autofill_test::SetProfileInfo(&expected2, "George", NULL, + test::SetProfileInfo(&expected2, "George", NULL, "Washington", "theprez@gmail.com", NULL, "190 High Street", NULL, "Philadelphia", "Pennsylvania", "19106", NULL, NULL); ASSERT_EQ(1U, results2.size()); @@ -1234,29 +1183,26 @@ TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInOld) { TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInNew) { FormData form1; FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "First name:", "first_name", "George", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Last name:", "last_name", "Washington", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Company:", "company", "Government", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Email:", "email", "theprez@gmail.com", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Address Line 1:", "address", "190 High Street", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "City:", "city", "Philadelphia", "text", &field); + test::CreateTestFormField("City:", "city", "Philadelphia", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "State:", "state", "Pennsylvania", "text", &field); + test::CreateTestFormField("State:", "state", "Pennsylvania", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "Zip:", "zipcode", "19106", "text", &field); + test::CreateTestFormField("Zip:", "zipcode", "19106", "text", &field); form1.fields.push_back(field); FormStructure form_structure1(form1, std::string()); @@ -1272,7 +1218,7 @@ TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInNew) { MessageLoop::current()->Run(); AutofillProfile expected; - autofill_test::SetProfileInfo(&expected, "George", NULL, + test::SetProfileInfo(&expected, "George", NULL, "Washington", "theprez@gmail.com", "Government", "190 High Street", NULL, "Philadelphia", "Pennsylvania", "19106", NULL, NULL); const std::vector<AutofillProfile*>& results1 = personal_data_->GetProfiles(); @@ -1281,27 +1227,24 @@ TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInNew) { // Submit a form with new data for the first profile. FormData form2; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "First name:", "first_name", "George", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Last name:", "last_name", "Washington", "text", &field); form2.fields.push_back(field); // Note missing Company field. - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Email:", "email", "theprez@gmail.com", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Address Line 1:", "address", "190 High Street", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "City:", "city", "Philadelphia", "text", &field); + test::CreateTestFormField("City:", "city", "Philadelphia", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "State:", "state", "Pennsylvania", "text", &field); + test::CreateTestFormField("State:", "state", "Pennsylvania", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "Zip:", "zipcode", "19106", "text", &field); + test::CreateTestFormField("Zip:", "zipcode", "19106", "text", &field); form2.fields.push_back(field); FormStructure form_structure2(form2, std::string()); @@ -1325,23 +1268,22 @@ TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInNew) { TEST_F(PersonalDataManagerTest, AggregateProfileWithInsufficientAddress) { FormData form1; FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "First name:", "first_name", "George", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Last name:", "last_name", "Washington", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Company:", "company", "Government", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Email:", "email", "theprez@gmail.com", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Address Line 1:", "address", "190 High Street", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "City:", "city", "Philadelphia", "text", &field); + test::CreateTestFormField("City:", "city", "Philadelphia", "text", &field); form1.fields.push_back(field); FormStructure form_structure1(form1, std::string()); @@ -1363,7 +1305,7 @@ TEST_F(PersonalDataManagerTest, AggregateExistingAuxiliaryProfile) { // Simulate having access to an auxiliary profile. // |auxiliary_profile| will be owned by |personal_data_|. AutofillProfile* auxiliary_profile = new AutofillProfile; - autofill_test::SetProfileInfo(auxiliary_profile, + test::SetProfileInfo(auxiliary_profile, "Tester", "Frederick", "McAddressBookTesterson", "tester@example.com", "Acme Inc.", "1 Main", "Apt A", "San Francisco", "CA", "94102", "US", "1.415.888.9999"); @@ -1375,29 +1317,24 @@ TEST_F(PersonalDataManagerTest, AggregateExistingAuxiliaryProfile) { // Note that the phone number format is different from the saved format. FormData form; FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "First name:", "first_name", "Tester", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Last name:", "last_name", "McAddressBookTesterson", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Email:", "email", "tester@example.com", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "Address:", "address1", "1 Main", "text", &field); + test::CreateTestFormField("Address:", "address1", "1 Main", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "City:", "city", "San Francisco", "text", &field); + test::CreateTestFormField("City:", "city", "San Francisco", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "State:", "state", "CA", "text", &field); + test::CreateTestFormField("State:", "state", "CA", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "Zip:", "zip", "94102", "text", &field); + test::CreateTestFormField("Zip:", "zip", "94102", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "Phone:", "phone", "4158889999", "text", &field); + test::CreateTestFormField("Phone:", "phone", "4158889999", "text", &field); form.fields.push_back(field); FormStructure form_structure(form, std::string()); @@ -1422,17 +1359,15 @@ TEST_F(PersonalDataManagerTest, AggregateTwoDifferentCreditCards) { // Start with a single valid credit card form. FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Name on card:", "name_on_card", "Biggie Smalls", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Month:", "exp_month", "01", "text", &field); + test::CreateTestFormField("Exp Month:", "exp_month", "01", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Year:", "exp_year", "2011", "text", &field); + test::CreateTestFormField("Exp Year:", "exp_year", "2011", "text", &field); form1.fields.push_back(field); FormStructure form_structure1(form1, std::string()); @@ -1450,7 +1385,7 @@ TEST_F(PersonalDataManagerTest, AggregateTwoDifferentCreditCards) { MessageLoop::current()->Run(); CreditCard expected; - autofill_test::SetCreditCardInfo(&expected, + test::SetCreditCardInfo(&expected, "Biggie Smalls", "4111111111111111", "01", "2011"); const std::vector<CreditCard*>& results = personal_data_->credit_cards(); ASSERT_EQ(1U, results.size()); @@ -1458,17 +1393,15 @@ TEST_F(PersonalDataManagerTest, AggregateTwoDifferentCreditCards) { // Add a second different valid credit card. FormData form2; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Name on card:", "name_on_card", "", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Card Number:", "card_number", "5500 0000 0000 0004", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Month:", "exp_month", "02", "text", &field); + test::CreateTestFormField("Exp Month:", "exp_month", "02", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Year:", "exp_year", "2012", "text", &field); + test::CreateTestFormField("Exp Year:", "exp_year", "2012", "text", &field); form2.fields.push_back(field); FormStructure form_structure2(form2, std::string()); @@ -1485,8 +1418,7 @@ TEST_F(PersonalDataManagerTest, AggregateTwoDifferentCreditCards) { MessageLoop::current()->Run(); CreditCard expected2; - autofill_test::SetCreditCardInfo(&expected2, - "", "5500000000000004", "02", "2012"); + test::SetCreditCardInfo(&expected2,"", "5500000000000004", "02", "2012"); const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); ASSERT_EQ(2U, results2.size()); EXPECT_EQ(0, expected.Compare(*results2[0])); @@ -1498,17 +1430,15 @@ TEST_F(PersonalDataManagerTest, AggregateInvalidCreditCard) { // Start with a single valid credit card form. FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Name on card:", "name_on_card", "Biggie Smalls", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Month:", "exp_month", "01", "text", &field); + test::CreateTestFormField("Exp Month:", "exp_month", "01", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Year:", "exp_year", "2011", "text", &field); + test::CreateTestFormField("Exp Year:", "exp_year", "2011", "text", &field); form1.fields.push_back(field); FormStructure form_structure1(form1, std::string()); @@ -1526,7 +1456,7 @@ TEST_F(PersonalDataManagerTest, AggregateInvalidCreditCard) { MessageLoop::current()->Run(); CreditCard expected; - autofill_test::SetCreditCardInfo(&expected, + test::SetCreditCardInfo(&expected, "Biggie Smalls", "4111111111111111", "01", "2011"); const std::vector<CreditCard*>& results = personal_data_->credit_cards(); ASSERT_EQ(1U, results.size()); @@ -1534,17 +1464,15 @@ TEST_F(PersonalDataManagerTest, AggregateInvalidCreditCard) { // Add a second different invalid credit card. FormData form2; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Name on card:", "name_on_card", "Jim Johansen", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Card Number:", "card_number", "1000000000000000", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Month:", "exp_month", "02", "text", &field); + test::CreateTestFormField("Exp Month:", "exp_month", "02", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Year:", "exp_year", "2012", "text", &field); + test::CreateTestFormField("Exp Year:", "exp_year", "2012", "text", &field); form2.fields.push_back(field); FormStructure form_structure2(form2, std::string()); @@ -1565,17 +1493,15 @@ TEST_F(PersonalDataManagerTest, AggregateSameCreditCardWithConflict) { // Start with a single valid credit card form. FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Name on card:", "name_on_card", "Biggie Smalls", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Month:", "exp_month", "01", "text", &field); + test::CreateTestFormField("Exp Month:", "exp_month", "01", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Year:", "exp_year", "2011", "text", &field); + test::CreateTestFormField("Exp Year:", "exp_year", "2011", "text", &field); form1.fields.push_back(field); FormStructure form_structure1(form1, std::string()); @@ -1593,7 +1519,7 @@ TEST_F(PersonalDataManagerTest, AggregateSameCreditCardWithConflict) { MessageLoop::current()->Run(); CreditCard expected; - autofill_test::SetCreditCardInfo(&expected, + test::SetCreditCardInfo(&expected, "Biggie Smalls", "4111111111111111", "01", "2011"); const std::vector<CreditCard*>& results = personal_data_->credit_cards(); ASSERT_EQ(1U, results.size()); @@ -1602,17 +1528,15 @@ TEST_F(PersonalDataManagerTest, AggregateSameCreditCardWithConflict) { // Add a second different valid credit card where the year is different but // the credit card number matches. FormData form2; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Name on card:", "name_on_card", "Biggie Smalls", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Card Number:", "card_number", "4111 1111 1111 1111", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Month:", "exp_month", "01", "text", &field); + test::CreateTestFormField("Exp Month:", "exp_month", "01", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Year:", "exp_year", "2012", "text", &field); + test::CreateTestFormField("Exp Year:", "exp_year", "2012", "text", &field); form2.fields.push_back(field); FormStructure form_structure2(form2, std::string()); @@ -1629,7 +1553,7 @@ TEST_F(PersonalDataManagerTest, AggregateSameCreditCardWithConflict) { // Expect that the newer information is saved. In this case the year is // updated to "2012". CreditCard expected2; - autofill_test::SetCreditCardInfo(&expected2, + test::SetCreditCardInfo(&expected2, "Biggie Smalls", "4111111111111111", "01", "2012"); const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); ASSERT_EQ(1U, results2.size()); @@ -1641,17 +1565,15 @@ TEST_F(PersonalDataManagerTest, AggregateEmptyCreditCardWithConflict) { // Start with a single valid credit card form. FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Name on card:", "name_on_card", "Biggie Smalls", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Month:", "exp_month", "01", "text", &field); + test::CreateTestFormField("Exp Month:", "exp_month", "01", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Year:", "exp_year", "2011", "text", &field); + test::CreateTestFormField("Exp Year:", "exp_year", "2011", "text", &field); form1.fields.push_back(field); FormStructure form_structure1(form1, std::string()); @@ -1669,7 +1591,7 @@ TEST_F(PersonalDataManagerTest, AggregateEmptyCreditCardWithConflict) { MessageLoop::current()->Run(); CreditCard expected; - autofill_test::SetCreditCardInfo(&expected, + test::SetCreditCardInfo(&expected, "Biggie Smalls", "4111111111111111", "01", "2011"); const std::vector<CreditCard*>& results = personal_data_->credit_cards(); ASSERT_EQ(1U, results.size()); @@ -1677,14 +1599,12 @@ TEST_F(PersonalDataManagerTest, AggregateEmptyCreditCardWithConflict) { // Add a second credit card with no number. FormData form2; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Name on card:", "name_on_card", "Biggie Smalls", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Month:", "exp_month", "01", "text", &field); + test::CreateTestFormField("Exp Month:", "exp_month", "01", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Year:", "exp_year", "2012", "text", &field); + test::CreateTestFormField("Exp Year:", "exp_year", "2012", "text", &field); form2.fields.push_back(field); FormStructure form_structure2(form2, std::string()); @@ -1697,7 +1617,7 @@ TEST_F(PersonalDataManagerTest, AggregateEmptyCreditCardWithConflict) { // No change is expected. CreditCard expected2; - autofill_test::SetCreditCardInfo(&expected2, + test::SetCreditCardInfo(&expected2, "Biggie Smalls", "4111111111111111", "01", "2011"); const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); ASSERT_EQ(1U, results2.size()); @@ -1709,17 +1629,15 @@ TEST_F(PersonalDataManagerTest, AggregateCreditCardWithMissingInfoInNew) { // Start with a single valid credit card form. FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Name on card:", "name_on_card", "Biggie Smalls", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Month:", "exp_month", "01", "text", &field); + test::CreateTestFormField("Exp Month:", "exp_month", "01", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Year:", "exp_year", "2011", "text", &field); + test::CreateTestFormField("Exp Year:", "exp_year", "2011", "text", &field); form1.fields.push_back(field); FormStructure form_structure1(form1, std::string()); @@ -1737,7 +1655,7 @@ TEST_F(PersonalDataManagerTest, AggregateCreditCardWithMissingInfoInNew) { MessageLoop::current()->Run(); CreditCard expected; - autofill_test::SetCreditCardInfo(&expected, + test::SetCreditCardInfo(&expected, "Biggie Smalls", "4111111111111111", "01", "2011"); const std::vector<CreditCard*>& results = personal_data_->credit_cards(); ASSERT_EQ(1U, results.size()); @@ -1747,14 +1665,12 @@ TEST_F(PersonalDataManagerTest, AggregateCreditCardWithMissingInfoInNew) { // the credit card number matches. FormData form2; // Note missing name. - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Card Number:", "card_number", "4111111111111111", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Month:", "exp_month", "01", "text", &field); + test::CreateTestFormField("Exp Month:", "exp_month", "01", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Year:", "exp_year", "2011", "text", &field); + test::CreateTestFormField("Exp Year:", "exp_year", "2011", "text", &field); form2.fields.push_back(field); FormStructure form_structure2(form2, std::string()); @@ -1770,7 +1686,7 @@ TEST_F(PersonalDataManagerTest, AggregateCreditCardWithMissingInfoInNew) { // No change is expected. CreditCard expected2; - autofill_test::SetCreditCardInfo(&expected2, + test::SetCreditCardInfo(&expected2, "Biggie Smalls", "4111111111111111", "01", "2011"); const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); ASSERT_EQ(1U, results2.size()); @@ -1778,10 +1694,10 @@ TEST_F(PersonalDataManagerTest, AggregateCreditCardWithMissingInfoInNew) { // Add a third credit card where the expiration date is missing. FormData form3; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Name on card:", "name_on_card", "Johnny McEnroe", "text", &field); form3.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Card Number:", "card_number", "5555555555554444", "text", &field); form3.fields.push_back(field); // Note missing expiration month and year.. @@ -1796,7 +1712,7 @@ TEST_F(PersonalDataManagerTest, AggregateCreditCardWithMissingInfoInNew) { // No change is expected. CreditCard expected3; - autofill_test::SetCreditCardInfo(&expected3, + test::SetCreditCardInfo(&expected3, "Biggie Smalls", "4111111111111111", "01", "2011"); const std::vector<CreditCard*>& results3 = personal_data_->credit_cards(); ASSERT_EQ(1U, results3.size()); @@ -1807,7 +1723,7 @@ TEST_F(PersonalDataManagerTest, AggregateCreditCardWithMissingInfoInOld) { // Start with a single valid credit card stored via the preferences. // Note the empty name. CreditCard saved_credit_card; - autofill_test::SetCreditCardInfo(&saved_credit_card, + test::SetCreditCardInfo(&saved_credit_card, "", "4111111111111111" /* Visa */, "01", "2011"); personal_data_->AddCreditCard(saved_credit_card); @@ -1825,17 +1741,15 @@ TEST_F(PersonalDataManagerTest, AggregateCreditCardWithMissingInfoInOld) { // the credit card number matches. FormData form; FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Name on card:", "name_on_card", "Biggie Smalls", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Month:", "exp_month", "01", "text", &field); + test::CreateTestFormField("Exp Month:", "exp_month", "01", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Year:", "exp_year", "2012", "text", &field); + test::CreateTestFormField("Exp Year:", "exp_year", "2012", "text", &field); form.fields.push_back(field); FormStructure form_structure(form, std::string()); @@ -1853,7 +1767,7 @@ TEST_F(PersonalDataManagerTest, AggregateCreditCardWithMissingInfoInOld) { // Expect that the newer information is saved. In this case the year is // added to the existing credit card. CreditCard expected2; - autofill_test::SetCreditCardInfo(&expected2, + test::SetCreditCardInfo(&expected2, "Biggie Smalls", "4111111111111111", "01", "2012"); const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); ASSERT_EQ(1U, results2.size()); @@ -1866,7 +1780,7 @@ TEST_F(PersonalDataManagerTest, AggregateSameCreditCardWithSeparators) { // Start with a single valid credit card stored via the preferences. // Note the separators in the credit card number. CreditCard saved_credit_card; - autofill_test::SetCreditCardInfo(&saved_credit_card, + test::SetCreditCardInfo(&saved_credit_card, "Biggie Smalls", "4111 1111 1111 1111" /* Visa */, "01", "2011"); personal_data_->AddCreditCard(saved_credit_card); @@ -1882,17 +1796,15 @@ TEST_F(PersonalDataManagerTest, AggregateSameCreditCardWithSeparators) { // Import the same card info, but with different separators in the number. FormData form; FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Name on card:", "name_on_card", "Biggie Smalls", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Card Number:", "card_number", "4111-1111-1111-1111", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Month:", "exp_month", "01", "text", &field); + test::CreateTestFormField("Exp Month:", "exp_month", "01", "text", &field); form.fields.push_back(field); - autofill_test::CreateTestFormField( - "Exp Year:", "exp_year", "2011", "text", &field); + test::CreateTestFormField("Exp Year:", "exp_year", "2011", "text", &field); form.fields.push_back(field); FormStructure form_structure(form, std::string()); @@ -1921,7 +1833,7 @@ TEST_F(PersonalDataManagerTest, GetNonEmptyTypes) { // Test with one profile stored. AutofillProfile profile0; - autofill_test::SetProfileInfo(&profile0, + test::SetProfileInfo(&profile0, "Marion", NULL, "Morrison", "johnwayne@me.xyz", NULL, "123 Zoo St.", NULL, "Hollywood", "CA", "91601", "US", "14155678910"); @@ -1952,13 +1864,13 @@ TEST_F(PersonalDataManagerTest, GetNonEmptyTypes) { // Test with multiple profiles stored. AutofillProfile profile1; - autofill_test::SetProfileInfo(&profile1, + test::SetProfileInfo(&profile1, "Josephine", "Alicia", "Saenz", "joewayne@me.xyz", "Fox", "903 Apple Ct.", NULL, "Orlando", "FL", "32801", "US", "16502937549"); AutofillProfile profile2; - autofill_test::SetProfileInfo(&profile2, + test::SetProfileInfo(&profile2, "Josephine", "Alicia", "Saenz", "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", "32801", "US", "16502937549"); @@ -1994,9 +1906,9 @@ TEST_F(PersonalDataManagerTest, GetNonEmptyTypes) { // Test with credit card information also stored. CreditCard credit_card; - autofill_test::SetCreditCardInfo(&credit_card, - "John Dillinger", "423456789012" /* Visa */, - "01", "2010"); + test::SetCreditCardInfo(&credit_card, + "John Dillinger", "423456789012" /* Visa */, + "01", "2010"); personal_data_->AddCreditCard(credit_card); // Verify that the web database has been updated and the notification sent. @@ -2036,28 +1948,27 @@ TEST_F(PersonalDataManagerTest, GetNonEmptyTypes) { TEST_F(PersonalDataManagerTest, CaseInsensitiveMultiValueAggregation) { FormData form1; FormFieldData field; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "First name:", "first_name", "George", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Last name:", "last_name", "Washington", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Email:", "email", "theprez@gmail.com", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Address:", "address1", "21 Laussat St", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "City:", "city", "San Francisco", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( - "State:", "state", "California", "text", &field); + test::CreateTestFormField("State:", "state", "California", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Zip:", "zip", "94102", "text", &field); form1.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Phone number:", "phone_number", "817-555-6789", "text", &field); form1.fields.push_back(field); @@ -2074,7 +1985,7 @@ TEST_F(PersonalDataManagerTest, CaseInsensitiveMultiValueAggregation) { MessageLoop::current()->Run(); AutofillProfile expected; - autofill_test::SetProfileInfo(&expected, "George", NULL, + test::SetProfileInfo(&expected, "George", NULL, "Washington", "theprez@gmail.com", NULL, "21 Laussat St", NULL, "San Francisco", "California", "94102", NULL, "(817) 555-6789"); const std::vector<AutofillProfile*>& results1 = personal_data_->GetProfiles(); @@ -2083,28 +1994,25 @@ TEST_F(PersonalDataManagerTest, CaseInsensitiveMultiValueAggregation) { // Upper-case the first name and change the phone number. FormData form2; - autofill_test::CreateTestFormField( + test::CreateTestFormField( "First name:", "first_name", "GEORGE", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Last name:", "last_name", "Washington", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Email:", "email", "theprez@gmail.com", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Address:", "address1", "21 Laussat St", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "City:", "city", "San Francisco", "text", &field); + test::CreateTestFormField("City:", "city", "San Francisco", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "State:", "state", "California", "text", &field); + test::CreateTestFormField("State:", "state", "California", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( - "Zip:", "zip", "94102", "text", &field); + test::CreateTestFormField("Zip:", "zip", "94102", "text", &field); form2.fields.push_back(field); - autofill_test::CreateTestFormField( + test::CreateTestFormField( "Phone number:", "phone_number", "214-555-1234", "text", &field); form2.fields.push_back(field); @@ -2130,3 +2038,5 @@ TEST_F(PersonalDataManagerTest, CaseInsensitiveMultiValueAggregation) { ASSERT_EQ(1U, results2.size()); EXPECT_EQ(0, expected.Compare(*results2[0])); } + +} // namespace autofill diff --git a/components/autofill/browser/phone_field.cc b/components/autofill/browser/phone_field.cc index e3b5a601..e3b527e 100644 --- a/components/autofill/browser/phone_field.cc +++ b/components/autofill/browser/phone_field.cc @@ -14,6 +14,7 @@ #include "components/autofill/browser/autofill_scanner.h" #include "ui/base/l10n/l10n_util.h" +namespace autofill { namespace { // This string includes all area code separators, including NoText. @@ -271,3 +272,5 @@ base::string16 PhoneField::GetRegExp(RegexType regex_id) { } return base::string16(); } + +} // namespace autofill diff --git a/components/autofill/browser/phone_field.h b/components/autofill/browser/phone_field.h index c262b68..e82c1e3 100644 --- a/components/autofill/browser/phone_field.h +++ b/components/autofill/browser/phone_field.h @@ -12,6 +12,8 @@ #include "components/autofill/browser/form_field.h" #include "components/autofill/browser/phone_number.h" +namespace autofill { + class AutofillField; class AutofillScanner; @@ -86,4 +88,6 @@ class PhoneField : public FormField { DISALLOW_COPY_AND_ASSIGN(PhoneField); }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_PHONE_FIELD_H_ diff --git a/components/autofill/browser/phone_field_unittest.cc b/components/autofill/browser/phone_field_unittest.cc index cec2f84..4e0c969 100644 --- a/components/autofill/browser/phone_field_unittest.cc +++ b/components/autofill/browser/phone_field_unittest.cc @@ -11,6 +11,8 @@ #include "components/autofill/common/form_field_data.h" #include "testing/gtest/include/gtest/gtest.h" +namespace autofill { + class PhoneFieldTest : public testing::Test { public: PhoneFieldTest() {} @@ -224,3 +226,5 @@ TEST_F(PhoneFieldTest, CountryAndCityAndPhoneNumber) { field_type_map_.find(ASCIIToUTF16("phone")) != field_type_map_.end()); EXPECT_EQ(PHONE_HOME_CITY_AND_NUMBER, field_type_map_[ASCIIToUTF16("phone")]); } + +} // namespace autofill diff --git a/components/autofill/browser/phone_number.cc b/components/autofill/browser/phone_number.cc index 4b551de..2dcd7a2 100644 --- a/components/autofill/browser/phone_number.cc +++ b/components/autofill/browser/phone_number.cc @@ -14,6 +14,7 @@ #include "components/autofill/browser/field_types.h" #include "components/autofill/browser/phone_number_i18n.h" +namespace autofill { namespace { const char16 kPhoneNumberSeparators[] = { ' ', '.', '(', ')', '-', 0 }; @@ -94,7 +95,7 @@ void PhoneNumber::SetRawInfo(AutofillFieldType type, number_ = value; // Invalidate the cached number. - cached_parsed_phone_ = autofill_i18n::PhoneObject(); + cached_parsed_phone_ = i18n::PhoneObject(); } // Normalize phones if |type| is a whole number: @@ -169,8 +170,7 @@ void PhoneNumber::GetMatchingTypes(const base::string16& text, base::string16 whole_number = GetInfo(PHONE_HOME_WHOLE_NUMBER, app_locale); if (!whole_number.empty()) { base::string16 normalized_number = - autofill_i18n::NormalizePhoneNumber(text, - GetRegion(*profile_, app_locale)); + i18n::NormalizePhoneNumber(text, GetRegion(*profile_, app_locale)); if (normalized_number == whole_number) matching_types->insert(PHONE_HOME_WHOLE_NUMBER); } @@ -179,7 +179,7 @@ void PhoneNumber::GetMatchingTypes(const base::string16& text, void PhoneNumber::UpdateCacheIfNeeded(const std::string& app_locale) const { std::string region = GetRegion(*profile_, app_locale); if (!number_.empty() && cached_parsed_phone_.region() != region) - cached_parsed_phone_ = autofill_i18n::PhoneObject(number_, region); + cached_parsed_phone_ = i18n::PhoneObject(number_, region); } PhoneNumber::PhoneCombineHelper::PhoneCombineHelper() { @@ -230,10 +230,12 @@ bool PhoneNumber::PhoneCombineHelper::ParseNumber( return true; } - return autofill_i18n::ConstructPhoneNumber( + return i18n::ConstructPhoneNumber( country_, city_, phone_, GetRegion(profile, app_locale), value); } bool PhoneNumber::PhoneCombineHelper::IsEmpty() const { return phone_.empty() && whole_number_.empty(); } + +} // namespace autofill diff --git a/components/autofill/browser/phone_number.h b/components/autofill/browser/phone_number.h index 50cc99f..62f27d5 100644 --- a/components/autofill/browser/phone_number.h +++ b/components/autofill/browser/phone_number.h @@ -14,6 +14,8 @@ #include "components/autofill/browser/form_group.h" #include "components/autofill/browser/phone_number_i18n.h" +namespace autofill { + class AutofillProfile; // A form group that stores phone number information. @@ -88,7 +90,9 @@ class PhoneNumber : public FormGroup { const AutofillProfile* profile_; // WEAK // Cached number. - mutable autofill_i18n::PhoneObject cached_parsed_phone_; + mutable i18n::PhoneObject cached_parsed_phone_; }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_PHONE_NUMBER_H_ diff --git a/components/autofill/browser/phone_number_i18n.cc b/components/autofill/browser/phone_number_i18n.cc index 8af00f2..eb1814f 100644 --- a/components/autofill/browser/phone_number_i18n.cc +++ b/components/autofill/browser/phone_number_i18n.cc @@ -16,6 +16,8 @@ using i18n::phonenumbers::PhoneNumber; using i18n::phonenumbers::PhoneNumberUtil; +namespace autofill { + namespace { std::string SanitizeRegion(const std::string& region, @@ -74,7 +76,7 @@ void FormatValidatedNumber(const PhoneNumber& number, } // namespace -namespace autofill_i18n { +namespace i18n { // Parses the number stored in |value| as it should be interpreted in the given // |region|, and stores the results into the remaining arguments. The |region| @@ -297,4 +299,5 @@ PhoneObject& PhoneObject::operator=(const PhoneObject& other) { return *this; } -} // namespace autofill_i18n +} // namespace i18n +} // namespace autofill diff --git a/components/autofill/browser/phone_number_i18n.h b/components/autofill/browser/phone_number_i18n.h index 2da7a4b..b6b68a6 100644 --- a/components/autofill/browser/phone_number_i18n.h +++ b/components/autofill/browser/phone_number_i18n.h @@ -18,8 +18,10 @@ class PhoneNumber; } } +namespace autofill { + // Utilities to process, normalize and compare international phone numbers. -namespace autofill_i18n { +namespace i18n { // Most of the following functions require |region| to operate. The |region| is // a ISO 3166 standard code ("US" for USA, "CZ" for Czech Republic, etc.). @@ -34,7 +36,7 @@ bool ParsePhoneNumber( base::string16* country_code, base::string16* city_code, base::string16* number, - i18n::phonenumbers::PhoneNumber* i18n_number) WARN_UNUSED_RESULT; + ::i18n::phonenumbers::PhoneNumber* i18n_number) WARN_UNUSED_RESULT; // Normalizes phone number, by changing digits in the extended fonts // (such as \xFF1x) into '0'-'9'. Also strips out non-digit characters. @@ -89,7 +91,8 @@ class PhoneObject { std::string region_; // The parsed number and its components. - scoped_ptr<i18n::phonenumbers::PhoneNumber> i18n_number_; + // + scoped_ptr< ::i18n::phonenumbers::PhoneNumber> i18n_number_; base::string16 city_code_; base::string16 country_code_; base::string16 number_; @@ -103,6 +106,7 @@ class PhoneObject { mutable base::string16 whole_number_; }; -} // namespace autofill_i18n +} // namespace i18n +} // namespace autofill #endif // COMPONENTS_AUTOFILL_BROWSER_PHONE_NUMBER_I18N_H_ diff --git a/components/autofill/browser/phone_number_i18n_unittest.cc b/components/autofill/browser/phone_number_i18n_unittest.cc index 4872a35..ddb6868 100644 --- a/components/autofill/browser/phone_number_i18n_unittest.cc +++ b/components/autofill/browser/phone_number_i18n_unittest.cc @@ -10,12 +10,15 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/libphonenumber/src/phonenumber_api.h" -using autofill_i18n::NormalizePhoneNumber; -using autofill_i18n::ParsePhoneNumber; -using autofill_i18n::ConstructPhoneNumber; -using autofill_i18n::PhoneNumbersMatch; using content::BrowserThread; +namespace autofill { + +using i18n::NormalizePhoneNumber; +using i18n::ParsePhoneNumber; +using i18n::ConstructPhoneNumber; +using i18n::PhoneNumbersMatch; + TEST(PhoneNumberI18NTest, NormalizePhoneNumber) { // "Large" digits. base::string16 phone1(UTF8ToUTF16( @@ -44,7 +47,7 @@ TEST(PhoneNumberI18NTest, ParsePhoneNumber) { base::string16 number; base::string16 city_code; base::string16 country_code; - i18n::phonenumbers::PhoneNumber unused_i18n_number; + ::i18n::phonenumbers::PhoneNumber unused_i18n_number; // Test for empty string. Should give back empty strings. base::string16 phone0; @@ -382,3 +385,5 @@ TEST(PhoneNumberI18NTest, PhoneNumbersMatch) { "US", "en-US")); } + +} // namespace autofill diff --git a/components/autofill/browser/phone_number_unittest.cc b/components/autofill/browser/phone_number_unittest.cc index e82e14d..2f561e9 100644 --- a/components/autofill/browser/phone_number_unittest.cc +++ b/components/autofill/browser/phone_number_unittest.cc @@ -10,6 +10,8 @@ #include "components/autofill/browser/phone_number_i18n.h" #include "testing/gtest/include/gtest/gtest.h" +namespace autofill { + TEST(PhoneNumberTest, Matcher) { AutofillProfile profile; profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); @@ -201,3 +203,5 @@ TEST(PhoneNumberTest, PhoneCombineHelper) { EXPECT_TRUE(number7.ParseNumber(AutofillProfile(), "en-US", &parsed_phone)); EXPECT_EQ(ASCIIToUTF16("(650) 234-5682"), parsed_phone); } + +} // namespace autofill diff --git a/components/autofill/browser/test_autofill_external_delegate.h b/components/autofill/browser/test_autofill_external_delegate.h index 81268d7..637bffd 100644 --- a/components/autofill/browser/test_autofill_external_delegate.h +++ b/components/autofill/browser/test_autofill_external_delegate.h @@ -7,10 +7,10 @@ #include "components/autofill/browser/autofill_external_delegate.h" -class AutofillManager; - namespace autofill { +class AutofillManager; + // Calls the required functions on the given external delegate to cause the // delegate to display a popup. void GenerateTestAutofillPopup( diff --git a/components/autofill/browser/validation_unittest.cc b/components/autofill/browser/validation_unittest.cc index b29d91b..939917d 100644 --- a/components/autofill/browser/validation_unittest.cc +++ b/components/autofill/browser/validation_unittest.cc @@ -7,6 +7,7 @@ #include "components/autofill/browser/validation.h" #include "testing/gtest/include/gtest/gtest.h" +namespace autofill { namespace { struct ExpirationDate { @@ -158,3 +159,5 @@ TEST(AutofillValidation, IsValidCreditCardSecurityCodeWithNumber) { EXPECT_FALSE(autofill::IsValidCreditCardSecurityCode( ASCIIToUTF16(kAmericanExpressCVC), ASCIIToUTF16(kInvalidNumbers[0]))); } + +} // namespace autofill diff --git a/components/autofill/browser/wallet/instrument.h b/components/autofill/browser/wallet/instrument.h index cb23d85..123b1cf 100644 --- a/components/autofill/browser/wallet/instrument.h +++ b/components/autofill/browser/wallet/instrument.h @@ -10,14 +10,15 @@ #include "base/memory/scoped_ptr.h" #include "base/string16.h" -class AutofillProfile; -class CreditCard; - namespace base { class DictionaryValue; } namespace autofill { + +class AutofillProfile; +class CreditCard; + namespace wallet { class Address; diff --git a/components/autofill/browser/wallet/wallet_address.h b/components/autofill/browser/wallet/wallet_address.h index 0b4bf36..937553e 100644 --- a/components/autofill/browser/wallet/wallet_address.h +++ b/components/autofill/browser/wallet/wallet_address.h @@ -12,13 +12,14 @@ #include "base/string16.h" #include "components/autofill/browser/field_types.h" -class AutofillProfile; - namespace base { class DictionaryValue; } namespace autofill { + +class AutofillProfile; + namespace wallet { // TODO(ahutter): This address is a lot like diff --git a/components/autofill/browser/wallet/wallet_service_url.cc b/components/autofill/browser/wallet/wallet_service_url.cc index 5e27a27..e1d9ed2 100644 --- a/components/autofill/browser/wallet/wallet_service_url.cc +++ b/components/autofill/browser/wallet/wallet_service_url.cc @@ -13,6 +13,7 @@ #include "googleurl/src/gurl.h" #include "net/base/url_util.h" +namespace autofill { namespace { const char kProdWalletServiceUrl[] = "https://wallet.google.com/"; @@ -61,9 +62,8 @@ GURL GetBaseSecureUrl() { return GURL(kSandboxWalletSecureServiceUrl); } -} // anonymous namespace +} // namespace -namespace autofill { namespace wallet { GURL GetGetWalletItemsUrl() { diff --git a/components/autofill/browser/webdata/autofill_change.cc b/components/autofill/browser/webdata/autofill_change.cc index 0b58602..6de7986 100644 --- a/components/autofill/browser/webdata/autofill_change.cc +++ b/components/autofill/browser/webdata/autofill_change.cc @@ -7,6 +7,8 @@ #include "components/autofill/browser/autofill_profile.h" #include "components/autofill/browser/credit_card.h" +namespace autofill { + AutofillChange::AutofillChange(Type type, const AutofillKey& key) : GenericAutofillChange<AutofillKey>(type, key) { } @@ -32,3 +34,5 @@ bool AutofillProfileChange::operator==( key() == change.key() && (type() != REMOVE) ? *profile() == *change.profile() : true; } + +} // namespace autofill diff --git a/components/autofill/browser/webdata/autofill_change.h b/components/autofill/browser/webdata/autofill_change.h index 386f540..215313e 100644 --- a/components/autofill/browser/webdata/autofill_change.h +++ b/components/autofill/browser/webdata/autofill_change.h @@ -9,6 +9,8 @@ #include "components/autofill/browser/webdata/autofill_entry.h" +namespace autofill { + class AutofillProfile; class CreditCard; @@ -69,4 +71,6 @@ class AutofillProfileChange : public GenericAutofillChange<std::string> { const AutofillProfile* profile_; }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_CHANGE_H__ diff --git a/components/autofill/browser/webdata/autofill_entry.cc b/components/autofill/browser/webdata/autofill_entry.cc index 4d47790..6d7d538 100644 --- a/components/autofill/browser/webdata/autofill_entry.cc +++ b/components/autofill/browser/webdata/autofill_entry.cc @@ -10,6 +10,7 @@ #include "base/logging.h" #include "base/utf_string_conversions.h" +namespace autofill { namespace { // The period after which Autofill entries should expire in days. @@ -124,3 +125,5 @@ bool AutofillEntry::CullTimeStamps(const std::vector<base::Time>& source, return true; } + +} // namespace autofill diff --git a/components/autofill/browser/webdata/autofill_entry.h b/components/autofill/browser/webdata/autofill_entry.h index 24f2ffa..6f21031 100644 --- a/components/autofill/browser/webdata/autofill_entry.h +++ b/components/autofill/browser/webdata/autofill_entry.h @@ -12,6 +12,8 @@ #include "base/string16.h" #include "base/time.h" +namespace autofill { + class AutofillKey { public: AutofillKey(); @@ -68,4 +70,6 @@ class AutofillEntry { bool timestamps_culled_; }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_ENTRY_H__ diff --git a/components/autofill/browser/webdata/autofill_entry_unittest.cc b/components/autofill/browser/webdata/autofill_entry_unittest.cc index c5940bb..4da7a8f 100644 --- a/components/autofill/browser/webdata/autofill_entry_unittest.cc +++ b/components/autofill/browser/webdata/autofill_entry_unittest.cc @@ -9,6 +9,8 @@ #include "components/autofill/browser/webdata/autofill_entry.h" #include "testing/gtest/include/gtest/gtest.h" +namespace autofill { + const unsigned int kMaxAutofillTimeStamps = 2; TEST(AutofillEntryTest, NoCulling) { @@ -76,3 +78,5 @@ TEST(AutofillEntryTest, CullByTime) { EXPECT_TRUE(entry_outside_the_limits.IsExpired()); EXPECT_TRUE(entry_outside_the_limits.timestamps_culled()); } + +} // namespace autofill diff --git a/components/autofill/browser/webdata/autofill_table.cc b/components/autofill/browser/webdata/autofill_table.cc index 4078891..3225d92 100644 --- a/components/autofill/browser/webdata/autofill_table.cc +++ b/components/autofill/browser/webdata/autofill_table.cc @@ -32,6 +32,7 @@ using base::Time; +namespace autofill { namespace { typedef std::vector<Tuple3<int64, base::string16, base::string16> > @@ -2050,3 +2051,5 @@ bool AutofillTable::MigrateToVersion37MergeAndCullOlderProfiles() { return true; } + +} // namespace autofill diff --git a/components/autofill/browser/webdata/autofill_table.h b/components/autofill/browser/webdata/autofill_table.h index 5828a62..37107c1 100644 --- a/components/autofill/browser/webdata/autofill_table.h +++ b/components/autofill/browser/webdata/autofill_table.h @@ -12,19 +12,22 @@ #include "base/string16.h" #include "components/webdata/common/web_database_table.h" +class WebDatabase; + +namespace base { +class Time; +} + +namespace autofill { + class AutofillChange; class AutofillEntry; class AutofillProfile; class AutofillTableTest; class CreditCard; -class WebDatabase; struct FormFieldData; -namespace base { -class Time; -} - // This class manages the various Autofill tables within the SQLite database // passed to the constructor. It expects the following schemas: // @@ -364,4 +367,6 @@ class AutofillTable : public WebDatabaseTable { DISALLOW_COPY_AND_ASSIGN(AutofillTable); }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_TABLE_H_ diff --git a/components/autofill/browser/webdata/autofill_table_unittest.cc b/components/autofill/browser/webdata/autofill_table_unittest.cc index 1b19489..e4d5138 100644 --- a/components/autofill/browser/webdata/autofill_table_unittest.cc +++ b/components/autofill/browser/webdata/autofill_table_unittest.cc @@ -26,6 +26,8 @@ using base::Time; using base::TimeDelta; +namespace autofill { + // So we can compare AutofillKeys with EXPECT_EQ(). std::ostream& operator<<(std::ostream& os, const AutofillKey& key) { return os << UTF16ToASCII(key.name()) << ", " << UTF16ToASCII(key.value()); @@ -1326,3 +1328,5 @@ TEST_F(AutofillTableTest, Autofill_GetAllAutofillEntries_TwoSame) { EXPECT_EQ(0U, expected_entries.size()); } + +} // namespace autofill diff --git a/components/autofill/browser/webdata/autofill_webdata.h b/components/autofill/browser/webdata/autofill_webdata.h index 9576d0c..032649b 100644 --- a/components/autofill/browser/webdata/autofill_webdata.h +++ b/components/autofill/browser/webdata/autofill_webdata.h @@ -12,10 +12,13 @@ #include "base/string16.h" #include "components/webdata/common/web_data_service_base.h" -class AutofillProfile; -class CreditCard; class Profile; class WebDataServiceConsumer; + +namespace autofill { + +class AutofillProfile; +class CreditCard; struct FormFieldData; // Pure virtual interface for retrieving Autofill data. API users @@ -85,4 +88,6 @@ class AutofillWebData { const base::Time& delete_begin, const base::Time& delete_end) = 0; }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_H_ diff --git a/components/autofill/browser/webdata/autofill_webdata_service.cc b/components/autofill/browser/webdata/autofill_webdata_service.cc index c61e032..51ce686 100644 --- a/components/autofill/browser/webdata/autofill_webdata_service.cc +++ b/components/autofill/browser/webdata/autofill_webdata_service.cc @@ -20,6 +20,8 @@ using base::Bind; using base::Time; using content::BrowserThread; +namespace autofill { + // static void AutofillWebDataService::NotifyOfMultipleAutofillChanges( AutofillWebDataService* web_data_service) { @@ -458,3 +460,5 @@ void AutofillWebDataService::NotifyAutofillMultipleChangedOnUIThread() { ui_observer_list_, AutofillMultipleChanged()); } + +} // namespace autofill diff --git a/components/autofill/browser/webdata/autofill_webdata_service.h b/components/autofill/browser/webdata/autofill_webdata_service.h index 3907057..8cebaaa 100644 --- a/components/autofill/browser/webdata/autofill_webdata_service.h +++ b/components/autofill/browser/webdata/autofill_webdata_service.h @@ -16,17 +16,20 @@ #include "components/webdata/common/web_data_service_consumer.h" #include "components/webdata/common/web_database.h" -class AutofillChange; -class AutofillProfile; -class AutofillWebDataServiceObserverOnDBThread; -class AutofillWebDataServiceObserverOnUIThread; -class CreditCard; class WebDatabaseService; namespace content { class BrowserContext; } +namespace autofill { + +class AutofillChange; +class AutofillProfile; +class AutofillWebDataServiceObserverOnDBThread; +class AutofillWebDataServiceObserverOnUIThread; +class CreditCard; + // API for Autofill web data. class AutofillWebDataService : public AutofillWebData, public WebDataServiceBase { @@ -131,4 +134,6 @@ class AutofillWebDataService : public AutofillWebData, DISALLOW_COPY_AND_ASSIGN(AutofillWebDataService); }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_H_ diff --git a/components/autofill/browser/webdata/autofill_webdata_service_observer.h b/components/autofill/browser/webdata/autofill_webdata_service_observer.h index f6a6e43..efc3ee5 100644 --- a/components/autofill/browser/webdata/autofill_webdata_service_observer.h +++ b/components/autofill/browser/webdata/autofill_webdata_service_observer.h @@ -7,6 +7,8 @@ #include "components/autofill/browser/webdata/autofill_change.h" +namespace autofill { + class AutofillWebDataServiceObserverOnDBThread { public: // Called on DB thread whenever Autofill entries are changed. @@ -34,4 +36,6 @@ class AutofillWebDataServiceObserverOnUIThread { virtual ~AutofillWebDataServiceObserverOnUIThread() {} }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_BROWSER_WEBDATA_AUTOFILL_WEBDATA_SERVICE_OBSERVER_H_ diff --git a/components/autofill/browser/webdata/web_data_service_unittest.cc b/components/autofill/browser/webdata/web_data_service_unittest.cc index f62f560..ee7bd51 100644 --- a/components/autofill/browser/webdata/web_data_service_unittest.cc +++ b/components/autofill/browser/webdata/web_data_service_unittest.cc @@ -42,6 +42,8 @@ using testing::ElementsAreArray; using testing::Pointee; using testing::Property; +namespace autofill { + static const int kWebDataServiceTimeoutSeconds = 8; ACTION_P(SignalEvent, event) { @@ -530,3 +532,5 @@ TEST_F(WebDataServiceAutofillTest, AutofillRemoveModifiedBetween) { EXPECT_EQ(handle2, card_consumer2.handle()); ASSERT_EQ(0U, card_consumer2.result().size()); } + +} // namespace autofill diff --git a/components/autofill/common/autofill_constants.cc b/components/autofill/common/autofill_constants.cc index a5c70dc..f880882 100644 --- a/components/autofill/common/autofill_constants.cc +++ b/components/autofill/common/autofill_constants.cc @@ -6,7 +6,6 @@ #include "build/build_config.h" -namespace components { namespace autofill { const char kHelpURL[] = @@ -19,4 +18,3 @@ const char kHelpURL[] = const size_t kRequiredAutofillFields = 3; } // namespace autofill -} // namespace components diff --git a/components/autofill/common/autofill_constants.h b/components/autofill/common/autofill_constants.h index 5f40b3e..44dabd1 100644 --- a/components/autofill/common/autofill_constants.h +++ b/components/autofill/common/autofill_constants.h @@ -9,7 +9,6 @@ #include <stddef.h> // For size_t -namespace components { namespace autofill { // Help URL for the Autofill dialog. @@ -22,6 +21,5 @@ extern const char kHelpURL[]; extern const size_t kRequiredAutofillFields; } // namespace autofill -} // namespace components #endif // COMPONENTS_AUTOFILL_COMMON_AUTOFILL_CONSTANTS_H_ diff --git a/components/autofill/common/autofill_messages.h b/components/autofill/common/autofill_messages.h index 56fc84a..afab402 100644 --- a/components/autofill/common/autofill_messages.h +++ b/components/autofill/common/autofill_messages.h @@ -34,7 +34,7 @@ IPC_STRUCT_TRAITS_END() IPC_ENUM_TRAITS(autofill::WebElementDescriptor::RetrievalMethod) -IPC_STRUCT_TRAITS_BEGIN(FormFieldData) +IPC_STRUCT_TRAITS_BEGIN(autofill::FormFieldData) IPC_STRUCT_TRAITS_MEMBER(label) IPC_STRUCT_TRAITS_MEMBER(name) IPC_STRUCT_TRAITS_MEMBER(value) @@ -50,7 +50,7 @@ IPC_STRUCT_TRAITS_BEGIN(FormFieldData) IPC_STRUCT_TRAITS_MEMBER(option_contents) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(FormFieldDataPredictions) +IPC_STRUCT_TRAITS_BEGIN(autofill::FormFieldDataPredictions) IPC_STRUCT_TRAITS_MEMBER(field) IPC_STRUCT_TRAITS_MEMBER(signature) IPC_STRUCT_TRAITS_MEMBER(heuristic_type) @@ -58,7 +58,7 @@ IPC_STRUCT_TRAITS_BEGIN(FormFieldDataPredictions) IPC_STRUCT_TRAITS_MEMBER(overall_type) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(FormData) +IPC_STRUCT_TRAITS_BEGIN(autofill::FormData) IPC_STRUCT_TRAITS_MEMBER(name) IPC_STRUCT_TRAITS_MEMBER(method) IPC_STRUCT_TRAITS_MEMBER(origin) @@ -67,14 +67,14 @@ IPC_STRUCT_TRAITS_BEGIN(FormData) IPC_STRUCT_TRAITS_MEMBER(fields) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(FormDataPredictions) +IPC_STRUCT_TRAITS_BEGIN(autofill::FormDataPredictions) IPC_STRUCT_TRAITS_MEMBER(data) IPC_STRUCT_TRAITS_MEMBER(signature) IPC_STRUCT_TRAITS_MEMBER(experiment_id) IPC_STRUCT_TRAITS_MEMBER(fields) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(PasswordFormFillData) +IPC_STRUCT_TRAITS_BEGIN(autofill::PasswordFormFillData) IPC_STRUCT_TRAITS_MEMBER(basic_data) IPC_STRUCT_TRAITS_MEMBER(additional_logins) IPC_STRUCT_TRAITS_MEMBER(wait_for_username) @@ -100,19 +100,19 @@ IPC_MESSAGE_ROUTED5(AutofillMsg_SuggestionsReturned, // Autofill form data. IPC_MESSAGE_ROUTED2(AutofillMsg_FormDataFilled, int /* id of the request message */, - FormData /* form data */) + autofill::FormData /* form data */) // Fill a password form and prepare field autocomplete for multiple // matching logins. Lets the renderer know if it should disable the popup // because the browser process will own the popup UI. IPC_MESSAGE_ROUTED2(AutofillMsg_FillPasswordForm, - PasswordFormFillData, /* the fill form data*/ + autofill::PasswordFormFillData, /* the fill form data*/ bool /* disable popup */ ) // Send the heuristic and server field type predictions to the renderer. IPC_MESSAGE_ROUTED1( AutofillMsg_FieldTypePredictionsAvailable, - std::vector<FormDataPredictions> /* forms */) + std::vector<autofill::FormDataPredictions> /* forms */) // Tells the renderer that the next form will be filled for real. IPC_MESSAGE_ROUTED0(AutofillMsg_SetAutofillActionFill) @@ -157,12 +157,12 @@ IPC_MESSAGE_ROUTED1(AutofillMsg_FormNotBlacklisted, // autocomplete with the |form_data| values input by the user. IPC_MESSAGE_ROUTED2(AutofillMsg_RequestAutocompleteResult, WebKit::WebFormElement::AutocompleteResult /* result */, - FormData /* form_data */) + autofill::FormData /* form_data */) // Sent when a page should be filled using Autocheckout. This happens when the // Autofill server hints that a page is Autocheckout enabled. IPC_MESSAGE_ROUTED2(AutofillMsg_FillFormsAndClick, - std::vector<FormData> /* form_data */, + std::vector<autofill::FormData> /* form_data */, autofill::WebElementDescriptor /* element_descriptor */) // Sent when the current page is whitelisted for Autocheckout. @@ -176,7 +176,7 @@ IPC_MESSAGE_ROUTED0(AutofillMsg_WhitelistedForAutocheckout) // Notification that forms have been seen that are candidates for // filling/submitting by the AutofillManager. IPC_MESSAGE_ROUTED3(AutofillHostMsg_FormsSeen, - std::vector<FormData> /* forms */, + std::vector<autofill::FormData> /* forms */, base::TimeTicks /* timestamp */, bool /* has_more_forms */) @@ -192,13 +192,13 @@ IPC_MESSAGE_ROUTED1(AutofillHostMsg_PasswordFormsRendered, // Notification that a form has been submitted. The user hit the button. IPC_MESSAGE_ROUTED2(AutofillHostMsg_FormSubmitted, - FormData /* form */, + autofill::FormData /* form */, base::TimeTicks /* timestamp */) // Notification that a form field's value has changed. IPC_MESSAGE_ROUTED3(AutofillHostMsg_TextFieldDidChange, - FormData /* the form */, - FormFieldData /* the form field */, + autofill::FormData /* the form */, + autofill::FormFieldData /* the form field */, base::TimeTicks /* timestamp */) // Shows the Autocheckout bubble if the conditions are right. @@ -210,8 +210,8 @@ IPC_MESSAGE_ROUTED3(AutofillHostMsg_MaybeShowAutocheckoutBubble, // Queries the browser for Autofill suggestions for a form input field. IPC_MESSAGE_ROUTED5(AutofillHostMsg_QueryFormFieldAutofill, int /* id of this message */, - FormData /* the form */, - FormFieldData /* the form field */, + autofill::FormData /* the form */, + autofill::FormFieldData /* the form field */, gfx::RectF /* input field bounds, window-relative */, bool /* display warning if autofill disabled */) @@ -223,8 +223,8 @@ IPC_MESSAGE_ROUTED1(AutofillHostMsg_DidShowAutofillSuggestions, // profile data. IPC_MESSAGE_ROUTED4(AutofillHostMsg_FillAutofillFormData, int /* id of this message */, - FormData /* the form */, - FormFieldData /* the form field */, + autofill::FormData /* the form */, + autofill::FormFieldData /* the form field */, int /* profile unique ID */) // Sent when a form is previewed with Autofill suggestions. @@ -236,7 +236,7 @@ IPC_MESSAGE_ROUTED1(AutofillHostMsg_DidFillAutofillFormData, // Sent when a form receives a request to do interactive autocomplete. IPC_MESSAGE_ROUTED2(AutofillHostMsg_RequestAutocomplete, - FormData /* form_data */, + autofill::FormData /* form_data */, GURL /* frame_url */) // Instructs the browser to remove the specified Autocomplete entry from the @@ -270,13 +270,13 @@ IPC_MESSAGE_ROUTED3(AutofillHostMsg_ShowPasswordGenerationPopup, // Instruct the browser that a password mapping has been found for a field. IPC_MESSAGE_ROUTED2(AutofillHostMsg_AddPasswordFormMapping, - FormFieldData, /* the user name field */ - PasswordFormFillData /* password pairings */) + autofill::FormFieldData, /* the user name field */ + autofill::PasswordFormFillData /* password pairings */) // Instruct the browser to show a popup with the following suggestions from the // password manager. IPC_MESSAGE_ROUTED3(AutofillHostMsg_ShowPasswordSuggestions, - FormFieldData /* the form field */, + autofill::FormFieldData /* the form field */, gfx::RectF /* input field bounds, window-relative */, std::vector<base::string16> /* suggestions */) diff --git a/components/autofill/common/autofill_pref_names.cc b/components/autofill/common/autofill_pref_names.cc index 5f86a97..7d437b6 100644 --- a/components/autofill/common/autofill_pref_names.cc +++ b/components/autofill/common/autofill_pref_names.cc @@ -4,6 +4,7 @@ #include "components/autofill/common/autofill_pref_names.h" +namespace autofill { namespace prefs { // Boolean that is true when auxiliary Autofill profiles are enabled. @@ -24,3 +25,4 @@ const char kAutofillPositiveUploadRate[] = "autofill.positive_upload_rate"; const char kPasswordGenerationEnabled[] = "password_generation.enabled"; } // namespace prefs +} // namespace autofill diff --git a/components/autofill/common/autofill_pref_names.h b/components/autofill/common/autofill_pref_names.h index 083bbe9..c67ac1a 100644 --- a/components/autofill/common/autofill_pref_names.h +++ b/components/autofill/common/autofill_pref_names.h @@ -5,6 +5,7 @@ #ifndef COMPONENTS_AUTOFILL_COMMON_AUTOFILL_PREF_NAMES_H_ #define COMPONENTS_AUTOFILL_COMMON_AUTOFILL_PREF_NAMES_H_ +namespace autofill { namespace prefs { // Alphabetical list of preference names specific to the Autofill @@ -16,5 +17,6 @@ extern const char kAutofillPositiveUploadRate[]; extern const char kPasswordGenerationEnabled[]; } // namespace prefs +} // namespace autofill #endif // COMPONENTS_AUTOFILL_COMMON_AUTOFILL_PREF_NAMES_H_ diff --git a/components/autofill/common/autofill_switches.cc b/components/autofill/common/autofill_switches.cc index 933dc8d..0f38b17 100644 --- a/components/autofill/common/autofill_switches.cc +++ b/components/autofill/common/autofill_switches.cc @@ -4,6 +4,7 @@ #include "components/autofill/common/autofill_switches.h" +namespace autofill { namespace switches { // Flag used to tell Chrome the base url of the Autofill service. @@ -32,3 +33,4 @@ const char kWalletServiceUrl[] = "wallet-service-url"; const char kWalletServiceUseProd[] = "wallet-service-use-prod"; } // namespace switches +} // namespace autofill diff --git a/components/autofill/common/autofill_switches.h b/components/autofill/common/autofill_switches.h index f127ca9..76b858b 100644 --- a/components/autofill/common/autofill_switches.h +++ b/components/autofill/common/autofill_switches.h @@ -5,6 +5,7 @@ #ifndef COMPONENTS_AUTOFILL_COMMON_AUTOFILL_SWITCHES_H_ #define COMPONENTS_AUTOFILL_COMMON_AUTOFILL_SWITCHES_H_ +namespace autofill { namespace switches { // All switches in alphabetical order. The switches should be documented @@ -18,5 +19,6 @@ extern const char kWalletServiceUrl[]; extern const char kWalletServiceUseProd[]; } // namespace switches +} // namespace autofill #endif // COMPONENTS_AUTOFILL_COMMON_AUTOFILL_SWITCHES_H_ diff --git a/components/autofill/common/form_data.cc b/components/autofill/common/form_data.cc index c4ebbc3..569d7e1 100644 --- a/components/autofill/common/form_data.cc +++ b/components/autofill/common/form_data.cc @@ -6,6 +6,8 @@ #include "base/string_util.h" +namespace autofill { + FormData::FormData() : user_submitted(false) { } @@ -36,3 +38,5 @@ bool FormData::operator==(const FormData& form) const { bool FormData::operator!=(const FormData& form) const { return !operator==(form); } + +} // namespace autofill diff --git a/components/autofill/common/form_data.h b/components/autofill/common/form_data.h index 8d683be..3a16729 100644 --- a/components/autofill/common/form_data.h +++ b/components/autofill/common/form_data.h @@ -12,6 +12,8 @@ #include "content/public/common/ssl_status.h" #include "googleurl/src/gurl.h" +namespace autofill { + // Holds information about a form to be filled and/or submitted. struct FormData { FormData(); @@ -38,4 +40,6 @@ struct FormData { content::SSLStatus ssl_status; }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_COMMON_FORM_DATA_H__ diff --git a/components/autofill/common/form_data_predictions.cc b/components/autofill/common/form_data_predictions.cc index 184d19f..a59f58a 100644 --- a/components/autofill/common/form_data_predictions.cc +++ b/components/autofill/common/form_data_predictions.cc @@ -4,6 +4,8 @@ #include "components/autofill/common/form_data_predictions.h" +namespace autofill { + FormDataPredictions::FormDataPredictions() { } @@ -16,3 +18,5 @@ FormDataPredictions::FormDataPredictions(const FormDataPredictions& other) FormDataPredictions::~FormDataPredictions() { } + +} // namespace autofill diff --git a/components/autofill/common/form_data_predictions.h b/components/autofill/common/form_data_predictions.h index 8196402..3e4c5bb 100644 --- a/components/autofill/common/form_data_predictions.h +++ b/components/autofill/common/form_data_predictions.h @@ -11,6 +11,8 @@ #include "components/autofill/common/form_data.h" #include "components/autofill/common/form_field_data_predictions.h" +namespace autofill { + // Holds information about a form to be filled and/or submitted. struct FormDataPredictions { // Data for this form. @@ -27,4 +29,6 @@ struct FormDataPredictions { ~FormDataPredictions(); }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_COMMON_FORM_DATA_PREDICTIONS_H__ diff --git a/components/autofill/common/form_field_data.cc b/components/autofill/common/form_field_data.cc index d78966d..b6ea38a 100644 --- a/components/autofill/common/form_field_data.cc +++ b/components/autofill/common/form_field_data.cc @@ -7,6 +7,8 @@ #include "base/string_util.h" #include "base/utf_string_conversions.h" +namespace autofill { + FormFieldData::FormFieldData() : max_length(0), is_autofilled(false), @@ -64,3 +66,5 @@ std::ostream& operator<<(std::ostream& os, const FormFieldData& field) { << " " << (field.should_autocomplete ? "true" : "false"); } + +} // namespace autofill diff --git a/components/autofill/common/form_field_data.h b/components/autofill/common/form_field_data.h index f77c85d..e1272ca 100644 --- a/components/autofill/common/form_field_data.h +++ b/components/autofill/common/form_field_data.h @@ -9,6 +9,8 @@ #include "base/string16.h" +namespace autofill { + // Stores information about a field in a form. struct FormFieldData { FormFieldData(); @@ -59,4 +61,7 @@ std::ostream& operator<<(std::ostream& os, const FormFieldData& field); EXPECT_EQ(expected.is_checkable, actual.is_checkable); \ } while (0) +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_COMMON_FORM_FIELD_DATA_H_ + diff --git a/components/autofill/common/form_field_data_predictions.cc b/components/autofill/common/form_field_data_predictions.cc index 3c04564..c83eb53 100644 --- a/components/autofill/common/form_field_data_predictions.cc +++ b/components/autofill/common/form_field_data_predictions.cc @@ -4,6 +4,8 @@ #include "components/autofill/common/form_field_data_predictions.h" +namespace autofill { + FormFieldDataPredictions::FormFieldDataPredictions() { } @@ -18,3 +20,5 @@ FormFieldDataPredictions::FormFieldDataPredictions( FormFieldDataPredictions::~FormFieldDataPredictions() { } + +} // namespace autofill diff --git a/components/autofill/common/form_field_data_predictions.h b/components/autofill/common/form_field_data_predictions.h index 3d0b982..adff09c 100644 --- a/components/autofill/common/form_field_data_predictions.h +++ b/components/autofill/common/form_field_data_predictions.h @@ -10,6 +10,8 @@ #include "components/autofill/common/form_field_data.h" +namespace autofill { + // Stores information about a field in a form. struct FormFieldDataPredictions { FormFieldDataPredictions(); @@ -23,4 +25,6 @@ struct FormFieldDataPredictions { std::string overall_type; }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_COMMON_FORM_FIELD_DATA_PREDICTIONS_H_ diff --git a/components/autofill/common/password_form_fill_data.cc b/components/autofill/common/password_form_fill_data.cc index e6456e6..535725c 100644 --- a/components/autofill/common/password_form_fill_data.cc +++ b/components/autofill/common/password_form_fill_data.cc @@ -7,6 +7,8 @@ #include "base/logging.h" #include "components/autofill/common/form_field_data.h" +namespace autofill { + PasswordFormFillData::PasswordFormFillData() : wait_for_username(false) { } @@ -43,3 +45,5 @@ void InitPasswordFormFillData( result->additional_logins[iter->first] = iter->second->password_value; } } + +} // namespace autofill diff --git a/components/autofill/common/password_form_fill_data.h b/components/autofill/common/password_form_fill_data.h index 90a5ebd..b0de41b 100644 --- a/components/autofill/common/password_form_fill_data.h +++ b/components/autofill/common/password_form_fill_data.h @@ -11,6 +11,8 @@ #include "components/autofill/common/form_data.h" #include "content/public/common/password_form.h" +namespace autofill { + // Structure used for autofilling password forms. // basic_data identifies the HTML form on the page and preferred username/ // password for login, while @@ -43,4 +45,6 @@ void InitPasswordFormFillData( bool wait_for_username_before_autofill, PasswordFormFillData* result); +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_COMMON_PASSWORD_FORM_FILL_DATA_H__ diff --git a/components/autofill/common/password_generation_util.cc b/components/autofill/common/password_generation_util.cc index 43ecb19..31118f83 100644 --- a/components/autofill/common/password_generation_util.cc +++ b/components/autofill/common/password_generation_util.cc @@ -6,6 +6,7 @@ #include "base/metrics/histogram.h" +namespace autofill { namespace password_generation { PasswordGenerationActions::PasswordGenerationActions() @@ -38,3 +39,4 @@ void LogPasswordGenerationEvent(PasswordGenerationEvent event) { } } // namespace password_generation +} // namespace autofill diff --git a/components/autofill/common/password_generation_util.h b/components/autofill/common/password_generation_util.h index e7ad8a5..a855958 100644 --- a/components/autofill/common/password_generation_util.h +++ b/components/autofill/common/password_generation_util.h @@ -5,6 +5,7 @@ #ifndef COMPONENTS_AUTOFILL_COMMON_PASSWORD_GENERATION_UTIL_H_ #define COMPONENTS_AUTOFILL_COMMON_PASSWORD_GENERATION_UTIL_H_ +namespace autofill { namespace password_generation { // Enumerates various events related to the password generation process. @@ -71,5 +72,6 @@ enum UserAction { }; } // namespace password_generation +} // namespace autofill #endif // COMPONENTS_AUTOFILL_COMMON_PASSWORD_GENERATION_UTIL_H_ diff --git a/components/autofill/common/web_element_descriptor.cc b/components/autofill/common/web_element_descriptor.cc index 8b897b8..b828778 100644 --- a/components/autofill/common/web_element_descriptor.cc +++ b/components/autofill/common/web_element_descriptor.cc @@ -4,6 +4,9 @@ #include "components/autofill/common/web_element_descriptor.h" +namespace autofill { + autofill::WebElementDescriptor::WebElementDescriptor() : retrieval_method(NONE) {} +} // namespace autofill diff --git a/components/autofill/renderer/autofill_agent.cc b/components/autofill/renderer/autofill_agent.cc index cea773d..acf4973 100644 --- a/components/autofill/renderer/autofill_agent.cc +++ b/components/autofill/renderer/autofill_agent.cc @@ -41,7 +41,6 @@ #include "ui/base/keycodes/keyboard_codes.h" #include "ui/base/l10n/l10n_util.h" -using components::autofill::kRequiredAutofillFields; using WebKit::WebAutofillClient; using WebKit::WebFormControlElement; using WebKit::WebFormElement; diff --git a/components/autofill/renderer/autofill_agent.h b/components/autofill/renderer/autofill_agent.h index 998125b..0e93043 100644 --- a/components/autofill/renderer/autofill_agent.h +++ b/components/autofill/renderer/autofill_agent.h @@ -20,8 +20,6 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" -struct FormFieldData; - namespace WebKit { class WebNode; class WebView; @@ -29,6 +27,8 @@ class WebView; namespace autofill { +struct FormData; +struct FormFieldData; struct WebElementDescriptor; class PasswordAutofillAgent; diff --git a/components/autofill/renderer/form_autofill_util.cc b/components/autofill/renderer/form_autofill_util.cc index 2d255df..64e2f81 100644 --- a/components/autofill/renderer/form_autofill_util.cc +++ b/components/autofill/renderer/form_autofill_util.cc @@ -45,14 +45,9 @@ using WebKit::WebSelectElement; using WebKit::WebString; using WebKit::WebVector; +namespace autofill { namespace { -using autofill::ExtractAutofillableElements; -using autofill::IsAutofillableInputElement; -using autofill::IsCheckableElement; -using autofill::IsSelectElement; -using autofill::IsTextInput; - // The maximum length allowed for form data. const size_t kMaxDataLength = 1024; @@ -467,7 +462,7 @@ void ForEachMatchingFormField(const WebFormElement& form_element, bool force_override, Callback callback) { std::vector<WebFormControlElement> control_elements; - ExtractAutofillableElements(form_element, autofill::REQUIRE_AUTOCOMPLETE, + ExtractAutofillableElements(form_element, REQUIRE_AUTOCOMPLETE, &control_elements); if (control_elements.size() != data.fields.size()) { @@ -574,13 +569,13 @@ void PreviewFormField(const FormFieldData& data, } std::string RetrievalMethodToString( - const autofill::WebElementDescriptor::RetrievalMethod& method) { + const WebElementDescriptor::RetrievalMethod& method) { switch (method) { - case autofill::WebElementDescriptor::CSS_SELECTOR: + case WebElementDescriptor::CSS_SELECTOR: return "CSS_SELECTOR"; - case autofill::WebElementDescriptor::ID: + case WebElementDescriptor::ID: return "ID"; - case autofill::WebElementDescriptor::NONE: + case WebElementDescriptor::NONE: return "NONE"; } NOTREACHED(); @@ -589,8 +584,6 @@ std::string RetrievalMethodToString( } // namespace -namespace autofill { - const size_t kMaxParseableFields = 100; // All text fields, including password fields, should be extracted. diff --git a/components/autofill/renderer/form_cache.cc b/components/autofill/renderer/form_cache.cc index 343998a..27441ad 100644 --- a/components/autofill/renderer/form_cache.cc +++ b/components/autofill/renderer/form_cache.cc @@ -23,7 +23,6 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebSelectElement.h" #include "ui/base/l10n/l10n_util.h" -using components::autofill::kRequiredAutofillFields; using WebKit::WebDocument; using WebKit::WebFormControlElement; using WebKit::WebFormElement; diff --git a/components/autofill/renderer/form_cache.h b/components/autofill/renderer/form_cache.h index eb1d84a..b1ec311 100644 --- a/components/autofill/renderer/form_cache.h +++ b/components/autofill/renderer/form_cache.h @@ -11,9 +11,6 @@ #include "base/string16.h" -struct FormData; -struct FormDataPredictions; - namespace WebKit { class WebDocument; class WebFormElement; @@ -24,6 +21,9 @@ class WebSelectElement; namespace autofill { +struct FormData; +struct FormDataPredictions; + // Manages the forms in a RenderView. class FormCache { public: diff --git a/components/autofill/renderer/page_click_listener.h b/components/autofill/renderer/page_click_listener.h index 83c41d4..6a29f1b 100644 --- a/components/autofill/renderer/page_click_listener.h +++ b/components/autofill/renderer/page_click_listener.h @@ -9,6 +9,8 @@ namespace WebKit { class WebInputElement; } +namespace autofill { + // Interface that should be implemented by classes interested in getting // notifications for clicks on a page. // Register on the PageListenerTracker object. @@ -33,4 +35,6 @@ class PageClickListener { virtual ~PageClickListener() {} }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_RENDERER_PAGE_CLICK_LISTENER_H_ diff --git a/components/autofill/renderer/page_click_tracker.cc b/components/autofill/renderer/page_click_tracker.cc index 21e28a2..0561684 100644 --- a/components/autofill/renderer/page_click_tracker.cc +++ b/components/autofill/renderer/page_click_tracker.cc @@ -56,6 +56,8 @@ bool DidSelectedTextFieldLoseFocus(const WebNode& newly_clicked_node) { } // namespace +namespace autofill { + PageClickTracker::PageClickTracker(content::RenderView* render_view) : content::RenderViewObserver(render_view), was_focused_(false) { @@ -158,3 +160,5 @@ void PageClickTracker::HandleTextFieldMaybeLosingFocus( break; } } + +} // namespace autofill diff --git a/components/autofill/renderer/page_click_tracker.h b/components/autofill/renderer/page_click_tracker.h index e4aedb2..b95259a3 100644 --- a/components/autofill/renderer/page_click_tracker.h +++ b/components/autofill/renderer/page_click_tracker.h @@ -13,6 +13,8 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEventListener.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" +namespace autofill { + class PageClickListener; @@ -71,4 +73,6 @@ class PageClickTracker : public content::RenderViewObserver, DISALLOW_COPY_AND_ASSIGN(PageClickTracker); }; +} // namespace autofill + #endif // COMPONENTS_AUTOFILL_RENDERER_PAGE_CLICK_TRACKER_H_ diff --git a/components/autofill/renderer/password_autofill_agent.cc b/components/autofill/renderer/password_autofill_agent.cc index fe3564f..0fcd1b0 100644 --- a/components/autofill/renderer/password_autofill_agent.cc +++ b/components/autofill/renderer/password_autofill_agent.cc @@ -25,6 +25,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" #include "ui/base/keycodes/keyboard_codes.h" +namespace autofill { namespace { // The size above which we stop triggering autocomplete. @@ -199,8 +200,6 @@ bool DoUsernamesMatch(const base::string16& username1, } // namespace -namespace autofill { - //////////////////////////////////////////////////////////////////////////////// // PasswordAutofillAgent, public: diff --git a/components/webdata/common/web_data_service_test_util.cc b/components/webdata/common/web_data_service_test_util.cc index 46d6292..950b56f 100644 --- a/components/webdata/common/web_data_service_test_util.cc +++ b/components/webdata/common/web_data_service_test_util.cc @@ -6,6 +6,8 @@ #include "components/autofill/browser/webdata/autofill_webdata_service.h" +using autofill::AutofillWebDataService; + MockWebDataServiceWrapperBase::MockWebDataServiceWrapperBase() { } diff --git a/components/webdata/common/web_data_service_test_util.h b/components/webdata/common/web_data_service_test_util.h index e037a15..e3ee512 100644 --- a/components/webdata/common/web_data_service_test_util.h +++ b/components/webdata/common/web_data_service_test_util.h @@ -57,16 +57,17 @@ class MockWebDataServiceWrapper : public MockWebDataServiceWrapperBase { public: MockWebDataServiceWrapper( scoped_refptr<WebDataService> fake_service, - scoped_refptr<AutofillWebDataService> fake_autofill); + scoped_refptr<autofill::AutofillWebDataService> fake_autofill); virtual ~MockWebDataServiceWrapper(); - virtual scoped_refptr<AutofillWebDataService> GetAutofillWebData() OVERRIDE; + virtual scoped_refptr<autofill::AutofillWebDataService> + GetAutofillWebData() OVERRIDE; virtual scoped_refptr<WebDataService> GetWebData() OVERRIDE; protected: - scoped_refptr<AutofillWebDataService> fake_autofill_web_data_; + scoped_refptr<autofill::AutofillWebDataService> fake_autofill_web_data_; scoped_refptr<WebDataService> fake_web_data_; private: diff --git a/components/webdata/common/web_database_migration_unittest.cc b/components/webdata/common/web_database_migration_unittest.cc index fad8510..64268fb 100644 --- a/components/webdata/common/web_database_migration_unittest.cc +++ b/components/webdata/common/web_database_migration_unittest.cc @@ -32,6 +32,9 @@ #include "sql/statement.h" #include "testing/gtest/include/gtest/gtest.h" +using autofill::AutofillProfile; +using autofill::AutofillTable; +using autofill::CreditCard; using base::Time; using content::BrowserThread; @@ -48,18 +51,19 @@ void AutofillProfile31FromStatement(const sql::Statement& s, DCHECK(date_modified); *label = s.ColumnString16(0); *unique_id = s.ColumnInt(1); - profile->SetRawInfo(NAME_FIRST, s.ColumnString16(2)); - profile->SetRawInfo(NAME_MIDDLE, s.ColumnString16(3)); - profile->SetRawInfo(NAME_LAST, s.ColumnString16(4)); - profile->SetRawInfo(EMAIL_ADDRESS, s.ColumnString16(5)); - profile->SetRawInfo(COMPANY_NAME, s.ColumnString16(6)); - profile->SetRawInfo(ADDRESS_HOME_LINE1, s.ColumnString16(7)); - profile->SetRawInfo(ADDRESS_HOME_LINE2, s.ColumnString16(8)); - profile->SetRawInfo(ADDRESS_HOME_CITY, s.ColumnString16(9)); - profile->SetRawInfo(ADDRESS_HOME_STATE, s.ColumnString16(10)); - profile->SetRawInfo(ADDRESS_HOME_ZIP, s.ColumnString16(11)); - profile->SetInfo(ADDRESS_HOME_COUNTRY, s.ColumnString16(12), "en-US"); - profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, s.ColumnString16(13)); + profile->SetRawInfo(autofill::NAME_FIRST, s.ColumnString16(2)); + profile->SetRawInfo(autofill::NAME_MIDDLE, s.ColumnString16(3)); + profile->SetRawInfo(autofill::NAME_LAST, s.ColumnString16(4)); + profile->SetRawInfo(autofill::EMAIL_ADDRESS, s.ColumnString16(5)); + profile->SetRawInfo(autofill::COMPANY_NAME, s.ColumnString16(6)); + profile->SetRawInfo(autofill::ADDRESS_HOME_LINE1, s.ColumnString16(7)); + profile->SetRawInfo(autofill::ADDRESS_HOME_LINE2, s.ColumnString16(8)); + profile->SetRawInfo(autofill::ADDRESS_HOME_CITY, s.ColumnString16(9)); + profile->SetRawInfo(autofill::ADDRESS_HOME_STATE, s.ColumnString16(10)); + profile->SetRawInfo(autofill::ADDRESS_HOME_ZIP, s.ColumnString16(11)); + profile->SetInfo( + autofill::ADDRESS_HOME_COUNTRY, s.ColumnString16(12), "en-US"); + profile->SetRawInfo(autofill::PHONE_HOME_WHOLE_NUMBER, s.ColumnString16(13)); *date_modified = s.ColumnInt64(15); profile->set_guid(s.ColumnString(16)); EXPECT_TRUE(base::IsValidGUID(profile->guid())); @@ -72,13 +76,14 @@ void AutofillProfile33FromStatement(const sql::Statement& s, DCHECK(date_modified); profile->set_guid(s.ColumnString(0)); EXPECT_TRUE(base::IsValidGUID(profile->guid())); - profile->SetRawInfo(COMPANY_NAME, s.ColumnString16(1)); - profile->SetRawInfo(ADDRESS_HOME_LINE1, s.ColumnString16(2)); - profile->SetRawInfo(ADDRESS_HOME_LINE2, s.ColumnString16(3)); - profile->SetRawInfo(ADDRESS_HOME_CITY, s.ColumnString16(4)); - profile->SetRawInfo(ADDRESS_HOME_STATE, s.ColumnString16(5)); - profile->SetRawInfo(ADDRESS_HOME_ZIP, s.ColumnString16(6)); - profile->SetInfo(ADDRESS_HOME_COUNTRY, s.ColumnString16(7), "en-US"); + profile->SetRawInfo(autofill::COMPANY_NAME, s.ColumnString16(1)); + profile->SetRawInfo(autofill::ADDRESS_HOME_LINE1, s.ColumnString16(2)); + profile->SetRawInfo(autofill::ADDRESS_HOME_LINE2, s.ColumnString16(3)); + profile->SetRawInfo(autofill::ADDRESS_HOME_CITY, s.ColumnString16(4)); + profile->SetRawInfo(autofill::ADDRESS_HOME_STATE, s.ColumnString16(5)); + profile->SetRawInfo(autofill::ADDRESS_HOME_ZIP, s.ColumnString16(6)); + profile->SetInfo( + autofill::ADDRESS_HOME_COUNTRY, s.ColumnString16(7), "en-US"); *date_modified = s.ColumnInt64(8); } @@ -95,10 +100,11 @@ void CreditCard31FromStatement(const sql::Statement& s, DCHECK(date_modified); *label = s.ColumnString16(0); *unique_id = s.ColumnInt(1); - credit_card->SetRawInfo(CREDIT_CARD_NAME, s.ColumnString16(2)); - credit_card->SetRawInfo(CREDIT_CARD_TYPE, s.ColumnString16(3)); - credit_card->SetRawInfo(CREDIT_CARD_EXP_MONTH, s.ColumnString16(5)); - credit_card->SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, s.ColumnString16(6)); + credit_card->SetRawInfo(autofill::CREDIT_CARD_NAME, s.ColumnString16(2)); + credit_card->SetRawInfo(autofill::CREDIT_CARD_TYPE, s.ColumnString16(3)); + credit_card->SetRawInfo(autofill::CREDIT_CARD_EXP_MONTH, s.ColumnString16(5)); + credit_card->SetRawInfo( + autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR, s.ColumnString16(6)); int encrypted_number_len = s.ColumnByteLength(10); if (encrypted_number_len) { encrypted_number->resize(encrypted_number_len); @@ -118,9 +124,10 @@ void CreditCard32FromStatement(const sql::Statement& s, DCHECK(date_modified); credit_card->set_guid(s.ColumnString(0)); EXPECT_TRUE(base::IsValidGUID(credit_card->guid())); - credit_card->SetRawInfo(CREDIT_CARD_NAME, s.ColumnString16(1)); - credit_card->SetRawInfo(CREDIT_CARD_EXP_MONTH, s.ColumnString16(2)); - credit_card->SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, s.ColumnString16(3)); + credit_card->SetRawInfo(autofill::CREDIT_CARD_NAME, s.ColumnString16(1)); + credit_card->SetRawInfo(autofill::CREDIT_CARD_EXP_MONTH, s.ColumnString16(2)); + credit_card->SetRawInfo( + autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR, s.ColumnString16(3)); int encrypted_number_len = s.ColumnByteLength(4); if (encrypted_number_len) { encrypted_number->resize(encrypted_number_len); @@ -811,20 +818,20 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion31ToCurrent) { EXPECT_NO_FATAL_FAILURE(AutofillProfile33FromStatement( s1, &profile_a, &profile_date_modified_a)); EXPECT_EQ(profile.guid(), profile_a.guid()); - EXPECT_EQ(profile.GetRawInfo(COMPANY_NAME), - profile_a.GetRawInfo(COMPANY_NAME)); - EXPECT_EQ(profile.GetRawInfo(ADDRESS_HOME_LINE1), - profile_a.GetRawInfo(ADDRESS_HOME_LINE1)); - EXPECT_EQ(profile.GetRawInfo(ADDRESS_HOME_LINE2), - profile_a.GetRawInfo(ADDRESS_HOME_LINE2)); - EXPECT_EQ(profile.GetRawInfo(ADDRESS_HOME_CITY), - profile_a.GetRawInfo(ADDRESS_HOME_CITY)); - EXPECT_EQ(profile.GetRawInfo(ADDRESS_HOME_STATE), - profile_a.GetRawInfo(ADDRESS_HOME_STATE)); - EXPECT_EQ(profile.GetRawInfo(ADDRESS_HOME_ZIP), - profile_a.GetRawInfo(ADDRESS_HOME_ZIP)); - EXPECT_EQ(profile.GetRawInfo(ADDRESS_HOME_COUNTRY), - profile_a.GetRawInfo(ADDRESS_HOME_COUNTRY)); + EXPECT_EQ(profile.GetRawInfo(autofill::COMPANY_NAME), + profile_a.GetRawInfo(autofill::COMPANY_NAME)); + EXPECT_EQ(profile.GetRawInfo(autofill::ADDRESS_HOME_LINE1), + profile_a.GetRawInfo(autofill::ADDRESS_HOME_LINE1)); + EXPECT_EQ(profile.GetRawInfo(autofill::ADDRESS_HOME_LINE2), + profile_a.GetRawInfo(autofill::ADDRESS_HOME_LINE2)); + EXPECT_EQ(profile.GetRawInfo(autofill::ADDRESS_HOME_CITY), + profile_a.GetRawInfo(autofill::ADDRESS_HOME_CITY)); + EXPECT_EQ(profile.GetRawInfo(autofill::ADDRESS_HOME_STATE), + profile_a.GetRawInfo(autofill::ADDRESS_HOME_STATE)); + EXPECT_EQ(profile.GetRawInfo(autofill::ADDRESS_HOME_ZIP), + profile_a.GetRawInfo(autofill::ADDRESS_HOME_ZIP)); + EXPECT_EQ(profile.GetRawInfo(autofill::ADDRESS_HOME_COUNTRY), + profile_a.GetRawInfo(autofill::ADDRESS_HOME_COUNTRY)); EXPECT_EQ(profile_date_modified, profile_date_modified_a); sql::Statement s2( |