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

Unified Diff: components/password_manager/core/browser/suppressed_form_fetcher.cc

Issue 2912783002: Measure how often PSL and same-organization name credentials are suppressed. (Closed)
Patch Set: Addressed comments from kolos@. Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: components/password_manager/core/browser/suppressed_form_fetcher.cc
diff --git a/components/password_manager/core/browser/suppressed_form_fetcher.cc b/components/password_manager/core/browser/suppressed_form_fetcher.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1a52b08999eed6b16512b6680193a5c63b66947a
--- /dev/null
+++ b/components/password_manager/core/browser/suppressed_form_fetcher.cc
@@ -0,0 +1,41 @@
+// 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_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 {
+
+SuppressedFormFetcher::SuppressedFormFetcher(
+ const std::string& observed_signon_realm,
+ const PasswordManagerClient* client,
+ Consumer* consumer)
+ : client_(client),
+ consumer_(consumer),
+ observed_signon_realm_(observed_signon_realm) {
+ DCHECK(client_);
+ DCHECK(consumer_);
+ DCHECK(GURL(observed_signon_realm_).SchemeIsHTTPOrHTTPS());
+ client_->GetPasswordStore()->GetLoginsForSameOrganizationName(
+ observed_signon_realm_, this);
+}
+
+SuppressedFormFetcher::~SuppressedFormFetcher() = default;
+
+void SuppressedFormFetcher::OnGetPasswordStoreResults(
+ std::vector<std::unique_ptr<autofill::PasswordForm>> results) {
+ base::EraseIf(results,
+ [this](const std::unique_ptr<autofill::PasswordForm>& form) {
+ return form->signon_realm == observed_signon_realm_;
+ });
+
+ consumer_->ProcessSuppressedForms(std::move(results));
+}
+
+} // namespace password_manager

Powered by Google App Engine
This is Rietveld 408576698