| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/desktop_notification_handler.h" | 5 #include "chrome/browser/desktop_notification_handler.h" |
| 6 | 6 |
| 7 #include "chrome/browser/notifications/desktop_notification_service.h" | 7 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 8 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | |
| 9 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 10 #include "content/browser/renderer_host/render_process_host.h" | 9 #include "content/browser/renderer_host/render_process_host.h" |
| 11 #include "content/browser/renderer_host/render_view_host.h" | 10 #include "content/browser/renderer_host/render_view_host.h" |
| 12 #include "content/browser/renderer_host/render_view_host_delegate.h" | 11 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 13 #include "content/common/desktop_notification_messages.h" | 12 #include "content/common/desktop_notification_messages.h" |
| 14 | 13 |
| 15 DesktopNotificationHandler::DesktopNotificationHandler( | 14 DesktopNotificationHandler::DesktopNotificationHandler( |
| 16 RenderViewHost* render_view_host) | 15 RenderViewHost* render_view_host) |
| 17 : RenderViewHostObserver(render_view_host) { | 16 : RenderViewHostObserver(render_view_host) { |
| 18 } | 17 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 32 IPC_MESSAGE_UNHANDLED(handled = false) | 31 IPC_MESSAGE_UNHANDLED(handled = false) |
| 33 IPC_END_MESSAGE_MAP() | 32 IPC_END_MESSAGE_MAP() |
| 34 | 33 |
| 35 return handled; | 34 return handled; |
| 36 } | 35 } |
| 37 | 36 |
| 38 void DesktopNotificationHandler::OnShow( | 37 void DesktopNotificationHandler::OnShow( |
| 39 const DesktopNotificationHostMsg_Show_Params& params) { | 38 const DesktopNotificationHostMsg_Show_Params& params) { |
| 40 RenderProcessHost* process = render_view_host()->process(); | 39 RenderProcessHost* process = render_view_host()->process(); |
| 41 DesktopNotificationService* service = | 40 DesktopNotificationService* service = |
| 42 DesktopNotificationServiceFactory::GetForProfile(process->profile()); | 41 process->profile()->GetDesktopNotificationService(); |
| 43 | 42 |
| 44 service->ShowDesktopNotification( | 43 service->ShowDesktopNotification( |
| 45 params, | 44 params, |
| 46 process->id(), | 45 process->id(), |
| 47 routing_id(), | 46 routing_id(), |
| 48 DesktopNotificationService::PageNotification); | 47 DesktopNotificationService::PageNotification); |
| 49 } | 48 } |
| 50 | 49 |
| 51 void DesktopNotificationHandler::OnCancel(int notification_id) { | 50 void DesktopNotificationHandler::OnCancel(int notification_id) { |
| 52 RenderProcessHost* process = render_view_host()->process(); | 51 RenderProcessHost* process = render_view_host()->process(); |
| 53 DesktopNotificationService* service = | 52 DesktopNotificationService* service = |
| 54 DesktopNotificationServiceFactory::GetForProfile(process->profile()); | 53 process->profile()->GetDesktopNotificationService(); |
| 55 | 54 |
| 56 service->CancelDesktopNotification( | 55 service->CancelDesktopNotification( |
| 57 process->id(), | 56 process->id(), |
| 58 routing_id(), | 57 routing_id(), |
| 59 notification_id); | 58 notification_id); |
| 60 } | 59 } |
| 61 | 60 |
| 62 void DesktopNotificationHandler::OnRequestPermission( | 61 void DesktopNotificationHandler::OnRequestPermission( |
| 63 const GURL& source_origin, int callback_context) { | 62 const GURL& source_origin, int callback_context) { |
| 64 if (render_view_host()->delegate()->RequestDesktopNotificationPermission( | 63 if (render_view_host()->delegate()->RequestDesktopNotificationPermission( |
| 65 source_origin, callback_context)) { | 64 source_origin, callback_context)) { |
| 66 return; | 65 return; |
| 67 } | 66 } |
| 68 | 67 |
| 69 RenderProcessHost* process = render_view_host()->process(); | 68 RenderProcessHost* process = render_view_host()->process(); |
| 70 DesktopNotificationService* service = | 69 DesktopNotificationService* service = |
| 71 DesktopNotificationServiceFactory::GetForProfile(process->profile()); | 70 process->profile()->GetDesktopNotificationService(); |
| 72 service->RequestPermission( | 71 service->RequestPermission( |
| 73 source_origin, process->id(), routing_id(), callback_context, NULL); | 72 source_origin, process->id(), routing_id(), callback_context, NULL); |
| 74 } | 73 } |
| OLD | NEW |