Commit 5881529d authored by Clemens Arbesser's avatar Clemens Arbesser Committed by Commit Bot

[Autofill Assistant] Move parameter names into trigger context.

This makes more sense to me, since (1) the controller shouldn't have to
know, and (2) the parameters are owned by the trigger context anyway.

This is a refactoring only and should have no user-facing changes.

Change-Id: I06da79a4215a12df66bf5f69f7a2634ba34f43ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2356504
Auto-Submit: Clemens Arbesser <arbesser@google.com>
Commit-Queue: Luca Hunkeler <hluca@google.com>
Reviewed-by: default avatarLuca Hunkeler <hluca@google.com>
Cr-Commit-Position: refs/heads/master@{#798556}
parent 4b80e912
......@@ -42,15 +42,6 @@ namespace {
// message.
static constexpr int kAutostartInitialProgress = 5;
// Parameter that allows setting the color of the overlay.
const char kOverlayColorParameterName[] = "OVERLAY_COLORS";
// Parameter that contains the current session username. Should be synced with
// |SESSION_USERNAME_PARAMETER| from
// .../password_manager/PasswordChangeLauncher.java
// TODO(b/151401974): Eliminate duplicate parameter definitions.
const char kPasswordChangeUsernameParameterName[] = "PASSWORD_CHANGE_USERNAME";
// Experiment for toggling the new progress bar.
const char kProgressBarExperiment[] = "4400697";
......@@ -1027,7 +1018,7 @@ void Controller::InitFromParameters() {
SetDetails(std::move(details));
const base::Optional<std::string> overlay_color =
trigger_context_->GetParameter(kOverlayColorParameterName);
trigger_context_->GetOverlayColors();
if (overlay_color) {
std::unique_ptr<OverlayColors> colors = std::make_unique<OverlayColors>();
std::vector<std::string> color_strings =
......@@ -1045,7 +1036,7 @@ void Controller::InitFromParameters() {
SetOverlayColors(std::move(colors));
}
const base::Optional<std::string> password_change_username =
trigger_context_->GetParameter(kPasswordChangeUsernameParameterName);
trigger_context_->GetPasswordChangeUsername();
if (password_change_username) {
DCHECK(
GetCurrentURL().is_valid()); // At least |deeplink_url_| must be set.
......
......@@ -7,6 +7,15 @@
namespace autofill_assistant {
// Parameter that allows setting the color of the overlay.
const char kOverlayColorParameterName[] = "OVERLAY_COLORS";
// Parameter that contains the current session username. Should be synced with
// |SESSION_USERNAME_PARAMETER| from
// .../password_manager/PasswordChangeLauncher.java
// TODO(b/151401974): Eliminate duplicate parameter definitions.
const char kPasswordChangeUsernameParameterName[] = "PASSWORD_CHANGE_USERNAME";
// static
std::unique_ptr<TriggerContext> TriggerContext::CreateEmpty() {
return std::make_unique<TriggerContextImpl>();
......@@ -28,6 +37,14 @@ std::unique_ptr<TriggerContext> TriggerContext::Merge(
TriggerContext::TriggerContext() {}
TriggerContext::~TriggerContext() {}
base::Optional<std::string> TriggerContext::GetOverlayColors() const {
return GetParameter(kOverlayColorParameterName);
}
base::Optional<std::string> TriggerContext::GetPasswordChangeUsername() const {
return GetParameter(kPasswordChangeUsernameParameterName);
}
TriggerContextImpl::TriggerContextImpl() {}
TriggerContextImpl::TriggerContextImpl(
......
......@@ -44,6 +44,10 @@ class TriggerContext {
virtual base::Optional<std::string> GetParameter(
const std::string& name) const = 0;
// Getters for specific parameters.
base::Optional<std::string> GetOverlayColors() const;
base::Optional<std::string> GetPasswordChangeUsername() const;
// Returns a comma-separated set of experiment ids.
virtual std::string experiment_ids() const = 0;
......
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