autofill_helper.h revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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 AutofillWebDataService; 22class CreditCard; 23class PersonalDataManager; 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<AutofillWebDataService> GetWebDataService( 36 int index) WARN_UNUSED_RESULT; 37 38// Used to access the personal data manager within a particular sync profile. 39PersonalDataManager* GetPersonalDataManager(int index) WARN_UNUSED_RESULT; 40 41// Adds the form fields in |keys| to the WebDataService of sync profile 42// |profile|. 43void AddKeys(int profile, const std::set<AutofillKey>& keys); 44 45// Removes the form field in |key| from the WebDataService of sync profile 46// |profile|. 47void RemoveKey(int profile, const AutofillKey& key); 48 49// Removes all of the keys from the WebDataService of sync profile |profile|. 50void RemoveKeys(int profile); 51 52// Gets all the form fields in the WebDataService of sync profile |profile|. 53std::set<AutofillEntry> GetAllKeys(int profile) WARN_UNUSED_RESULT; 54 55// Compares the form fields in the WebDataServices of sync profiles 56// |profile_a| and |profile_b|. Returns true if they match. 57bool KeysMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT; 58 59// Replaces the Autofill profiles in sync profile |profile| with 60// |autofill_profiles|. 61void SetProfiles(int profile, std::vector<AutofillProfile>* autofill_profiles); 62 63// Replaces the CreditCard profiles in sync profile |profile| with 64// |credit_cards|. 65void SetCreditCards(int profile, std::vector<CreditCard>* credit_cards); 66 67// Adds the autofill profile |autofill_profile| to sync profile |profile|. 68void AddProfile(int profile, const AutofillProfile& autofill_profile); 69 70// Removes the autofill profile with guid |guid| from sync profile 71// |profile|. 72void RemoveProfile(int profile, const std::string& guid); 73 74// Updates the autofill profile with guid |guid| in sync profile |profile| 75// to |type| and |value|. 76void UpdateProfile(int profile, 77 const std::string& guid, 78 const AutofillType& type, 79 const string16& value); 80 81// Gets all the Autofill profiles in the PersonalDataManager of sync profile 82// |profile|. 83const std::vector<AutofillProfile*>& GetAllProfiles( 84 int profile) WARN_UNUSED_RESULT; 85 86// Returns the number of autofill profiles contained by sync profile 87// |profile|. 88int GetProfileCount(int profile); 89 90// Returns the number of autofill keys contained by sync profile |profile|. 91int GetKeyCount(int profile); 92 93// Compares the Autofill profiles in the PersonalDataManagers of sync profiles 94// |profile_a| and |profile_b|. Returns true if they match. 95bool ProfilesMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT; 96 97// Compares the autofill profiles for all sync profiles, and returns true if 98// they all match. 99bool AllProfilesMatch() WARN_UNUSED_RESULT; 100 101// Creates a test autofill profile based on the persona specified in |type|. 102AutofillProfile CreateAutofillProfile(ProfileType type); 103 104} // namespace autofill_helper 105 106#endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_AUTOFILL_HELPER_H_ 107