| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_SUPPRESSED_HTTPS_FORM_FETCHER_H
_ | |
| 6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_SUPPRESSED_HTTPS_FORM_FETCHER_H
_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/gtest_prod_util.h" | |
| 12 #include "base/macros.h" | |
| 13 #include "components/autofill/core/common/password_form.h" | |
| 14 #include "components/password_manager/core/browser/password_store_consumer.h" | |
| 15 #include "url/gurl.h" | |
| 16 | |
| 17 namespace password_manager { | |
| 18 | |
| 19 class PasswordManagerClient; | |
| 20 | |
| 21 // Fetches credentials saved for the HTTPS counterpart of the given HTTP realm. | |
| 22 // | |
| 23 // 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 | |
| 25 // often this happens and inconveniences the user. | |
| 26 // | |
| 27 // 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. | |
| 29 class SuppressedHTTPSFormFetcher : public PasswordStoreConsumer { | |
| 30 public: | |
| 31 // Interface to be implemented by the consumer of this class. | |
| 32 class Consumer { | |
| 33 public: | |
| 34 virtual void ProcessSuppressedHTTPSForms( | |
| 35 std::vector<std::unique_ptr<autofill::PasswordForm>> forms) = 0; | |
| 36 }; | |
| 37 | |
| 38 SuppressedHTTPSFormFetcher(const std::string& observed_signon_realm, | |
| 39 const PasswordManagerClient* client, | |
| 40 Consumer* consumer); | |
| 41 ~SuppressedHTTPSFormFetcher() override; | |
| 42 | |
| 43 protected: | |
| 44 // PasswordStoreConsumer: | |
| 45 void OnGetPasswordStoreResults( | |
| 46 std::vector<std::unique_ptr<autofill::PasswordForm>> results) override; | |
| 47 | |
| 48 private: | |
| 49 FRIEND_TEST_ALL_PREFIXES(SuppressedHTTPSFormFetcherTest, EmptyStore); | |
| 50 FRIEND_TEST_ALL_PREFIXES(SuppressedHTTPSFormFetcherTest, FullStore); | |
| 51 | |
| 52 // The client and the consumer should outlive |this|. | |
| 53 const PasswordManagerClient* client_; | |
| 54 Consumer* consumer_; | |
| 55 | |
| 56 const GURL observed_signon_realm_as_url_; | |
| 57 | |
| 58 DISALLOW_COPY_AND_ASSIGN(SuppressedHTTPSFormFetcher); | |
| 59 }; | |
| 60 | |
| 61 } // namespace password_manager | |
| 62 | |
| 63 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_SUPPRESSED_HTTPS_FORM_FETCHE
R_H_ | |
| OLD | NEW |