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

Unified Diff: chrome/browser/chromeos/arc/notification/arc_notification_manager.cc

Issue 1475583002: Add IPC messages for ARC notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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: 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

Powered by Google App Engine
This is Rietveld 408576698