OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/metrics/user_metrics_action.h" | 10 #include "base/metrics/user_metrics_action.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 83 } |
84 | 84 |
85 virtual void NotificationError() OVERRIDE { | 85 virtual void NotificationError() OVERRIDE { |
86 RenderFrameHost* rfh = | 86 RenderFrameHost* rfh = |
87 RenderFrameHost::FromID(render_process_id_, render_frame_id_); | 87 RenderFrameHost::FromID(render_process_id_, render_frame_id_); |
88 if (!rfh) | 88 if (!rfh) |
89 return; | 89 return; |
90 | 90 |
91 rfh->Send(new DesktopNotificationMsg_PostError( | 91 rfh->Send(new DesktopNotificationMsg_PostError( |
92 rfh->GetRoutingID(), notification_id_)); | 92 rfh->GetRoutingID(), notification_id_)); |
93 delete this; | |
94 } | 93 } |
95 | 94 |
96 virtual void NotificationClosed(bool by_user) OVERRIDE { | 95 virtual void NotificationClosed(bool by_user) OVERRIDE { |
97 RenderFrameHost* rfh = | 96 RenderFrameHost* rfh = |
98 RenderFrameHost::FromID(render_process_id_, render_frame_id_); | 97 RenderFrameHost::FromID(render_process_id_, render_frame_id_); |
99 if (!rfh) | 98 if (!rfh) |
100 return; | 99 return; |
101 | 100 |
102 rfh->Send(new DesktopNotificationMsg_PostClose( | 101 rfh->Send(new DesktopNotificationMsg_PostClose( |
103 rfh->GetRoutingID(), notification_id_, by_user)); | 102 rfh->GetRoutingID(), notification_id_, by_user)); |
104 static_cast<RenderFrameHostImpl*>(rfh)->NotificationClosed( | 103 static_cast<RenderFrameHostImpl*>(rfh)->NotificationClosed( |
105 notification_id_); | 104 notification_id_); |
106 delete this; | |
107 } | 105 } |
108 | 106 |
109 virtual void NotificationClick() OVERRIDE { | 107 virtual void NotificationClick() OVERRIDE { |
110 RenderFrameHost* rfh = | 108 RenderFrameHost* rfh = |
111 RenderFrameHost::FromID(render_process_id_, render_frame_id_); | 109 RenderFrameHost::FromID(render_process_id_, render_frame_id_); |
112 if (!rfh) | 110 if (!rfh) |
113 return; | 111 return; |
114 | 112 |
115 rfh->Send(new DesktopNotificationMsg_PostClick( | 113 rfh->Send(new DesktopNotificationMsg_PostClick( |
116 rfh->GetRoutingID(), notification_id_)); | 114 rfh->GetRoutingID(), notification_id_)); |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 weak_ptr_factory_.GetWeakPtr(), | 824 weak_ptr_factory_.GetWeakPtr(), |
827 callback_context); | 825 callback_context); |
828 | 826 |
829 GetContentClient()->browser()->RequestDesktopNotificationPermission( | 827 GetContentClient()->browser()->RequestDesktopNotificationPermission( |
830 source_origin, this, done_callback); | 828 source_origin, this, done_callback); |
831 } | 829 } |
832 | 830 |
833 void RenderFrameHostImpl::OnShowDesktopNotification( | 831 void RenderFrameHostImpl::OnShowDesktopNotification( |
834 int notification_id, | 832 int notification_id, |
835 const ShowDesktopNotificationHostMsgParams& params) { | 833 const ShowDesktopNotificationHostMsgParams& params) { |
| 834 scoped_ptr<DesktopNotificationDelegateImpl> delegate( |
| 835 new DesktopNotificationDelegateImpl(this, notification_id)); |
| 836 |
836 base::Closure cancel_callback; | 837 base::Closure cancel_callback; |
837 GetContentClient()->browser()->ShowDesktopNotification( | 838 GetContentClient()->browser()->ShowDesktopNotification( |
838 params, this, | 839 params, |
839 new DesktopNotificationDelegateImpl(this, notification_id), | 840 this, |
| 841 delegate.PassAs<DesktopNotificationDelegate>(), |
840 &cancel_callback); | 842 &cancel_callback); |
841 cancel_notification_callbacks_[notification_id] = cancel_callback; | 843 cancel_notification_callbacks_[notification_id] = cancel_callback; |
842 } | 844 } |
843 | 845 |
844 void RenderFrameHostImpl::OnCancelDesktopNotification(int notification_id) { | 846 void RenderFrameHostImpl::OnCancelDesktopNotification(int notification_id) { |
845 if (!cancel_notification_callbacks_.count(notification_id)) { | 847 if (!cancel_notification_callbacks_.count(notification_id)) { |
846 NOTREACHED(); | 848 NOTREACHED(); |
847 return; | 849 return; |
848 } | 850 } |
849 cancel_notification_callbacks_[notification_id].Run(); | 851 cancel_notification_callbacks_[notification_id].Run(); |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 FROM_HERE, | 1193 FROM_HERE, |
1192 base::Bind( | 1194 base::Bind( |
1193 &TransitionRequestManager::SetHasPendingTransitionRequest, | 1195 &TransitionRequestManager::SetHasPendingTransitionRequest, |
1194 base::Unretained(TransitionRequestManager::GetInstance()), | 1196 base::Unretained(TransitionRequestManager::GetInstance()), |
1195 GetProcess()->GetID(), | 1197 GetProcess()->GetID(), |
1196 routing_id_, | 1198 routing_id_, |
1197 has_pending_request)); | 1199 has_pending_request)); |
1198 } | 1200 } |
1199 | 1201 |
1200 } // namespace content | 1202 } // namespace content |
OLD | NEW |