Index: ui/arc/notification/arc_notification_item.h |
diff --git a/ui/arc/notification/arc_notification_item.h b/ui/arc/notification/arc_notification_item.h |
index 3df5e6aaed430ea60574cbbee2f3272f9408389c..84a9f35b511e1c58e78fd24d2b0deeac6159fc77 100644 |
--- a/ui/arc/notification/arc_notification_item.h |
+++ b/ui/arc/notification/arc_notification_item.h |
@@ -5,100 +5,56 @@ |
#ifndef UI_ARC_NOTIFICATION_ARC_NOTIFICATION_ITEM_H_ |
#define UI_ARC_NOTIFICATION_ARC_NOTIFICATION_ITEM_H_ |
-#include <memory> |
-#include <string> |
- |
#include "base/macros.h" |
-#include "base/memory/weak_ptr.h" |
-#include "base/threading/thread_checker.h" |
-#include "components/signin/core/account_id/account_id.h" |
-#include "third_party/skia/include/core/SkBitmap.h" |
-#include "ui/arc/notification/arc_notification_manager.h" |
-#include "ui/message_center/message_center.h" |
+#include "base/observer_list.h" |
+#include "components/arc/common/notifications.mojom.h" |
+#include "ui/gfx/image/image_skia.h" |
namespace arc { |
-// The class represents each ARC notification. One instance of this class |
-// corresponds to one ARC notification. |
class ArcNotificationItem { |
public: |
- ArcNotificationItem(ArcNotificationManager* manager, |
- message_center::MessageCenter* message_center, |
- const std::string& notification_key, |
- const AccountId& profile_id); |
- virtual ~ArcNotificationItem(); |
- |
- virtual void UpdateWithArcNotificationData( |
- mojom::ArcNotificationDataPtr data); |
- |
- // Methods called from ArcNotificationManager: |
- void OnClosedFromAndroid(); |
- |
- // Methods called from ArcNotificationItemDelegate: |
- void Close(bool by_user); |
- void Click(); |
- void ButtonClick(int button_index); |
- void OpenSettings(); |
+ class Observer { |
+ public: |
+ // Invoked when the notification data for this item has changed. |
+ virtual void OnItemDestroying() = 0; |
- const std::string& notification_key() const { return notification_key_; } |
+ // Invoked when the notification data for the item is updated. |
+ virtual void OnItemUpdated() = 0; |
- protected: |
- static int ConvertAndroidPriority(int android_priority); |
+ protected: |
+ virtual ~Observer() = default; |
+ }; |
- // Checks whether there is on-going |notification_|. |
- bool HasPendingNotification(); |
- // Cache the |data| in |newer_data_|. |
- void CacheArcNotificationData(mojom::ArcNotificationDataPtr data); |
+ virtual ~ArcNotificationItem() {} |
hidehiko
2017/03/02 15:38:16
ditto.
|
- // Sets the pending |notification_|. |
- void SetNotification( |
- std::unique_ptr<message_center::Notification> notification); |
- |
- // Add |notification_| to message center and update again if there is |
- // |newer_data_|. |
- void AddToMessageCenter(); |
- |
- bool CalledOnValidThread() const; |
- |
- const AccountId& profile_id() const { return profile_id_; } |
- const std::string& notification_id() const { return notification_id_; } |
- message_center::MessageCenter* message_center() { return message_center_; } |
- ArcNotificationManager* manager() { return manager_; } |
- |
- message_center::Notification* pending_notification() { |
- return notification_.get(); |
- } |
+ virtual void UpdateWithArcNotificationData( |
hidehiko
2017/03/02 15:38:16
As you change this to interface, could you documen
|
+ mojom::ArcNotificationDataPtr data) = 0; |
- private: |
- void OnImageDecoded(const SkBitmap& bitmap); |
+ // Methods called from ArcNotificationManager: |
+ virtual void OnClosedFromAndroid() = 0; |
- ArcNotificationManager* const manager_; |
- message_center::MessageCenter* const message_center_; |
- const AccountId profile_id_; |
+ // Methods called from ArcNotificationItemDelegate: |
+ virtual void Close(bool by_user) = 0; |
+ virtual void OpenSettings() = 0; |
- const std::string notification_key_; |
- const std::string notification_id_; |
+ virtual void CloseFromCloseButton() = 0; |
- // Stores on-going notification data during the image decoding. |
- // This field will be removed after removing async task of image decoding. |
- std::unique_ptr<message_center::Notification> notification_; |
+ virtual void AddObserver(Observer* observer) = 0; |
+ virtual void RemoveObserver(Observer* observer) = 0; |
- // The flag to indicate that the removing is initiated by the manager and we |
- // don't need to notify a remove event to the manager. |
- // This is true only when: |
- // (1) the notification is being removed |
- // (2) the removing is initiated by manager |
- bool being_removed_by_manager_ = false; |
+ // Increment |window_ref_count_| and a CreateNotificationWindow request |
+ // is sent when |window_ref_count_| goes from zero to one. |
+ virtual void IncrementWindowRefCount() = 0; |
- // Stores the latest notification data which is newer than the on-going data. |
- // If the on-going data is either none or the latest, this is null. |
- // This field will be removed after removing async task of image decoding. |
- mojom::ArcNotificationDataPtr newer_data_; |
+ // Decrement |window_ref_count_| and a CloseNotificationWindow request |
+ // is sent when |window_ref_count_| goes from one to zero. |
+ virtual void DecrementWindowRefCount() = 0; |
- base::ThreadChecker thread_checker_; |
- base::WeakPtrFactory<ArcNotificationItem> weak_ptr_factory_; |
+ virtual bool pinned() const = 0; |
+ virtual const gfx::ImageSkia& snapshot() const = 0; |
- DISALLOW_COPY_AND_ASSIGN(ArcNotificationItem); |
+ virtual const std::string& notification_key() const = 0; |
}; |
} // namespace arc |