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/notifications/notification_object_proxy.h" | 5 #include "chrome/browser/notifications/notification_object_proxy.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "base/strings/stringprintf.h" | |
9 #include "content/public/browser/desktop_notification_delegate.h" | 8 #include "content/public/browser/desktop_notification_delegate.h" |
10 #include "content/public/browser/render_frame_host.h" | |
11 #include "content/public/browser/render_process_host.h" | |
12 #include "content/public/browser/web_contents.h" | |
13 | 9 |
14 NotificationObjectProxy::NotificationObjectProxy( | 10 NotificationObjectProxy::NotificationObjectProxy( |
15 scoped_ptr<content::DesktopNotificationDelegate> delegate) | 11 scoped_ptr<content::DesktopNotificationDelegate> delegate) |
16 : delegate_(delegate.Pass()), | 12 : delegate_(delegate.Pass()), |
17 displayed_(false), | 13 displayed_(false), |
18 id_(base::GenerateGUID()) { | 14 id_(base::GenerateGUID()) {} |
19 } | |
20 | 15 |
21 NotificationObjectProxy::~NotificationObjectProxy() {} | 16 NotificationObjectProxy::~NotificationObjectProxy() {} |
22 | 17 |
23 void NotificationObjectProxy::Display() { | 18 void NotificationObjectProxy::Display() { |
24 // This method is called each time the notification is shown to the user | 19 // This method is called each time the notification is shown to the user |
25 // but we only want to fire the event the first time. | 20 // but we only want to fire the event the first time. |
26 if (displayed_) | 21 if (displayed_) |
27 return; | 22 return; |
28 displayed_ = true; | 23 displayed_ = true; |
29 | 24 |
30 delegate_->NotificationDisplayed(); | 25 delegate_->NotificationDisplayed(); |
31 } | 26 } |
32 | 27 |
33 void NotificationObjectProxy::Error() { | 28 void NotificationObjectProxy::Error() { |
34 delegate_->NotificationError(); | 29 delegate_->NotificationError(); |
35 } | 30 } |
36 | 31 |
37 void NotificationObjectProxy::Close(bool by_user) { | 32 void NotificationObjectProxy::Close(bool by_user) { |
38 delegate_->NotificationClosed(by_user); | 33 delegate_->NotificationClosed(by_user); |
39 } | 34 } |
40 | 35 |
41 void NotificationObjectProxy::Click() { | 36 void NotificationObjectProxy::Click() { |
42 delegate_->NotificationClick(); | 37 delegate_->NotificationClick(); |
43 } | 38 } |
44 | 39 |
45 std::string NotificationObjectProxy::id() const { | 40 std::string NotificationObjectProxy::id() const { |
46 return id_; | 41 return id_; |
47 } | 42 } |
OLD | NEW |