OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/views/ash/balloon_view_ash.h" | 5 #include "chrome/browser/ui/views/ash/balloon_view_ash.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/system/status_area_widget.h" | 8 #include "ash/system/status_area_widget.h" |
9 #include "ash/system/web_notification/web_notification_tray.h" | 9 #include "ash/system/web_notification/web_notification_tray.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 balloon_(NULL) { | 86 balloon_(NULL) { |
87 } | 87 } |
88 | 88 |
89 BalloonViewAsh::~BalloonViewAsh() { | 89 BalloonViewAsh::~BalloonViewAsh() { |
90 } | 90 } |
91 | 91 |
92 // BalloonView interface. | 92 // BalloonView interface. |
93 void BalloonViewAsh::Show(Balloon* balloon) { | 93 void BalloonViewAsh::Show(Balloon* balloon) { |
94 balloon_ = balloon; | 94 balloon_ = balloon; |
95 const Notification& notification = balloon_->notification(); | 95 const Notification& notification = balloon_->notification(); |
| 96 current_notification_id_ = notification.notification_id(); |
96 std::string extension_id = GetExtensionId(balloon); | 97 std::string extension_id = GetExtensionId(balloon); |
97 GetWebNotificationTray()->AddNotification(notification.notification_id(), | 98 GetWebNotificationTray()->AddNotification(current_notification_id_, |
98 notification.title(), | 99 notification.title(), |
99 notification.body(), | 100 notification.body(), |
100 notification.display_source(), | 101 notification.display_source(), |
101 extension_id); | 102 extension_id); |
102 FetchIcon(notification); | 103 FetchIcon(notification); |
103 } | 104 } |
104 | 105 |
105 void BalloonViewAsh::Update() { | 106 void BalloonViewAsh::Update() { |
106 const Notification& notification = balloon_->notification(); | 107 const Notification& notification = balloon_->notification(); |
107 GetWebNotificationTray()->UpdateNotification(notification.notification_id(), | 108 std::string new_notification_id = notification.notification_id(); |
| 109 GetWebNotificationTray()->UpdateNotification(current_notification_id_, |
| 110 new_notification_id, |
108 notification.title(), | 111 notification.title(), |
109 notification.body()); | 112 notification.body()); |
| 113 current_notification_id_ = new_notification_id; |
110 FetchIcon(notification); | 114 FetchIcon(notification); |
111 } | 115 } |
112 | 116 |
113 void BalloonViewAsh::RepositionToBalloon() { | 117 void BalloonViewAsh::RepositionToBalloon() { |
114 } | 118 } |
115 | 119 |
116 void BalloonViewAsh::Close(bool by_user) { | 120 void BalloonViewAsh::Close(bool by_user) { |
117 Notification notification(balloon_->notification()); // Copy notification | 121 Notification notification(balloon_->notification()); // Copy notification |
118 collection_->OnBalloonClosed(balloon_); // Deletes balloon. | 122 collection_->OnBalloonClosed(balloon_); // Deletes balloon. |
119 notification.Close(by_user); | 123 notification.Close(by_user); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 ExtensionService* extension_service = | 161 ExtensionService* extension_service = |
158 balloon_->profile()->GetExtensionService(); | 162 balloon_->profile()->GetExtensionService(); |
159 const GURL& origin = balloon_->notification().origin_url(); | 163 const GURL& origin = balloon_->notification().origin_url(); |
160 const extensions::Extension* extension = | 164 const extensions::Extension* extension = |
161 extension_service->extensions()->GetExtensionOrAppByURL( | 165 extension_service->extensions()->GetExtensionOrAppByURL( |
162 ExtensionURLInfo(origin)); | 166 ExtensionURLInfo(origin)); |
163 if (extension) | 167 if (extension) |
164 return extension->id(); | 168 return extension->id(); |
165 return std::string(); | 169 return std::string(); |
166 } | 170 } |
OLD | NEW |