Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Unified Diff: ui/arc/notification/arc_custom_notification_item.cc

Issue 2093563007: Add a floating close button for arc custom notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/arc/notification/arc_custom_notification_item.cc
diff --git a/ui/arc/notification/arc_custom_notification_item.cc b/ui/arc/notification/arc_custom_notification_item.cc
index ac60ba8b97b68297fff936677fd9e203e8fd9772..153cf3e6a69ba2c9ba35c90fa4d0ff2051fbd98b 100644
--- a/ui/arc/notification/arc_custom_notification_item.cc
+++ b/ui/arc/notification/arc_custom_notification_item.cc
@@ -20,13 +20,14 @@ constexpr char kNotifierId[] = "ARC_NOTIFICATION";
class ArcNotificationDelegate : public message_center::NotificationDelegate {
public:
- ArcNotificationDelegate() {}
+ explicit ArcNotificationDelegate(ArcCustomNotificationItem* item)
+ : item_(item) {}
std::unique_ptr<views::View> CreateCustomContent() override {
if (!surface_)
return nullptr;
- return base::MakeUnique<ArcCustomNotificationView>(surface_);
+ return base::MakeUnique<ArcCustomNotificationView>(item_, surface_);
}
void set_notification_surface(exo::NotificationSurface* surface) {
@@ -37,6 +38,7 @@ class ArcNotificationDelegate : public message_center::NotificationDelegate {
// The destructor is private since this class is ref-counted.
~ArcNotificationDelegate() override {}
+ ArcCustomNotificationItem* const item_;
exo::NotificationSurface* surface_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(ArcNotificationDelegate);
@@ -57,6 +59,8 @@ ArcCustomNotificationItem::ArcCustomNotificationItem(
ArcCustomNotificationItem::~ArcCustomNotificationItem() {
if (ArcNotificationSurfaceManager::Get())
ArcNotificationSurfaceManager::Get()->RemoveObserver(this);
+
+ FOR_EACH_OBSERVER(Observer, observers_, OnItemDestroying());
}
void ArcCustomNotificationItem::UpdateWithArcNotificationData(
@@ -83,7 +87,7 @@ void ArcCustomNotificationItem::UpdateWithArcNotificationData(
base::UTF8ToUTF16(data.message.get()), gfx::Image(),
base::UTF8ToUTF16("arc"), // display source
GURL(), // empty origin url, for system component
- notifier_id, rich_data, new ArcNotificationDelegate()));
+ notifier_id, rich_data, new ArcNotificationDelegate(this)));
exo::NotificationSurface* surface =
ArcNotificationSurfaceManager::Get()->GetSurface(notification_key());
@@ -91,6 +95,24 @@ void ArcCustomNotificationItem::UpdateWithArcNotificationData(
OnNotificationSurfaceAdded(surface);
else
ArcNotificationSurfaceManager::Get()->AddObserver(this);
+
+ pinned_ = rich_data.pinned;
+ FOR_EACH_OBSERVER(Observer, observers_, OnItemPinnedChanged());
+}
+
+void ArcCustomNotificationItem::CloseFromCloseButton() {
+ // Needs to manually remove notification from MessageCenter because
+ // the floating close button is not part of MessageCenter.
+ message_center()->RemoveNotification(notification_id(), true);
+ Close(true);
+}
+
+void ArcCustomNotificationItem::AddObserver(Observer* observer) {
+ observers_.AddObserver(observer);
+}
+
+void ArcCustomNotificationItem::RemoveObserver(Observer* observer) {
+ observers_.RemoveObserver(observer);
}
void ArcCustomNotificationItem::OnNotificationSurfaceAdded(
« no previous file with comments | « ui/arc/notification/arc_custom_notification_item.h ('k') | ui/arc/notification/arc_custom_notification_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698