Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: components/password_manager/core/browser/password_form_data.h

Issue 866983003: GetLoginsRequest: Use ScopedVector to express ownership of forms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@324291_scopedvector
Patch Set: Second fix of the rebase Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_FORM_DATA_H_ 5 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_FORM_DATA_H_
6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_FORM_DATA_H_ 6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_FORM_DATA_H_
7 7
8 #include <ostream> 8 #include <ostream>
9 9
10 #include "base/memory/scoped_ptr.h"
10 #include "components/autofill/core/common/password_form.h" 11 #include "components/autofill/core/common/password_form.h"
11 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
12 13
13 // TODO(sync): This file must eventually be refactored away -- crbug.com/87185. 14 // TODO(sync): This file must eventually be refactored away -- crbug.com/87185.
14 15
15 namespace password_manager { 16 namespace password_manager {
16 17
17 // Struct used for creation of PasswordForms from static arrays of data. 18 // Struct used for creation of PasswordForms from static arrays of data.
18 // Note: This is only meant to be used in unit test. 19 // Note: This is only meant to be used in unit test.
19 struct PasswordFormData { 20 struct PasswordFormData {
20 const autofill::PasswordForm::Scheme scheme; 21 const autofill::PasswordForm::Scheme scheme;
21 const char* signon_realm; 22 const char* signon_realm;
22 const char* origin; 23 const char* origin;
23 const char* action; 24 const char* action;
24 const wchar_t* submit_element; 25 const wchar_t* submit_element;
25 const wchar_t* username_element; 26 const wchar_t* username_element;
26 const wchar_t* password_element; 27 const wchar_t* password_element;
27 const wchar_t* username_value; // Set to NULL for a blacklist entry. 28 const wchar_t* username_value; // Set to NULL for a blacklist entry.
28 const wchar_t* password_value; 29 const wchar_t* password_value;
29 const bool preferred; 30 const bool preferred;
30 const bool ssl_valid; 31 const bool ssl_valid;
31 const double creation_time; 32 const double creation_time;
32 }; 33 };
33 34
34 // Creates and returns a new PasswordForm built from form_data. Caller is 35 // Creates and returns a new PasswordForm built from form_data.
35 // responsible for deleting the object when finished with it. 36 scoped_ptr<autofill::PasswordForm> CreatePasswordFormFromData(
36 autofill::PasswordForm* CreatePasswordFormFromData(
37 const PasswordFormData& form_data); 37 const PasswordFormData& form_data);
38 38
39 // Checks whether two vectors of PasswordForms contain equivalent elements, 39 // Checks whether two vectors of PasswordForms contain equivalent elements,
40 // regardless of order. 40 // regardless of order.
41 // TODO(vabr) The *Ptr suffix is obsolete, rename.
41 bool ContainsSamePasswordFormsPtr( 42 bool ContainsSamePasswordFormsPtr(
42 const std::vector<autofill::PasswordForm*>& first, 43 const std::vector<autofill::PasswordForm*>& first,
43 const std::vector<autofill::PasswordForm*>& second); 44 const std::vector<autofill::PasswordForm*>& second);
44 45
45 bool ContainsSamePasswordForms(std::vector<autofill::PasswordForm>& first,
46 std::vector<autofill::PasswordForm>& second);
47
48 // This gmock matcher is used to check that the |arg| contains exactly the same 46 // This gmock matcher is used to check that the |arg| contains exactly the same
49 // PasswordForms as |forms|, regardless of order. 47 // PasswordForms as |forms|, regardless of order.
50 MATCHER_P(ContainsAllPasswordForms, forms, "") { 48 MATCHER_P(ContainsSamePasswordForms, forms, "") {
51 return ContainsSamePasswordFormsPtr(forms, arg); 49 return ContainsSamePasswordFormsPtr(forms, arg);
52 } 50 }
53 51
54 } // namespace password_manager 52 } // namespace password_manager
55 53
56 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_FORM_DATA_H_ 54 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_FORM_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698