Index: components/password_manager/core/browser/suppressed_https_form_fetcher.cc |
diff --git a/components/password_manager/core/browser/suppressed_https_form_fetcher.cc b/components/password_manager/core/browser/suppressed_https_form_fetcher.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d3111ad75c51c8b48e8e91479938d009582f7523 |
--- /dev/null |
+++ b/components/password_manager/core/browser/suppressed_https_form_fetcher.cc |
@@ -0,0 +1,47 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "components/password_manager/core/browser/suppressed_https_form_fetcher.h" |
+ |
+#include "base/logging.h" |
+#include "base/stl_util.h" |
+#include "components/password_manager/core/browser/password_manager_client.h" |
+#include "components/password_manager/core/browser/password_store.h" |
+#include "url/gurl.h" |
+ |
+namespace password_manager { |
+ |
+SuppressedHTTPSFormFetcher::SuppressedHTTPSFormFetcher( |
+ const GURL& http_origin, |
+ const PasswordManagerClient* client, |
+ Consumer* consumer) |
+ : client_(client), consumer_(consumer) { |
+ DCHECK(client_); |
+ DCHECK(consumer_); |
+ DCHECK(http_origin.is_valid()); |
+ DCHECK(http_origin.SchemeIs(url::kHttpScheme)); |
+ |
+ GURL::Replacements scheme_to_https; |
+ scheme_to_https.SetSchemeStr(url::kHttpsScheme); |
+ GURL https_origin = http_origin.ReplaceComponents(scheme_to_https); |
+ PasswordStore::FormDigest synthetic_form_digest( |
+ autofill::PasswordForm::SCHEME_HTML, https_origin.GetOrigin().spec(), |
+ https_origin); |
+ |
+ client_->GetPasswordStore()->GetLogins(synthetic_form_digest, this); |
+} |
+ |
+SuppressedHTTPSFormFetcher::~SuppressedHTTPSFormFetcher() = default; |
+ |
+void SuppressedHTTPSFormFetcher::OnGetPasswordStoreResults( |
+ std::vector<std::unique_ptr<autofill::PasswordForm>> results) { |
+ base::EraseIf( |
+ results, [](const std::unique_ptr<autofill::PasswordForm>& form) { |
+ return form->is_public_suffix_match || form->is_affiliation_based_match; |
dvadym
2017/05/22 09:58:50
Just wondering, why do we want do exclude PSL matc
engedy
2017/05/22 10:32:28
PSL matches will be included inherently in the oth
dvadym
2017/05/22 12:42:25
Acknowledged, I'm ok with separate histograms.
|
+ }); |
+ |
+ consumer_->ProcessSuppressedHTTPSForms(std::move(results)); |
+} |
+ |
+} // namespace password_manager |