Commit db1d60e1 authored by Mathias Carlen's avatar Mathias Carlen Committed by Commit Bot

[AA] Add PopupMessageAction.

This patch introduces a new action to display message popups (bubbles)
in the bottom sheet anchored at the icon.

R=arbesser@google.com

Bug: b/132863319
Change-Id: I51d2d885937e6e50e8273217c481b606be7a91d6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1681771
Commit-Queue: Mathias Carlen <mcarlen@chromium.org>
Reviewed-by: default avatarClemens Arbesser <arbesser@google.com>
Cr-Commit-Position: refs/heads/master@{#673345}
parent 7c07a853
...@@ -49,6 +49,8 @@ jumbo_static_library("browser") { ...@@ -49,6 +49,8 @@ jumbo_static_library("browser") {
"actions/highlight_element_action.h", "actions/highlight_element_action.h",
"actions/navigate_action.cc", "actions/navigate_action.cc",
"actions/navigate_action.h", "actions/navigate_action.h",
"actions/popup_message_action.cc",
"actions/popup_message_action.h",
"actions/prompt_action.cc", "actions/prompt_action.cc",
"actions/prompt_action.h", "actions/prompt_action.h",
"actions/reset_action.cc", "actions/reset_action.cc",
...@@ -168,6 +170,7 @@ source_set("unit_tests") { ...@@ -168,6 +170,7 @@ source_set("unit_tests") {
"actions/configure_bottom_sheet_action_unittest.cc", "actions/configure_bottom_sheet_action_unittest.cc",
"actions/mock_action_delegate.cc", "actions/mock_action_delegate.cc",
"actions/mock_action_delegate.h", "actions/mock_action_delegate.h",
"actions/popup_message_action_unittest.cc",
"actions/prompt_action_unittest.cc", "actions/prompt_action_unittest.cc",
"actions/wait_for_dom_action_unittest.cc", "actions/wait_for_dom_action_unittest.cc",
"batch_element_checker_unittest.cc", "batch_element_checker_unittest.cc",
......
...@@ -121,6 +121,9 @@ std::ostream& operator<<(std::ostream& out, ...@@ -121,6 +121,9 @@ std::ostream& operator<<(std::ostream& out,
case ActionProto::ActionInfoCase::kShowForm: case ActionProto::ActionInfoCase::kShowForm:
out << "ShowForm"; out << "ShowForm";
break; break;
case ActionProto::ActionInfoCase::kPopupMessage:
out << "PopupMessage";
break;
case ActionProto::ActionInfoCase::ACTION_INFO_NOT_SET: case ActionProto::ActionInfoCase::ACTION_INFO_NOT_SET:
out << "ACTION_INFO_NOT_SET"; out << "ACTION_INFO_NOT_SET";
break; break;
......
// Copyright 2019 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/popup_message_action.h"
#include <utility>
#include "base/bind.h"
#include "base/callback.h"
#include "components/autofill_assistant/browser/actions/action_delegate.h"
namespace autofill_assistant {
PopupMessageAction::PopupMessageAction(const ActionProto& proto)
: Action(proto) {}
PopupMessageAction::~PopupMessageAction() {}
void PopupMessageAction::InternalProcessAction(ActionDelegate* delegate,
ProcessActionCallback callback) {
delegate->SetBubbleMessage(proto_.popup_message().message());
UpdateProcessedAction(ACTION_APPLIED);
std::move(callback).Run(std::move(processed_action_proto_));
}
} // namespace autofill_assistant
// Copyright 2019 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_POPUP_MESSAGE_ACTION_H_
#define COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_ACTIONS_POPUP_MESSAGE_ACTION_H_
#include "base/macros.h"
#include "components/autofill_assistant/browser/actions/action.h"
namespace autofill_assistant {
// TODO: Action documentation.
// This action shows a popup message in the bottom bar anchored at the icon.
// The popup is just a Chrome TextBubble that is hidden when clicked. Also, a
// subsequent popup action will replace the message in the popup bubble, not add
// a second one.
class PopupMessageAction : public Action {
public:
explicit PopupMessageAction(const ActionProto& proto);
~PopupMessageAction() override;
private:
// Overrides Action:
void InternalProcessAction(ActionDelegate* delegate,
ProcessActionCallback callback) override;
DISALLOW_COPY_AND_ASSIGN(PopupMessageAction);
};
} // namespace autofill_assistant
#endif // COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_ACTIONS_POPUP_MESSAGE_ACTION_H_
// Copyright 2019 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/popup_message_action.h"
#include <string>
#include <utility>
#include "base/test/mock_callback.h"
#include "components/autofill_assistant/browser/actions/mock_action_delegate.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace autofill_assistant {
namespace {
using ::testing::InSequence;
using ::testing::Pointee;
using ::testing::Property;
class PopupMessageActionTest : public testing::Test {
public:
void SetUp() override { prompt_proto_ = proto_.mutable_popup_message(); }
protected:
MockActionDelegate mock_action_delegate_;
base::MockCallback<Action::ProcessActionCallback> callback_;
ActionProto proto_;
PopupMessageProto* prompt_proto_;
};
TEST_F(PopupMessageActionTest, NoMessage) {
{
InSequence seq;
EXPECT_CALL(mock_action_delegate_, SetBubbleMessage(""));
EXPECT_CALL(
callback_,
Run(Pointee(Property(&ProcessedActionProto::status, ACTION_APPLIED))));
}
PopupMessageAction action(proto_);
action.ProcessAction(&mock_action_delegate_, callback_.Get());
}
TEST_F(PopupMessageActionTest, WithMessage) {
const std::string message = "test bubble message";
{
InSequence seq;
EXPECT_CALL(mock_action_delegate_, SetBubbleMessage(message));
EXPECT_CALL(
callback_,
Run(Pointee(Property(&ProcessedActionProto::status, ACTION_APPLIED))));
}
prompt_proto_->set_message(message);
PopupMessageAction action(proto_);
action.ProcessAction(&mock_action_delegate_, callback_.Get());
}
} // namespace
} // namespace autofill_assistant
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "components/autofill_assistant/browser/actions/get_payment_information_action.h" #include "components/autofill_assistant/browser/actions/get_payment_information_action.h"
#include "components/autofill_assistant/browser/actions/highlight_element_action.h" #include "components/autofill_assistant/browser/actions/highlight_element_action.h"
#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/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/reset_action.h"
#include "components/autofill_assistant/browser/actions/select_option_action.h" #include "components/autofill_assistant/browser/actions/select_option_action.h"
...@@ -290,6 +291,10 @@ bool ProtocolUtils::ParseActions(const std::string& response, ...@@ -290,6 +291,10 @@ bool ProtocolUtils::ParseActions(const std::string& response,
client_action = std::make_unique<ShowFormAction>(action); client_action = std::make_unique<ShowFormAction>(action);
break; break;
} }
case ActionProto::ActionInfoCase::kPopupMessage: {
client_action = std::make_unique<PopupMessageAction>(action);
break;
}
case ActionProto::ActionInfoCase::ACTION_INFO_NOT_SET: { case ActionProto::ActionInfoCase::ACTION_INFO_NOT_SET: {
DVLOG(1) << "Encountered action with ACTION_INFO_NOT_SET"; DVLOG(1) << "Encountered action with ACTION_INFO_NOT_SET";
client_action = std::make_unique<UnsupportedAction>(action); client_action = std::make_unique<UnsupportedAction>(action);
......
...@@ -394,6 +394,7 @@ message ActionProto { ...@@ -394,6 +394,7 @@ message ActionProto {
WaitForNavigationProto wait_for_navigation = 41; WaitForNavigationProto wait_for_navigation = 41;
ConfigureBottomSheetProto configure_bottom_sheet = 42; ConfigureBottomSheetProto configure_bottom_sheet = 42;
ShowFormProto show_form = 43; ShowFormProto show_form = 43;
PopupMessageProto popup_message = 44;
} }
// Set to true to make the client remove any contextual information if the // Set to true to make the client remove any contextual information if the
...@@ -1446,3 +1447,11 @@ message DirectActionProto { ...@@ -1446,3 +1447,11 @@ message DirectActionProto {
// Map to direct actions with the given names. // Map to direct actions with the given names.
repeated string names = 12; repeated string names = 12;
} }
// Action to show a popup bubble on top of the bottom sheet, anchored at the
// icon. Setting an empty message will remove any existing and visible popup
// message. A second action replaces a previously shown message.
message PopupMessageProto {
// Message to show in the popup.
optional string message = 1;
}
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