| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_SUPPRESSED_HTTPS_FORM_FETCHER_H
_ | 5 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_SUPPRESSED_FORM_FETCHER_H_ |
| 6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_SUPPRESSED_HTTPS_FORM_FETCHER_H
_ | 6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_SUPPRESSED_FORM_FETCHER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "components/autofill/core/common/password_form.h" | 13 #include "components/autofill/core/common/password_form.h" |
| 14 #include "components/password_manager/core/browser/password_store_consumer.h" | 14 #include "components/password_manager/core/browser/password_store_consumer.h" |
| 15 #include "url/gurl.h" | |
| 16 | 15 |
| 17 namespace password_manager { | 16 namespace password_manager { |
| 18 | 17 |
| 19 class PasswordManagerClient; | 18 class PasswordManagerClient; |
| 20 | 19 |
| 21 // Fetches credentials saved for the HTTPS counterpart of the given HTTP realm. | 20 // Fetches credentials saved for the HTTPS counterpart of the given HTTP realm. |
| 22 // | 21 // |
| 23 // Filling these HTTPS credentials into forms served over HTTP is obviously | 22 // Filling these HTTPS credentials into forms served over HTTP is obviously |
| 24 // suppressed, the purpose of doing such a query is to collect metrics on how | 23 // suppressed, the purpose of doing such a query is to collect metrics on how |
| 25 // often this happens and inconveniences the user. | 24 // often this happens and inconveniences the user. |
| 26 // | 25 // |
| 27 // This logic is implemented by this class, a separate PasswordStore consumer, | 26 // This logic is implemented by this class, a separate PasswordStore consumer, |
| 28 // to make it very sure that these credentials will not get mistakenly filled. | 27 // to make it very sure that these credentials will not get mistakenly filled. |
| 29 class SuppressedHTTPSFormFetcher : public PasswordStoreConsumer { | 28 class SuppressedFormFetcher : public PasswordStoreConsumer { |
| 30 public: | 29 public: |
| 31 // Interface to be implemented by the consumer of this class. | 30 // Interface to be implemented by the consumer of this class. |
| 32 class Consumer { | 31 class Consumer { |
| 33 public: | 32 public: |
| 34 virtual void ProcessSuppressedHTTPSForms( | 33 virtual void ProcessSuppressedForms( |
| 35 std::vector<std::unique_ptr<autofill::PasswordForm>> forms) = 0; | 34 std::vector<std::unique_ptr<autofill::PasswordForm>> forms) = 0; |
| 36 }; | 35 }; |
| 37 | 36 |
| 38 SuppressedHTTPSFormFetcher(const std::string& observed_signon_realm, | 37 SuppressedFormFetcher(const std::string& observed_signon_realm, |
| 39 const PasswordManagerClient* client, | 38 const PasswordManagerClient* client, |
| 40 Consumer* consumer); | 39 Consumer* consumer); |
| 41 ~SuppressedHTTPSFormFetcher() override; | 40 ~SuppressedFormFetcher() override; |
| 42 | 41 |
| 43 protected: | 42 protected: |
| 44 // PasswordStoreConsumer: | 43 // PasswordStoreConsumer: |
| 45 void OnGetPasswordStoreResults( | 44 void OnGetPasswordStoreResults( |
| 46 std::vector<std::unique_ptr<autofill::PasswordForm>> results) override; | 45 std::vector<std::unique_ptr<autofill::PasswordForm>> results) override; |
| 47 | 46 |
| 48 private: | 47 private: |
| 49 FRIEND_TEST_ALL_PREFIXES(SuppressedHTTPSFormFetcherTest, EmptyStore); | 48 FRIEND_TEST_ALL_PREFIXES(SuppressedFormFetcherTest, EmptyStore); |
| 50 FRIEND_TEST_ALL_PREFIXES(SuppressedHTTPSFormFetcherTest, FullStore); | 49 FRIEND_TEST_ALL_PREFIXES(SuppressedFormFetcherTest, FullStore); |
| 51 | 50 |
| 52 // The client and the consumer should outlive |this|. | 51 // The client and the consumer should outlive |this|. |
| 53 const PasswordManagerClient* client_; | 52 const PasswordManagerClient* client_; |
| 54 Consumer* consumer_; | 53 Consumer* consumer_; |
| 55 | 54 |
| 56 const GURL observed_signon_realm_as_url_; | 55 const std::string observed_signon_realm_; |
| 57 | 56 |
| 58 DISALLOW_COPY_AND_ASSIGN(SuppressedHTTPSFormFetcher); | 57 DISALLOW_COPY_AND_ASSIGN(SuppressedFormFetcher); |
| 59 }; | 58 }; |
| 60 | 59 |
| 61 } // namespace password_manager | 60 } // namespace password_manager |
| 62 | 61 |
| 63 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_SUPPRESSED_HTTPS_FORM_FETCHE
R_H_ | 62 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_SUPPRESSED_FORM_FETCHER_H_ |
| OLD | NEW |