Commit 317c4f7f authored by sandromaggi's avatar sandromaggi Committed by Commit Bot

[Autofill Assistant] Remove restart action.

The action is no longer used.

Bug: b/148194528
Change-Id: Ia7b6cb5c5f6dd4ebdad059f35a15e35da469d159
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2027329Reviewed-by: default avatarMathias Carlen <mcarlen@chromium.org>
Commit-Queue: Sandro Maggi <sandromaggi@google.com>
Cr-Commit-Position: refs/heads/master@{#736784}
parent 943548fd
...@@ -45,8 +45,6 @@ jumbo_static_library("browser") { ...@@ -45,8 +45,6 @@ jumbo_static_library("browser") {
"actions/prompt_action.h", "actions/prompt_action.h",
"actions/required_fields_fallback_handler.cc", "actions/required_fields_fallback_handler.cc",
"actions/required_fields_fallback_handler.h", "actions/required_fields_fallback_handler.h",
"actions/reset_action.cc",
"actions/reset_action.h",
"actions/select_option_action.cc", "actions/select_option_action.cc",
"actions/select_option_action.h", "actions/select_option_action.h",
"actions/set_attribute_action.cc", "actions/set_attribute_action.cc",
......
...@@ -95,9 +95,6 @@ std::ostream& operator<<(std::ostream& out, ...@@ -95,9 +95,6 @@ std::ostream& operator<<(std::ostream& out,
case ActionProto::ActionInfoCase::kShowDetails: case ActionProto::ActionInfoCase::kShowDetails:
out << "ShowDetails"; out << "ShowDetails";
break; break;
case ActionProto::ActionInfoCase::kReset:
out << "Reset";
break;
case ActionProto::ActionInfoCase::kStop: case ActionProto::ActionInfoCase::kStop:
out << "Stop"; out << "Stop";
break; break;
......
...@@ -271,10 +271,6 @@ class ActionDelegate { ...@@ -271,10 +271,6 @@ class ActionDelegate {
// Shut down Autofill Assistant and closes Chrome. // Shut down Autofill Assistant and closes Chrome.
virtual void Close() = 0; virtual void Close() = 0;
// Restart Autofill Assistant at the end of the current script with a cleared
// state.
virtual void Restart() = 0;
// Get current personal data manager. // Get current personal data manager.
virtual autofill::PersonalDataManager* GetPersonalDataManager() = 0; virtual autofill::PersonalDataManager* GetPersonalDataManager() = 0;
......
// Copyright 2018 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/autofill_assistant/browser/actions/reset_action.h"
#include <memory>
#include <utility>
#include "base/callback.h"
#include "components/autofill_assistant/browser/actions/action_delegate.h"
namespace autofill_assistant {
ResetAction::ResetAction(ActionDelegate* delegate, const ActionProto& proto)
: Action(delegate, proto) {
DCHECK(proto_.has_reset());
}
ResetAction::~ResetAction() {}
void ResetAction::InternalProcessAction(ProcessActionCallback callback) {
delegate_->Restart();
UpdateProcessedAction(ACTION_APPLIED);
std::move(callback).Run(std::move(processed_action_proto_));
}
} // namespace autofill_assistant
// Copyright 2018 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.
#ifndef COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_ACTIONS_RESET_ACTION_H_
#define COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_ACTIONS_RESET_ACTION_H_
#include <string>
#include "base/macros.h"
#include "components/autofill_assistant/browser/actions/action.h"
namespace autofill_assistant {
// An action to reset Autofill Assistant state.
class ResetAction : public Action {
public:
explicit ResetAction(ActionDelegate* delegate, const ActionProto& proto);
~ResetAction() override;
private:
// Overrides Action:
void InternalProcessAction(ProcessActionCallback callback) override;
DISALLOW_COPY_AND_ASSIGN(ResetAction);
};
} // namespace autofill_assistant
#endif // COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_ACTIONS_RESET_ACTION_H_
...@@ -829,12 +829,6 @@ void Controller::OnScriptExecuted(const std::string& script_path, ...@@ -829,12 +829,6 @@ void Controller::OnScriptExecuted(const std::string& script_path,
end_state = AutofillAssistantState::TRACKING; end_state = AutofillAssistantState::TRACKING;
return; return;
// TODO(b/148194528): Remove.
case ScriptExecutor::RESTART:
script_tracker_.reset();
script_domain_ = "";
break;
case ScriptExecutor::CONTINUE: case ScriptExecutor::CONTINUE:
break; break;
......
...@@ -556,40 +556,6 @@ TEST_F(ControllerTest, CloseCustomTab) { ...@@ -556,40 +556,6 @@ TEST_F(ControllerTest, CloseCustomTab) {
EXPECT_TRUE(controller_->PerformUserAction(0)); EXPECT_TRUE(controller_->PerformUserAction(0));
} }
TEST_F(ControllerTest, Reset) {
// 1. Fetch scripts for URL, which in contains a single "reset" script.
SupportsScriptResponseProto script_response;
auto* reset_script = AddRunnableScript(&script_response, "reset");
RunOnce(reset_script);
std::string script_response_str;
script_response.SerializeToString(&script_response_str);
EXPECT_CALL(*mock_service_, OnGetScriptsForUrl(_, _, _))
.WillRepeatedly(RunOnceCallback<2>(true, script_response_str));
Start("http://a.example.com/path");
EXPECT_THAT(controller_->GetUserActions(),
ElementsAre(Property(&UserAction::chip,
Field(&Chip::text, StrEq("reset")))));
// 2. Execute the "reset" script, which contains a reset action.
ActionsResponseProto actions_response;
actions_response.add_actions()->mutable_reset();
std::string actions_response_str;
actions_response.SerializeToString(&actions_response_str);
EXPECT_CALL(*mock_service_, OnGetActions(StrEq("reset"), _, _, _, _, _))
.WillOnce(RunOnceCallback<5>(true, actions_response_str));
GetUserData()->selected_card_ = std::make_unique<autofill::CreditCard>();
EXPECT_TRUE(controller_->PerformUserAction(0));
// The reset script should be available again, even though it's marked
// RunOnce, as the script state should have been cleared as well.
EXPECT_THAT(controller_->GetUserActions(),
ElementsAre(Property(&UserAction::chip,
Field(&Chip::text, StrEq("reset")))));
}
TEST_F(ControllerTest, RefreshScriptWhenDomainChanges) { TEST_F(ControllerTest, RefreshScriptWhenDomainChanges) {
SupportsScriptResponseProto script_response; SupportsScriptResponseProto script_response;
AddRunnableScript(&script_response, "script"); AddRunnableScript(&script_response, "script");
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "components/autofill_assistant/browser/actions/navigate_action.h" #include "components/autofill_assistant/browser/actions/navigate_action.h"
#include "components/autofill_assistant/browser/actions/popup_message_action.h" #include "components/autofill_assistant/browser/actions/popup_message_action.h"
#include "components/autofill_assistant/browser/actions/prompt_action.h" #include "components/autofill_assistant/browser/actions/prompt_action.h"
#include "components/autofill_assistant/browser/actions/reset_action.h"
#include "components/autofill_assistant/browser/actions/select_option_action.h" #include "components/autofill_assistant/browser/actions/select_option_action.h"
#include "components/autofill_assistant/browser/actions/set_attribute_action.h" #include "components/autofill_assistant/browser/actions/set_attribute_action.h"
#include "components/autofill_assistant/browser/actions/set_form_field_value_action.h" #include "components/autofill_assistant/browser/actions/set_form_field_value_action.h"
...@@ -239,10 +238,6 @@ bool ProtocolUtils::ParseActions(ActionDelegate* delegate, ...@@ -239,10 +238,6 @@ bool ProtocolUtils::ParseActions(ActionDelegate* delegate,
client_action = std::make_unique<StopAction>(delegate, action); client_action = std::make_unique<StopAction>(delegate, action);
break; break;
} }
case ActionProto::ActionInfoCase::kReset: {
client_action = std::make_unique<ResetAction>(delegate, action);
break;
}
case ActionProto::ActionInfoCase::kHighlightElement: { case ActionProto::ActionInfoCase::kHighlightElement: {
client_action = client_action =
std::make_unique<HighlightElementAction>(delegate, action); std::make_unique<HighlightElementAction>(delegate, action);
......
...@@ -48,9 +48,6 @@ std::ostream& operator<<(std::ostream& out, ...@@ -48,9 +48,6 @@ std::ostream& operator<<(std::ostream& out,
case ScriptExecutor::CLOSE_CUSTOM_TAB: case ScriptExecutor::CLOSE_CUSTOM_TAB:
out << "CLOSE_CUSTOM_TAB"; out << "CLOSE_CUSTOM_TAB";
break; break;
case ScriptExecutor::RESTART:
out << "RESTART";
break;
// Intentionally no default case to make compilation fail if a new value // Intentionally no default case to make compilation fail if a new value
// was added to the enum but not to this list. // was added to the enum but not to this list.
} }
...@@ -509,10 +506,6 @@ void ScriptExecutor::Close() { ...@@ -509,10 +506,6 @@ void ScriptExecutor::Close() {
should_stop_script_ = true; should_stop_script_ = true;
} }
void ScriptExecutor::Restart() {
at_end_ = RESTART;
}
autofill::PersonalDataManager* ScriptExecutor::GetPersonalDataManager() { autofill::PersonalDataManager* ScriptExecutor::GetPersonalDataManager() {
return delegate_->GetPersonalDataManager(); return delegate_->GetPersonalDataManager();
} }
......
...@@ -78,9 +78,6 @@ class ScriptExecutor : public ActionDelegate, ...@@ -78,9 +78,6 @@ class ScriptExecutor : public ActionDelegate,
// Shut down Autofill Assistant and CCT. // Shut down Autofill Assistant and CCT.
CLOSE_CUSTOM_TAB, CLOSE_CUSTOM_TAB,
// Reset all state and restart.
RESTART,
}; };
// Contains the result of the Run operation. // Contains the result of the Run operation.
...@@ -203,7 +200,6 @@ class ScriptExecutor : public ActionDelegate, ...@@ -203,7 +200,6 @@ class ScriptExecutor : public ActionDelegate,
void LoadURL(const GURL& url) override; void LoadURL(const GURL& url) override;
void Shutdown() override; void Shutdown() override;
void Close() override; void Close() override;
void Restart() override;
autofill::PersonalDataManager* GetPersonalDataManager() override; autofill::PersonalDataManager* GetPersonalDataManager() override;
WebsiteLoginFetcher* GetWebsiteLoginFetcher() override; WebsiteLoginFetcher* GetWebsiteLoginFetcher() override;
content::WebContents* GetWebContents() override; content::WebContents* GetWebContents() override;
......
...@@ -288,22 +288,6 @@ TEST_F(ScriptExecutorTest, StopAfterEnd) { ...@@ -288,22 +288,6 @@ TEST_F(ScriptExecutorTest, StopAfterEnd) {
executor_->Run(&user_data_, executor_callback_.Get()); executor_->Run(&user_data_, executor_callback_.Get());
} }
TEST_F(ScriptExecutorTest, ResetAfterEnd) {
ActionsResponseProto actions_response;
actions_response.add_actions()->mutable_reset();
EXPECT_CALL(mock_service_, OnGetActions(_, _, _, _, _, _))
.WillOnce(RunOnceCallback<5>(true, Serialize(actions_response)));
EXPECT_CALL(mock_service_, OnGetNextActions(_, _, _, _, _))
.WillOnce(RunOnceCallback<4>(true, ""));
EXPECT_CALL(executor_callback_,
Run(AllOf(Field(&ScriptExecutor::Result::success, true),
Field(&ScriptExecutor::Result::at_end,
ScriptExecutor::RESTART))));
executor_->Run(&user_data_, executor_callback_.Get());
}
TEST_F(ScriptExecutorTest, InterruptActionListOnError) { TEST_F(ScriptExecutorTest, InterruptActionListOnError) {
ActionsResponseProto initial_actions_response; ActionsResponseProto initial_actions_response;
initial_actions_response.add_actions()->mutable_tell()->set_message( initial_actions_response.add_actions()->mutable_tell()->set_message(
......
...@@ -468,7 +468,6 @@ message ActionProto { ...@@ -468,7 +468,6 @@ message ActionProto {
ShowProgressBarProto show_progress_bar = 24; ShowProgressBarProto show_progress_bar = 24;
HighlightElementProto highlight_element = 31; HighlightElementProto highlight_element = 31;
ShowDetailsProto show_details = 32; ShowDetailsProto show_details = 32;
ResetProto reset = 34;
StopProto stop = 35; StopProto stop = 35;
CollectUserDataProto collect_user_data = 36; CollectUserDataProto collect_user_data = 36;
SetAttributeProto set_attribute = 37; SetAttributeProto set_attribute = 37;
...@@ -486,7 +485,7 @@ message ActionProto { ...@@ -486,7 +485,7 @@ message ActionProto {
// action sent to the client after this one. Default is false. // action sent to the client after this one. Default is false.
optional bool clean_contextual_ui = 33; optional bool clean_contextual_ui = 33;
reserved 47; reserved 34, 47;
} }
// Result of |CollectUserDataProto| to be sent to the server. // Result of |CollectUserDataProto| to be sent to the server.
...@@ -1468,9 +1467,6 @@ message CollectUserDataProto { ...@@ -1468,9 +1467,6 @@ message CollectUserDataProto {
optional string info_section_text = 24; optional string info_section_text = 24;
} }
// Resets Autofill Assistant: clears any state and server payload.
message ResetProto {}
// Stop Autofill Assistant. // Stop Autofill Assistant.
message StopProto { message StopProto {
// If true, close the Chrome Custom Tab, in addition to shutting down Autofill // If true, close the Chrome Custom Tab, in addition to shutting down Autofill
......
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