Index: chrome/browser/chromeos/arc/notification/arc_notification_manager.cc |
diff --git a/chrome/browser/chromeos/arc/notification/arc_notification_manager.cc b/chrome/browser/chromeos/arc/notification/arc_notification_manager.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3971f6e8c43913a354e3f3ae7dc6ab7a432f8402 |
--- /dev/null |
+++ b/chrome/browser/chromeos/arc/notification/arc_notification_manager.cc |
@@ -0,0 +1,62 @@ |
+// Copyright 2015 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 "chrome/browser/chromeos/arc/notification/arc_notification_manager.h" |
+ |
+#include "chrome/browser/browser_process.h" |
+#include "chrome/browser/chromeos/arc/notification/arc_notification_item.h" |
+ |
+namespace chromeos { |
+ |
+ArcNotificationManager::ArcNotificationManager() { |
+ // This must be initialized after ArcBridgeService. |
+ DCHECK(arc::ArcBridgeService::Get()); |
+ arc::ArcBridgeService::Get()->AddObserver(this); |
+} |
+ |
+ArcNotificationManager::~ArcNotificationManager() {} |
khmel1
2015/11/25 00:30:10
No need to RemoveObserver(this) ?
yoshiki
2015/11/25 09:40:34
Done.
|
+ |
+void ArcNotificationManager::OnNotificationPostedFromAndroid( |
+ const arc::ArcNotificationData& data) { |
+ ArcNotificationItem* item = |
+ new ArcNotificationItem(this, g_browser_process->message_center(), data); |
+ items_.insert(make_pair(data.key, item)); |
khmel1
2015/11/25 00:30:10
What will be in case if manager deleted with pendi
yoshiki
2015/11/25 09:40:34
Done.
|
+} |
+ |
+void ArcNotificationManager::OnNotificationRemovedFromAndroid( |
+ const std::string& key) { |
+ Items::iterator it = items_.find(key); |
+ if (it != items_.end()) { |
+ ArcNotificationItem* item = it->second; |
+ items_.erase(it); |
+ |
+ item->OnClosedFromAndroid(); |
+ delete item; |
+ } |
+} |
+ |
+void ArcNotificationManager::NotifyNotificationRemovedFromChrome( |
+ const std::string& key) { |
+ Items::iterator it = items_.find(key); |
+ if (it != items_.end()) { |
khmel1
2015/11/25 00:30:10
Log error in case not found?
yoshiki
2015/11/25 09:40:35
This method may be called during OnNotificationRem
|
+ ArcNotificationItem* item = it->second; |
+ items_.erase(it); |
+ |
+ arc::ArcBridgeService::Get()->NotifyNotificationEvent( |
+ key, arc::NOTIFICATION_EVENT_CLOSED); |
+ delete item; |
+ } |
+} |
+ |
+void ArcNotificationManager::NotifyNotificationClickedFromChrome( |
+ const std::string& key) { |
+ Items::iterator it = items_.find(key); |
+ if (it != items_.end()) { |
+ LOG(ERROR) << "CLIOCKE: " << key; |
khmel1
2015/11/25 00:30:10
Debug print?
yoshiki
2015/11/25 09:40:34
Done.
|
+ arc::ArcBridgeService::Get()->NotifyNotificationEvent( |
+ key, arc::NOTIFICATION_EVENT_BODY_CLICKED); |
+ } |
+} |
+ |
+} // namespace chromeos |