Commit af6a1592 authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Add non-UI part support of notification inline reply.

A web notification with the inline reply actions is already implemented
on Android and Windows 10 native notifications.
In order to support the feature on Chrome OS, we have to implement it
in the views framework notification implementation.

This CL adds the non user interface part of the notification inline
reply support.

TEST=manual
BUG=599859,773586

Change-Id: Ib6079f8dadd5e154e68a5c32b5c99df2fb100499
Reviewed-on: https://chromium-review.googlesource.com/756184Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516969}
parent c66b9c91
......@@ -471,6 +471,14 @@ void MessageCenterView::ClickOnNotificationButton(
message_center_->ClickOnNotificationButton(notification_id, button_index);
}
void MessageCenterView::ClickOnNotificationButtonWithReply(
const std::string& notification_id,
int button_index,
const base::string16& reply) {
message_center_->ClickOnNotificationButtonWithReply(notification_id,
button_index, reply);
}
void MessageCenterView::ClickOnSettingsButton(
const std::string& notification_id) {
message_center_->ClickOnSettingsButton(notification_id);
......
......@@ -107,6 +107,9 @@ class ASH_EXPORT MessageCenterView
const message_center::Notification& notification) override;
void ClickOnNotificationButton(const std::string& notification_id,
int button_index) override;
void ClickOnNotificationButtonWithReply(const std::string& notification_id,
int button_index,
const base::string16& reply) override;
void ClickOnSettingsButton(const std::string& notification_id) override;
void UpdateNotificationSize(const std::string& notification_id) override;
......
......@@ -199,6 +199,9 @@ class MessageCenterViewTest : public AshTestBase,
const Notification& notification) override;
void ClickOnNotificationButton(const std::string& notification_id,
int button_index) override;
void ClickOnNotificationButtonWithReply(const std::string& notification_id,
int button_index,
const base::string16& reply) override;
void ClickOnSettingsButton(const std::string& notification_id) override;
void UpdateNotificationSize(const std::string& notification_id) override;
......@@ -391,6 +394,14 @@ void MessageCenterViewTest::ClickOnNotificationButton(
NOTREACHED();
}
void MessageCenterViewTest::ClickOnNotificationButtonWithReply(
const std::string& notification_id,
int button_index,
const base::string16& reply) {
// For this test, this method should not be invoked.
NOTREACHED();
}
void MessageCenterViewTest::ClickOnSettingsButton(
const std::string& notification_id) {
// For this test, this method should not be invoked.
......
......@@ -187,6 +187,10 @@ class MessageListViewTest : public AshTestBase,
}
void ClickOnNotificationButton(const std::string& notification_id,
int button_index) override {}
void ClickOnNotificationButtonWithReply(
const std::string& notification_id,
int button_index,
const base::string16& reply) override {}
void ClickOnSettingsButton(const std::string& notification_id) override {}
void UpdateNotificationSize(const std::string& notification_id) override;
......
......@@ -148,6 +148,14 @@ class TestMessageViewDelegate : public message_center::MessageViewDelegate {
NOTREACHED();
}
void ClickOnNotificationButtonWithReply(
const std::string& notification_id,
int button_index,
const base::string16& reply) override {
// For this test, this method should not be invoked.
NOTREACHED();
}
void ClickOnSettingsButton(const std::string& notification_id) override {
// For this test, this method should not be invoked.
NOTREACHED();
......
......@@ -123,6 +123,14 @@ class TestMessageViewDelegate : public message_center::MessageViewDelegate {
NOTREACHED();
}
void ClickOnNotificationButtonWithReply(
const std::string& notification_id,
int button_index,
const base::string16& reply) override {
// For this test, this method should not be invoked.
NOTREACHED();
}
void ClickOnSettingsButton(const std::string& notification_id) override {
// For this test, this method should not be invoked.
NOTREACHED();
......
......@@ -95,6 +95,11 @@ void FakeMessageCenter::ClickOnNotificationButton(const std::string& id,
int button_index) {
}
void FakeMessageCenter::ClickOnNotificationButtonWithReply(
const std::string& id,
int button_index,
const base::string16& reply) {}
void FakeMessageCenter::ClickOnSettingsButton(const std::string& id) {}
void FakeMessageCenter::MarkSinglePopupAsShown(const std::string& id,
......
......@@ -51,6 +51,9 @@ class FakeMessageCenter : public MessageCenter {
void ClickOnNotification(const std::string& id) override;
void ClickOnNotificationButton(const std::string& id,
int button_index) override;
void ClickOnNotificationButtonWithReply(const std::string& id,
int button_index,
const base::string16& reply) override;
void ClickOnSettingsButton(const std::string& id) override;
void MarkSinglePopupAsShown(const std::string& id,
bool mark_notification_as_read) override;
......
......@@ -131,6 +131,14 @@ class MESSAGE_CENTER_EXPORT MessageCenter {
virtual void ClickOnNotificationButton(const std::string& id,
int button_index) = 0;
// This should be called by UI classes when a notification button with an
// input is clicked to trigger the notification's delegate callback and also
// update the message center observers.
virtual void ClickOnNotificationButtonWithReply(
const std::string& id,
int button_index,
const base::string16& reply) = 0;
// Called by the UI classes when the settings buttons is clicked
// to trigger the notification's delegate and update the message
// center observers.
......
......@@ -479,7 +479,7 @@ void MessageCenterImpl::ClickOnNotificationButton(const std::string& id,
int button_index) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(!iterating_);
if (FindVisibleNotificationById(id) == NULL)
if (!FindVisibleNotificationById(id))
return;
#if defined(OS_CHROMEOS)
if (HasPopupNotifications())
......@@ -496,6 +496,28 @@ void MessageCenterImpl::ClickOnNotificationButton(const std::string& id,
}
}
void MessageCenterImpl::ClickOnNotificationButtonWithReply(
const std::string& id,
int button_index,
const base::string16& reply) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (!FindVisibleNotificationById(id))
return;
#if defined(OS_CHROMEOS)
if (HasPopupNotifications())
MarkSinglePopupAsShown(id, true);
#endif
scoped_refptr<NotificationDelegate> delegate =
notification_list_->GetNotificationDelegate(id);
if (delegate.get())
delegate->ButtonClickWithReply(button_index, reply);
{
internal::ScopedNotificationsIterationLock lock(this);
for (auto& observer : observer_list_)
observer.OnNotificationButtonClickedWithReply(id, button_index, reply);
}
}
void MessageCenterImpl::ClickOnSettingsButton(const std::string& id) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(!iterating_);
......
......@@ -69,6 +69,9 @@ class MESSAGE_CENTER_EXPORT MessageCenterImpl
void ClickOnNotification(const std::string& id) override;
void ClickOnNotificationButton(const std::string& id,
int button_index) override;
void ClickOnNotificationButtonWithReply(const std::string& id,
int button_index,
const base::string16& reply) override;
void ClickOnSettingsButton(const std::string& id) override;
void MarkSinglePopupAsShown(const std::string& id,
bool mark_notification_as_read) override;
......
......@@ -40,6 +40,13 @@ class MESSAGE_CENTER_EXPORT MessageCenterObserver {
virtual void OnNotificationButtonClicked(const std::string& notification_id,
int button_index) {}
// Called when a click event happens on a button with an input indexed by
// |button_index| of the notification associated with |notification_id|.
virtual void OnNotificationButtonClickedWithReply(
const std::string& notification_id,
int button_index,
const base::string16& reply) {}
// Called when notification settings button is clicked. The |handled| argument
// indicates whether the notification delegate already handled the operation.
virtual void OnNotificationSettingsClicked(bool handled) {}
......
......@@ -114,6 +114,14 @@ void MessagePopupCollection::ClickOnNotificationButton(
message_center_->ClickOnNotificationButton(notification_id, button_index);
}
void MessagePopupCollection::ClickOnNotificationButtonWithReply(
const std::string& notification_id,
int button_index,
const base::string16& reply) {
message_center_->ClickOnNotificationButtonWithReply(notification_id,
button_index, reply);
}
void MessagePopupCollection::ClickOnSettingsButton(
const std::string& notification_id) {
message_center_->ClickOnSettingsButton(notification_id);
......
......@@ -65,6 +65,9 @@ class MESSAGE_CENTER_EXPORT MessagePopupCollection
const Notification& notification) override;
void ClickOnNotificationButton(const std::string& notification_id,
int button_index) override;
void ClickOnNotificationButtonWithReply(const std::string& notification_id,
int button_index,
const base::string16& reply) override;
void ClickOnSettingsButton(const std::string& notification_id) override;
void UpdateNotificationSize(const std::string& notification_id) override;
......
......@@ -27,6 +27,10 @@ class MessageViewDelegate {
const Notification& notification) = 0;
virtual void ClickOnNotificationButton(const std::string& notification_id,
int button_index) = 0;
virtual void ClickOnNotificationButtonWithReply(
const std::string& notification_id,
int button_index,
const base::string16& reply) = 0;
virtual void ClickOnSettingsButton(const std::string& notification_id) = 0;
// For ArcCustomNotificationView, size changes might come after the
// notification update over Mojo. Provide a method here to notify when
......
......@@ -50,6 +50,9 @@ class NotificationViewMDTest : public views::ViewsTestBase,
const Notification& notification) override;
void ClickOnNotificationButton(const std::string& notification_id,
int button_index) override;
void ClickOnNotificationButtonWithReply(const std::string& notification_id,
int button_index,
const base::string16& reply) override;
void ClickOnSettingsButton(const std::string& notification_id) override;
void UpdateNotificationSize(const std::string& notification_id) override;
......@@ -156,6 +159,14 @@ void NotificationViewMDTest::ClickOnNotificationButton(
NOTREACHED();
}
void NotificationViewMDTest::ClickOnNotificationButtonWithReply(
const std::string& notification_id,
int button_index,
const base::string16& reply) {
// For this test, this method should not be invoked.
NOTREACHED();
}
void NotificationViewMDTest::ClickOnSettingsButton(
const std::string& notification_id) {
// For this test, this method should not be invoked.
......
......@@ -71,6 +71,9 @@ class NotificationViewTest : public views::ViewsTestBase,
const Notification& notification) override;
void ClickOnNotificationButton(const std::string& notification_id,
int button_index) override;
void ClickOnNotificationButtonWithReply(const std::string& notification_id,
int button_index,
const base::string16& reply) override;
void ClickOnSettingsButton(const std::string& notification_id) override;
void UpdateNotificationSize(const std::string& notification_id) override;
......@@ -290,6 +293,14 @@ void NotificationViewTest::ClickOnNotificationButton(
NOTREACHED();
}
void NotificationViewTest::ClickOnNotificationButtonWithReply(
const std::string& notification_id,
int button_index,
const base::string16& reply) {
// For this test, this method should not be invoked.
NOTREACHED();
}
void NotificationViewTest::ClickOnSettingsButton(
const std::string& notification_id) {
// For this test, this method should not be invoked.
......
......@@ -372,6 +372,15 @@ void ToastContentsView::ClickOnNotificationButton(
collection_->ClickOnNotificationButton(notification_id, button_index);
}
void ToastContentsView::ClickOnNotificationButtonWithReply(
const std::string& notification_id,
int button_index,
const base::string16& reply) {
if (collection_)
collection_->ClickOnNotificationButtonWithReply(notification_id,
button_index, reply);
}
void ToastContentsView::CreateWidget(
PopupAlignmentDelegate* alignment_delegate) {
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
......
......@@ -101,6 +101,9 @@ class MESSAGE_CENTER_EXPORT ToastContentsView
const Notification& notification) override;
void ClickOnNotificationButton(const std::string& notification_id,
int button_index) override;
void ClickOnNotificationButtonWithReply(const std::string& notification_id,
int button_index,
const base::string16& reply) override;
void ClickOnSettingsButton(const std::string& notification_id) override;
void UpdateNotificationSize(const std::string& notification_id) override;
......
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