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