Commit 67ace9dd authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

arc: notification: Forward window activation.

In ARC, activation of a window is mapped to activity stacking.
Notifications, which are not activities, are always placed at the top
of windows.

When an inline notification and an activity with an input field are
shown at the same time, it causes an issue because regardless of the
activity having focus, the notification always receives keyboard input.

In order to fix that, we have to forward ash side activation through
mojo and reflect it to the NOT_FOCUSABLE flag of notifications.

A Tast test for this will be added.

Android side CL: http://ag/9537575

TEST=manual (Follow the repro steps in the bug.)
BUG=b:142103828

Change-Id: Ifda5532b498ef9ea01ee70836813ae700a6ec58f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1855545Reviewed-by: default avatarGreg Kerr <kerrnel@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706235}
parent 4a392de9
......@@ -797,6 +797,13 @@ void ArcNotificationContentView::OnWidgetClosing(views::Widget* widget) {
}
}
void ArcNotificationContentView::OnWidgetActivationChanged(
views::Widget* widget,
bool active) {
if (item_)
item_->OnWindowActivated(active);
}
void ArcNotificationContentView::OnItemDestroying() {
item_->RemoveObserver(this);
item_ = nullptr;
......
......@@ -116,6 +116,7 @@ class ArcNotificationContentView
// views::WidgetObserver:
void OnWidgetClosing(views::Widget* widget) override;
void OnWidgetActivationChanged(views::Widget* widget, bool active) override;
// ArcNotificationItem::Observer
void OnItemDestroying() override;
......
......@@ -56,6 +56,9 @@ class ArcNotificationItem {
// Called when the user wants to toggle expansio of notification. This is
// called from ArcNotificationContentView.
virtual void ToggleExpansion() = 0;
// Called when the notification is activated i.e. starts accepting input for
// inline reply. Called from ArcNotificationContentView.
virtual void OnWindowActivated(bool activated) = 0;
// Called from ArcNotificationManager when the remote input textbox on
// notification is activated or deactivated.
......
......@@ -209,6 +209,10 @@ void ArcNotificationItemImpl::ToggleExpansion() {
manager_->SendNotificationToggleExpansionOnChrome(notification_key_);
}
void ArcNotificationItemImpl::OnWindowActivated(bool activated) {
manager_->SendNotificationActivatedInChrome(notification_key_, activated);
}
void ArcNotificationItemImpl::OnRemoteInputActivationChanged(bool activated) {
for (auto& observer : observers_)
observer.OnRemoteInputActivationChanged(activated);
......
......@@ -39,6 +39,7 @@ class ArcNotificationItemImpl : public ArcNotificationItem {
void OpenSettings() override;
void OpenSnooze() override;
void ToggleExpansion() override;
void OnWindowActivated(bool activated) override;
void OnRemoteInputActivationChanged(bool activated) override;
void AddObserver(Observer* observer) override;
void RemoveObserver(Observer* observer) override;
......
......@@ -376,6 +376,31 @@ void ArcNotificationManager::SendNotificationClickedOnChrome(
key, ArcNotificationEvent::BODY_CLICKED);
}
void ArcNotificationManager::SendNotificationActivatedInChrome(
const std::string& key,
bool activated) {
if (items_.find(key) == items_.end()) {
VLOG(3)
<< "Chrome requests to fire an activation event on notification (key: "
<< key << "), but it is gone.";
return;
}
auto* notifications_instance = ARC_GET_INSTANCE_FOR_METHOD(
instance_owner_->holder(), SendNotificationEventToAndroid);
// On shutdown, the ARC channel may quit earlier than notifications.
if (!notifications_instance) {
VLOG(2) << "ARC Notification (key: " << key
<< ") is (de)activated, but the ARC channel has already gone.";
return;
}
notifications_instance->SendNotificationEventToAndroid(
key, activated ? ArcNotificationEvent::ACTIVATED
: ArcNotificationEvent::DEACTIVATED);
}
void ArcNotificationManager::CreateNotificationWindow(const std::string& key) {
if (items_.find(key) == items_.end()) {
VLOG(3) << "Chrome requests to create window on notification (key: " << key
......
......@@ -62,6 +62,8 @@ class ArcNotificationManager
// Methods called from ArcNotificationItem:
void SendNotificationRemovedFromChrome(const std::string& key);
void SendNotificationClickedOnChrome(const std::string& key);
void SendNotificationActivatedInChrome(const std::string& key,
bool activated);
void CreateNotificationWindow(const std::string& key);
void CloseNotificationWindow(const std::string& key);
void OpenNotificationSettings(const std::string& key);
......
......@@ -39,6 +39,7 @@ class MockArcNotificationItem : public ArcNotificationItem {
void OnClosedFromAndroid() override {}
void Click() override {}
void ToggleExpansion() override {}
void OnWindowActivated(bool activated) override {}
void OpenSettings() override {}
void OpenSnooze() override {}
void IncrementWindowRefCount() override {}
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Next MinVersion: 24
// Next MinVersion: 25
module arc.mojom;
......@@ -23,6 +23,11 @@ enum ArcNotificationEvent {
DEPRECATED_BUTTON_5_CLICKED = 6,
// expand/collapse the bundled notification
[MinVersion=10] TOGGLE_EXPANSION = 7,
// The notification is activated/deactivated. Please note that they are sent
// only in limited instances e.g. when remote input opens, or when spoken
// feedback is enabled.
[MinVersion=24] ACTIVATED = 8,
[MinVersion=24] DEACTIVATED = 9,
};
[Extensible]
......
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