| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_FORM_DATA_H_ | 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_FORM_DATA_H_ |
| 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_FORM_DATA_H_ | 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_FORM_DATA_H_ |
| 7 | 7 |
| 8 #include <ostream> | 8 #include <ostream> |
| 9 | 9 |
| 10 #include "content/public/common/password_form.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
| 11 #include "webkit/forms/password_form.h" | |
| 12 | 12 |
| 13 // Struct used for creation of PasswordForms from static arrays of data. | 13 // Struct used for creation of PasswordForms from static arrays of data. |
| 14 // Note: This is only meant to be used in unit test. | 14 // Note: This is only meant to be used in unit test. |
| 15 struct PasswordFormData { | 15 struct PasswordFormData { |
| 16 const webkit::forms::PasswordForm::Scheme scheme; | 16 const content::PasswordForm::Scheme scheme; |
| 17 const char* signon_realm; | 17 const char* signon_realm; |
| 18 const char* origin; | 18 const char* origin; |
| 19 const char* action; | 19 const char* action; |
| 20 const wchar_t* submit_element; | 20 const wchar_t* submit_element; |
| 21 const wchar_t* username_element; | 21 const wchar_t* username_element; |
| 22 const wchar_t* password_element; | 22 const wchar_t* password_element; |
| 23 const wchar_t* username_value; // Set to NULL for a blacklist entry. | 23 const wchar_t* username_value; // Set to NULL for a blacklist entry. |
| 24 const wchar_t* password_value; | 24 const wchar_t* password_value; |
| 25 const bool preferred; | 25 const bool preferred; |
| 26 const bool ssl_valid; | 26 const bool ssl_valid; |
| 27 const double creation_time; | 27 const double creation_time; |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 // Creates and returns a new PasswordForm built from form_data. Caller is | 30 // Creates and returns a new PasswordForm built from form_data. Caller is |
| 31 // responsible for deleting the object when finished with it. | 31 // responsible for deleting the object when finished with it. |
| 32 webkit::forms::PasswordForm* CreatePasswordFormFromData( | 32 content::PasswordForm* CreatePasswordFormFromData( |
| 33 const PasswordFormData& form_data); | 33 const PasswordFormData& form_data); |
| 34 | 34 |
| 35 // Checks whether two vectors of PasswordForms contain equivalent elements, | 35 // Checks whether two vectors of PasswordForms contain equivalent elements, |
| 36 // regardless of order. | 36 // regardless of order. |
| 37 bool ContainsSamePasswordFormsPtr( | 37 bool ContainsSamePasswordFormsPtr( |
| 38 const std::vector<webkit::forms::PasswordForm*>& first, | 38 const std::vector<content::PasswordForm*>& first, |
| 39 const std::vector<webkit::forms::PasswordForm*>& second); | 39 const std::vector<content::PasswordForm*>& second); |
| 40 | 40 |
| 41 bool ContainsSamePasswordForms( | 41 bool ContainsSamePasswordForms( |
| 42 std::vector<webkit::forms::PasswordForm>& first, | 42 std::vector<content::PasswordForm>& first, |
| 43 std::vector<webkit::forms::PasswordForm>& second); | 43 std::vector<content::PasswordForm>& second); |
| 44 | 44 |
| 45 // Pretty-prints the contents of a PasswordForm. | 45 // Pretty-prints the contents of a PasswordForm. |
| 46 // TODO(sync): This file must eventually be refactored away -- crbug.com/87185. | 46 // TODO(sync): This file must eventually be refactored away -- crbug.com/87185. |
| 47 std::ostream& operator<<(std::ostream& os, | 47 std::ostream& operator<<(std::ostream& os, |
| 48 const webkit::forms::PasswordForm& form); | 48 const content::PasswordForm& form); |
| 49 | 49 |
| 50 // This gmock matcher is used to check that the |arg| contains exactly the same | 50 // This gmock matcher is used to check that the |arg| contains exactly the same |
| 51 // PasswordForms as |forms|, regardless of order. | 51 // PasswordForms as |forms|, regardless of order. |
| 52 MATCHER_P(ContainsAllPasswordForms, forms, "") { | 52 MATCHER_P(ContainsAllPasswordForms, forms, "") { |
| 53 return ContainsSamePasswordFormsPtr(forms, arg); | 53 return ContainsSamePasswordFormsPtr(forms, arg); |
| 54 } | 54 } |
| 55 | 55 |
| 56 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_FORM_DATA_H_ | 56 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_FORM_DATA_H_ |
| OLD | NEW |