OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/chromeos/arc/notification/arc_notification_manager.h" | |
6 | |
7 #include "chrome/browser/browser_process.h" | |
8 #include "chrome/browser/chromeos/arc/notification/arc_notification_item.h" | |
9 | |
10 namespace chromeos { | |
11 | |
12 ArcNotificationManager::ArcNotificationManager() { | |
13 // This must be initialized after ArcBridgeService. | |
14 DCHECK(arc::ArcBridgeService::Get()); | |
15 arc::ArcBridgeService::Get()->AddObserver(this); | |
16 } | |
17 | |
18 ArcNotificationManager::~ArcNotificationManager() {} | |
khmel1
2015/11/25 00:30:10
No need to RemoveObserver(this) ?
yoshiki
2015/11/25 09:40:34
Done.
| |
19 | |
20 void ArcNotificationManager::OnNotificationPostedFromAndroid( | |
21 const arc::ArcNotificationData& data) { | |
22 ArcNotificationItem* item = | |
23 new ArcNotificationItem(this, g_browser_process->message_center(), data); | |
24 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.
| |
25 } | |
26 | |
27 void ArcNotificationManager::OnNotificationRemovedFromAndroid( | |
28 const std::string& key) { | |
29 Items::iterator it = items_.find(key); | |
30 if (it != items_.end()) { | |
31 ArcNotificationItem* item = it->second; | |
32 items_.erase(it); | |
33 | |
34 item->OnClosedFromAndroid(); | |
35 delete item; | |
36 } | |
37 } | |
38 | |
39 void ArcNotificationManager::NotifyNotificationRemovedFromChrome( | |
40 const std::string& key) { | |
41 Items::iterator it = items_.find(key); | |
42 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
| |
43 ArcNotificationItem* item = it->second; | |
44 items_.erase(it); | |
45 | |
46 arc::ArcBridgeService::Get()->NotifyNotificationEvent( | |
47 key, arc::NOTIFICATION_EVENT_CLOSED); | |
48 delete item; | |
49 } | |
50 } | |
51 | |
52 void ArcNotificationManager::NotifyNotificationClickedFromChrome( | |
53 const std::string& key) { | |
54 Items::iterator it = items_.find(key); | |
55 if (it != items_.end()) { | |
56 LOG(ERROR) << "CLIOCKE: " << key; | |
khmel1
2015/11/25 00:30:10
Debug print?
yoshiki
2015/11/25 09:40:34
Done.
| |
57 arc::ArcBridgeService::Get()->NotifyNotificationEvent( | |
58 key, arc::NOTIFICATION_EVENT_BODY_CLICKED); | |
59 } | |
60 } | |
61 | |
62 } // namespace chromeos | |
OLD | NEW |