Commit 3e5482ff authored by Friedrich Horschig's avatar Friedrich Horschig Committed by Commit Bot

Move password popup building suggestions into helper methods

This CL should have no visible effect. (maybe metrics, see below)

Currently, the same popup suggestions are built in two different places
and a third one reuses one of the methods. For updating, there will be
at least two more code paths building suggestions which cannot reuse the
current code.
To prevent code duplication, this CL moves building the suggestions into
helper methods.

One notable change: previously, we would record the metric
"PasswordManager.ShowAllSavedPasswordsShownContext" when the suggestion
entry was added to the list of suggestions. This might have recorded the
metric prematurely since there is another check that occasionally
prevents showing the popup (and with it, the "Show all" button).

Bug: 1043963
Change-Id: Ia305c9102d6f1b2f6430e02617e83de02f9253e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2020704
Commit-Queue: Friedrich [CET] <fhorschig@chromium.org>
Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736273}
parent 322aef81
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/i18n/rtl.h" #include "base/i18n/rtl.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/task/cancelable_task_tracker.h" #include "base/task/cancelable_task_tracker.h"
#include "base/util/type_safety/strong_alias.h"
#include "components/autofill/core/browser/autofill_client.h" #include "components/autofill/core/browser/autofill_client.h"
#include "components/autofill/core/browser/ui/autofill_popup_delegate.h" #include "components/autofill/core/browser/ui/autofill_popup_delegate.h"
#include "components/autofill/core/common/password_form_fill_data.h" #include "components/autofill/core/common/password_form_fill_data.h"
...@@ -105,6 +106,29 @@ class PasswordAutofillManager : public autofill::AutofillPopupDelegate { ...@@ -105,6 +106,29 @@ class PasswordAutofillManager : public autofill::AutofillPopupDelegate {
#endif // defined(UNIT_TEST) #endif // defined(UNIT_TEST)
private: private:
using ForPasswordField = util::StrongAlias<class ForPasswordFieldTag, bool>;
using OffersGeneration = util::StrongAlias<class OffersGenerationTag, bool>;
using ShowAllPasswords = util::StrongAlias<class ShowAllPasswordsTag, bool>;
using ShowPasswordSuggestions =
util::StrongAlias<class ShowPasswordSuggestionsTag, bool>;
// Builds the suggestions used to show or update the autofill popup.
std::vector<autofill::Suggestion> BuildSuggestions(
ShowAllPasswords show_all_passwords,
ForPasswordField for_password_field,
const base::string16& typed_username,
OffersGeneration for_generation,
ShowPasswordSuggestions show_password_suggestions);
// Called just before showing a popup to log which |suggestions| were shown.
void LogMetricsForSuggestions(
const std::vector<autofill::Suggestion>& suggestions) const;
// Validates and forwards the given objects to the autofill client.
bool ShowPopup(const gfx::RectF& bounds,
base::i18n::TextDirection text_direction,
const std::vector<autofill::Suggestion>& suggestions);
// Attempts to fill the password associated with user name |username|, and // Attempts to fill the password associated with user name |username|, and
// returns true if it was successful. // returns true if it was successful.
bool FillSuggestion(const base::string16& username); bool FillSuggestion(const base::string16& username);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment