OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_FORM_FETCHER_IMPL_H_ | 5 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_FORM_FETCHER_IMPL_H_ |
6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_FORM_FETCHER_IMPL_H_ | 6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_FORM_FETCHER_IMPL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "components/password_manager/core/browser/form_fetcher.h" | 13 #include "components/password_manager/core/browser/form_fetcher.h" |
14 #include "components/password_manager/core/browser/http_password_store_migrator. h" | 14 #include "components/password_manager/core/browser/http_password_store_migrator. h" |
15 #include "components/password_manager/core/browser/password_store.h" | 15 #include "components/password_manager/core/browser/password_store.h" |
16 #include "components/password_manager/core/browser/password_store_consumer.h" | 16 #include "components/password_manager/core/browser/password_store_consumer.h" |
17 #include "components/password_manager/core/browser/suppressed_https_form_fetcher .h" | 17 #include "components/password_manager/core/browser/suppressed_form_fetcher.h" |
18 | 18 |
19 namespace password_manager { | 19 namespace password_manager { |
20 | 20 |
21 class PasswordManagerClient; | 21 class PasswordManagerClient; |
22 | 22 |
23 // Production implementation of FormFetcher. Fetches credentials associated | 23 // Production implementation of FormFetcher. Fetches credentials associated |
24 // with a particular origin. | 24 // with a particular origin. |
25 class FormFetcherImpl : public FormFetcher, | 25 class FormFetcherImpl : public FormFetcher, |
26 public PasswordStoreConsumer, | 26 public PasswordStoreConsumer, |
27 public HttpPasswordStoreMigrator::Consumer, | 27 public HttpPasswordStoreMigrator::Consumer, |
28 public SuppressedHTTPSFormFetcher::Consumer { | 28 public SuppressedFormFetcher::Consumer { |
29 public: | 29 public: |
30 // |form_digest| describes what credentials need to be retrieved and | 30 // |form_digest| describes what credentials need to be retrieved and |
31 // |client| serves the PasswordStore, the logging information etc. | 31 // |client| serves the PasswordStore, the logging information etc. |
32 FormFetcherImpl(PasswordStore::FormDigest form_digest, | 32 FormFetcherImpl(PasswordStore::FormDigest form_digest, |
33 const PasswordManagerClient* client, | 33 const PasswordManagerClient* client, |
34 bool should_migrate_http_passwords, | 34 bool should_migrate_http_passwords, |
35 bool should_query_suppressed_https_forms); | 35 bool should_query_suppressed_forms); |
36 | 36 |
37 ~FormFetcherImpl() override; | 37 ~FormFetcherImpl() override; |
38 | 38 |
39 // FormFetcher: | 39 // FormFetcher: |
40 void AddConsumer(FormFetcher::Consumer* consumer) override; | 40 void AddConsumer(FormFetcher::Consumer* consumer) override; |
41 void RemoveConsumer(FormFetcher::Consumer* consumer) override; | 41 void RemoveConsumer(FormFetcher::Consumer* consumer) override; |
42 State GetState() const override; | 42 State GetState() const override; |
43 const std::vector<InteractionsStats>& GetInteractionsStats() const override; | 43 const std::vector<InteractionsStats>& GetInteractionsStats() const override; |
44 const std::vector<const autofill::PasswordForm*>& GetFederatedMatches() | 44 const std::vector<const autofill::PasswordForm*>& GetFederatedMatches() |
45 const override; | 45 const override; |
46 const std::vector<const autofill::PasswordForm*>& GetSuppressedHTTPSForms() | 46 const std::vector<const autofill::PasswordForm*>& GetSuppressedHTTPSForms() |
47 const override; | 47 const override; |
48 bool DidCompleteQueryingSuppressedHTTPSForms() const override; | 48 const std::vector<const autofill::PasswordForm*>& |
49 GetSuppressedPSLMatchingForms() const override; | |
50 const std::vector<const autofill::PasswordForm*>& | |
51 GetSuppressedSameOrganizationNameForms() const override; | |
52 bool DidCompleteQueryingSuppressedForms() const override; | |
49 void Fetch() override; | 53 void Fetch() override; |
50 std::unique_ptr<FormFetcher> Clone() override; | 54 std::unique_ptr<FormFetcher> Clone() override; |
51 | 55 |
52 // PasswordStoreConsumer: | 56 // PasswordStoreConsumer: |
53 void OnGetPasswordStoreResults( | 57 void OnGetPasswordStoreResults( |
54 std::vector<std::unique_ptr<autofill::PasswordForm>> results) override; | 58 std::vector<std::unique_ptr<autofill::PasswordForm>> results) override; |
55 void OnGetSiteStatistics(std::vector<InteractionsStats> stats) override; | 59 void OnGetSiteStatistics(std::vector<InteractionsStats> stats) override; |
56 | 60 |
57 // HttpPasswordStoreMigrator::Consumer: | 61 // HttpPasswordStoreMigrator::Consumer: |
58 void ProcessMigratedForms( | 62 void ProcessMigratedForms( |
59 std::vector<std::unique_ptr<autofill::PasswordForm>> forms) override; | 63 std::vector<std::unique_ptr<autofill::PasswordForm>> forms) override; |
60 | 64 |
61 // SuppressedHTTPSFormFetcher::Consumer: | 65 // SuppressedFormFetcher::Consumer: |
62 void ProcessSuppressedHTTPSForms( | 66 void ProcessSuppressedForms( |
63 std::vector<std::unique_ptr<autofill::PasswordForm>> forms) override; | 67 std::vector<std::unique_ptr<autofill::PasswordForm>> forms) override; |
64 | 68 |
65 private: | 69 private: |
66 // Processes password form results and forwards them to the |consumers_|. | 70 // Processes password form results and forwards them to the |consumers_|. |
67 void ProcessPasswordStoreResults( | 71 void ProcessPasswordStoreResults( |
68 std::vector<std::unique_ptr<autofill::PasswordForm>> results); | 72 std::vector<std::unique_ptr<autofill::PasswordForm>> results); |
69 | 73 |
70 // PasswordStore results will be fetched for this description. | 74 // PasswordStore results will be fetched for this description. |
71 const PasswordStore::FormDigest form_digest_; | 75 const PasswordStore::FormDigest form_digest_; |
72 | 76 |
73 // Results obtained from PasswordStore: | 77 // Results obtained from PasswordStore: |
74 std::vector<std::unique_ptr<autofill::PasswordForm>> non_federated_; | 78 std::vector<std::unique_ptr<autofill::PasswordForm>> non_federated_; |
75 | 79 |
76 // Federated credentials relevant to the observed form. They are neither | 80 // Federated credentials relevant to the observed form. They are neither |
77 // filled not saved by PasswordFormManager, so they are kept separately from | 81 // filled not saved by PasswordFormManager, so they are kept separately from |
78 // non-federated matches. | 82 // non-federated matches. |
79 std::vector<std::unique_ptr<autofill::PasswordForm>> federated_; | 83 std::vector<std::unique_ptr<autofill::PasswordForm>> federated_; |
80 | 84 |
81 // Statistics for the current domain. | 85 // Statistics for the current domain. |
82 std::vector<InteractionsStats> interactions_stats_; | 86 std::vector<InteractionsStats> interactions_stats_; |
83 | 87 |
84 // When |form_digest_.origin| is not secure, that is, its scheme is HTTP, this | 88 std::vector<std::unique_ptr<autofill::PasswordForm>> |
85 // will be filled with credentials found for the HTTPS version of that origin. | 89 suppressed_same_origin_https_forms_; |
86 std::vector<std::unique_ptr<autofill::PasswordForm>> suppressed_https_forms_; | 90 std::vector<std::unique_ptr<autofill::PasswordForm>> |
91 suppressed_psl_matching_forms_; | |
92 std::vector<std::unique_ptr<autofill::PasswordForm>> | |
93 suppressed_same_organization_name_forms_; | |
87 | 94 |
88 // Whether querying |suppressed_https_forms_| was attempted and did complete | 95 // Whether querying |suppressed_https_forms_| was attempted and did complete |
89 // at least once during the lifetime of this instance, regardless of whether | 96 // at least once during the lifetime of this instance, regardless of whether |
90 // there have been any results. | 97 // there have been any results. |
91 bool did_complete_querying_suppressed_https_forms_ = false; | 98 bool did_complete_querying_suppressed_forms_ = false; |
92 | 99 |
93 // Non-owning copies of the vectors above. | 100 // Non-owning copies of the vectors above. |
94 std::vector<const autofill::PasswordForm*> weak_non_federated_; | 101 std::vector<const autofill::PasswordForm*> weak_non_federated_; |
95 std::vector<const autofill::PasswordForm*> weak_federated_; | 102 std::vector<const autofill::PasswordForm*> weak_federated_; |
96 std::vector<const autofill::PasswordForm*> weak_suppressed_https_forms_; | 103 std::vector<const autofill::PasswordForm*> |
104 weak_suppressed_same_origin_https_forms_; | |
105 std::vector<const autofill::PasswordForm*> | |
106 weak_suppressed_psl_matching_forms_; | |
107 std::vector<const autofill::PasswordForm*> | |
108 weak_suppressed_same_organization_name_forms_; | |
97 | 109 |
98 // Consumers of the fetcher, all are assumed to outlive |this|. | 110 // Consumers of the fetcher, all are assumed to outlive |this|. |
99 std::set<FormFetcher::Consumer*> consumers_; | 111 std::set<FormFetcher::Consumer*> consumers_; |
100 | 112 |
101 // Client used to obtain a CredentialFilter. | 113 // Client used to obtain a CredentialFilter. |
102 const PasswordManagerClient* const client_; | 114 const PasswordManagerClient* const client_; |
103 | 115 |
104 // The number of non-federated forms which were filtered out by | 116 // The number of non-federated forms which were filtered out by |
105 // CredentialsFilter and not included in |non_federated_|. | 117 // CredentialsFilter and not included in |non_federated_|. |
106 size_t filtered_count_ = 0; | 118 size_t filtered_count_ = 0; |
107 | 119 |
108 // State of the fetcher. | 120 // State of the fetcher. |
109 State state_ = State::NOT_WAITING; | 121 State state_ = State::NOT_WAITING; |
110 | 122 |
111 // False unless FetchDataFromPasswordStore has been called again without the | 123 // False unless FetchDataFromPasswordStore has been called again without the |
112 // password store returning results in the meantime. | 124 // password store returning results in the meantime. |
113 bool need_to_refetch_ = false; | 125 bool need_to_refetch_ = false; |
114 | 126 |
115 // Indicates whether HTTP passwords should be migrated to HTTPS. | 127 // Indicates whether HTTP passwords should be migrated to HTTPS. |
116 const bool should_migrate_http_passwords_; | 128 const bool should_migrate_http_passwords_; |
117 | 129 |
118 // Indicates whether to query |suppressed_https_forms_| on HTTP origins. | 130 // Indicates whether to query suppressed forms on HTTP/HTTPS origins. |
kolos1
2017/05/30 07:02:29
Do we need to mention "HTTP/HTTPS origins"? Sounds
engedy
2017/05/30 08:47:43
Right. Done.
| |
119 const bool should_query_suppressed_https_forms_; | 131 const bool should_query_suppressed_forms_; |
120 | 132 |
121 // Does the actual migration. | 133 // Does the actual migration. |
122 std::unique_ptr<HttpPasswordStoreMigrator> http_migrator_; | 134 std::unique_ptr<HttpPasswordStoreMigrator> http_migrator_; |
123 | 135 |
124 // When |form_digest_.origin| is not secure, responsible for looking up | 136 // Responsible for looking up `suppressed` credentials. These are stored |
125 // credentials stored for the HTTPS counterpart of that origin. This happens | 137 // credentials that were not filled, even though they might be related to the |
126 // asynchronously, without blocking Consumer::ProcessMatches. | 138 // origin that this instance was created for. Look-up happens asynchronously, |
127 std::unique_ptr<SuppressedHTTPSFormFetcher> suppressed_https_form_fetcher_; | 139 // without blocking Consumer::ProcessMatches. |
140 std::unique_ptr<SuppressedFormFetcher> suppressed_form_fetcher_; | |
128 | 141 |
129 DISALLOW_COPY_AND_ASSIGN(FormFetcherImpl); | 142 DISALLOW_COPY_AND_ASSIGN(FormFetcherImpl); |
130 }; | 143 }; |
131 | 144 |
132 } // namespace password_manager | 145 } // namespace password_manager |
133 | 146 |
134 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_FORM_FETCHER_IMPL_H_ | 147 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_FORM_FETCHER_IMPL_H_ |
OLD | NEW |