passwords_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_PASSWORDS_HELPER_H_ 6#define CHROME_BROWSER_SYNC_TEST_INTEGRATION_PASSWORDS_HELPER_H_ 7 8#include <vector> 9 10#include "chrome/browser/profiles/profile.h" 11#include "chrome/browser/sync/profile_sync_service.h" 12#include "chrome/browser/sync/test/integration/sync_test.h" 13#include "content/public/common/password_form.h" 14 15class PasswordStore; 16 17namespace passwords_helper { 18 19// Adds the login held in |form| to the password store |store|. Even though 20// logins are normally added asynchronously, this method will block until the 21// login is added. 22void AddLogin(PasswordStore* store, const content::PasswordForm& form); 23 24// Update the data held in password store |store| with a modified |form|. 25// This method blocks until the operation is complete. 26void UpdateLogin(PasswordStore* store, const content::PasswordForm& form); 27 28// Searches |store| for all logins matching a fake signon realm used only by 29// LivePasswordsSyncTest and adds the results to |matches|. Note that the 30// caller is responsible for deleting the forms added to |matches|. 31void GetLogins(PasswordStore* store, 32 std::vector<content::PasswordForm>& matches); 33 34// Removes the login held in |form| from the password store |store|. This 35// method blocks until the operation is complete. 36void RemoveLogin(PasswordStore* store, const content::PasswordForm& form); 37 38// Removes all password forms from the password store |store|. 39void RemoveLogins(PasswordStore* store); 40 41// Sets the cryptographer's encryption passphrase for the profile at index 42// |index| to |passphrase|, and passphrase type |type|. 43void SetEncryptionPassphrase(int index, 44 const std::string& passphrase, 45 ProfileSyncService::PassphraseType type); 46 47// Sets the cryptographer's decryption passphrase for the profile at index 48// |index| to |passphrase|. Returns false if the operation failed, and true 49// otherwise. 50bool SetDecryptionPassphrase(int index, const std::string& passphrase); 51 52// Gets the password store of the profile with index |index|. 53PasswordStore* GetPasswordStore(int index); 54 55// Gets the password store of the verifier profile. 56PasswordStore* GetVerifierPasswordStore(); 57 58// Returns true iff the profile with index |index| contains the same password 59// forms as the verifier profile. 60bool ProfileContainsSamePasswordFormsAsVerifier(int index); 61 62// Returns true iff the profile with index |index_a| contains the same 63// password forms as the profile with index |index_b|. 64bool ProfilesContainSamePasswordForms(int index_a, int index_b); 65 66// Returns true iff all profiles contain the same password forms as the 67// verifier profile. 68bool AllProfilesContainSamePasswordFormsAsVerifier(); 69 70// Returns true iff all profiles contain the same password forms. 71bool AllProfilesContainSamePasswordForms(); 72 73// Returns the number of forms in the password store of the profile with index 74// |index|. 75int GetPasswordCount(int index); 76 77// Returns the number of forms in the password store of the verifier profile. 78int GetVerifierPasswordCount(); 79 80// Creates a test password form with a well known fake signon realm used only 81// by LivePasswordsSyncTest based on |index|. 82content::PasswordForm CreateTestPasswordForm(int index); 83 84} // namespace passwords_helper 85 86#endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_PASSWORDS_HELPER_H_ 87