autofill_helper.h revision 5821806d5e7f356e8fa4b058a389a808ea183019
1// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_AUTOFILL_HELPER_H_ 6#define CHROME_BROWSER_SYNC_TEST_INTEGRATION_AUTOFILL_HELPER_H_ 7 8#include <set> 9#include <string> 10#include <vector> 11 12#include "base/compiler_specific.h" 13#include "base/memory/ref_counted.h" 14#include "base/string16.h" 15#include "chrome/browser/sync/test/integration/sync_datatype_helper.h" 16 17class AutofillEntry; 18class AutofillKey; 19class AutofillProfile; 20class AutofillType; 21class CreditCard; 22class PersonalDataManager; 23class WebDataService; 24 25namespace autofill_helper { 26 27enum ProfileType { 28 PROFILE_MARION, 29 PROFILE_HOMER, 30 PROFILE_FRASIER, 31 PROFILE_NULL 32}; 33 34// Used to access the web data service within a particular sync profile. 35scoped_refptr<WebDataService> GetWebDataService(int index) WARN_UNUSED_RESULT; 36 37// Used to access the personal data manager within a particular sync profile. 38PersonalDataManager* GetPersonalDataManager(int index) WARN_UNUSED_RESULT; 39 40// Adds the form fields in |keys| to the WebDataService of sync profile 41// |profile|. 42void AddKeys(int profile, const std::set<AutofillKey>& keys); 43 44// Removes the form field in |key| from the WebDataService of sync profile 45// |profile|. 46void RemoveKey(int profile, const AutofillKey& key); 47 48// Removes all of the keys from the WebDataService of sync profile |profile|. 49void RemoveKeys(int profile); 50 51// Gets all the form fields in the WebDataService of sync profile |profile|. 52std::set<AutofillEntry> GetAllKeys(int profile) WARN_UNUSED_RESULT; 53 54// Compares the form fields in the WebDataServices of sync profiles 55// |profile_a| and |profile_b|. Returns true if they match. 56bool KeysMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT; 57 58// Replaces the Autofill profiles in sync profile |profile| with 59// |autofill_profiles|. 60void SetProfiles(int profile, std::vector<AutofillProfile>* autofill_profiles); 61 62// Replaces the CreditCard profiles in sync profile |profile| with 63// |credit_cards|. 64void SetCreditCards(int profile, std::vector<CreditCard>* credit_cards); 65 66// Adds the autofill profile |autofill_profile| to sync profile |profile|. 67void AddProfile(int profile, const AutofillProfile& autofill_profile); 68 69// Removes the autofill profile with guid |guid| from sync profile 70// |profile|. 71void RemoveProfile(int profile, const std::string& guid); 72 73// Updates the autofill profile with guid |guid| in sync profile |profile| 74// to |type| and |value|. 75void UpdateProfile(int profile, 76 const std::string& guid, 77 const AutofillType& type, 78 const string16& value); 79 80// Gets all the Autofill profiles in the PersonalDataManager of sync profile 81// |profile|. 82const std::vector<AutofillProfile*>& GetAllProfiles( 83 int profile) WARN_UNUSED_RESULT; 84 85// Returns the number of autofill profiles contained by sync profile 86// |profile|. 87int GetProfileCount(int profile); 88 89// Returns the number of autofill keys contained by sync profile |profile|. 90int GetKeyCount(int profile); 91 92// Compares the Autofill profiles in the PersonalDataManagers of sync profiles 93// |profile_a| and |profile_b|. Returns true if they match. 94bool ProfilesMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT; 95 96// Compares the autofill profiles for all sync profiles, and returns true if 97// they all match. 98bool AllProfilesMatch() WARN_UNUSED_RESULT; 99 100// Creates a test autofill profile based on the persona specified in |type|. 101AutofillProfile CreateAutofillProfile(ProfileType type); 102 103} // namespace autofill_helper 104 105#endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_AUTOFILL_HELPER_H_ 106