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" | 8 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/common/url_constants.h" |
10 #include "content/browser/renderer_host/render_process_host.h" | 11 #include "content/browser/renderer_host/render_process_host.h" |
11 #include "content/browser/renderer_host/render_view_host.h" | 12 #include "content/browser/renderer_host/render_view_host.h" |
12 #include "content/browser/renderer_host/render_view_host_delegate.h" | 13 #include "content/browser/renderer_host/render_view_host_delegate.h" |
13 #include "content/common/desktop_notification_messages.h" | 14 #include "content/common/desktop_notification_messages.h" |
14 | 15 |
15 DesktopNotificationHandler::DesktopNotificationHandler( | 16 DesktopNotificationHandler::DesktopNotificationHandler( |
16 RenderViewHost* render_view_host) | 17 RenderViewHost* render_view_host) |
17 : RenderViewHostObserver(render_view_host) { | 18 : RenderViewHostObserver(render_view_host) { |
18 } | 19 } |
19 | 20 |
(...skipping 10 matching lines...) Expand all Loading... |
30 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission, | 31 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission, |
31 OnRequestPermission) | 32 OnRequestPermission) |
32 IPC_MESSAGE_UNHANDLED(handled = false) | 33 IPC_MESSAGE_UNHANDLED(handled = false) |
33 IPC_END_MESSAGE_MAP() | 34 IPC_END_MESSAGE_MAP() |
34 | 35 |
35 return handled; | 36 return handled; |
36 } | 37 } |
37 | 38 |
38 void DesktopNotificationHandler::OnShow( | 39 void DesktopNotificationHandler::OnShow( |
39 const DesktopNotificationHostMsg_Show_Params& params) { | 40 const DesktopNotificationHostMsg_Show_Params& params) { |
| 41 // Disallow HTML notifications from unwanted schemes. javascript: |
| 42 // in particular allows unwanted cross-domain access. |
| 43 GURL url = params.contents_url; |
| 44 if (!url.SchemeIs(chrome::kHttpScheme) && |
| 45 !url.SchemeIs(chrome::kHttpsScheme) && |
| 46 !url.SchemeIs(chrome::kExtensionScheme) && |
| 47 !url.SchemeIs(chrome::kDataScheme)) { |
| 48 return; |
| 49 } |
| 50 |
40 RenderProcessHost* process = render_view_host()->process(); | 51 RenderProcessHost* process = render_view_host()->process(); |
41 DesktopNotificationService* service = | 52 DesktopNotificationService* service = |
42 DesktopNotificationServiceFactory::GetForProfile(process->profile()); | 53 DesktopNotificationServiceFactory::GetForProfile(process->profile()); |
43 | 54 |
44 service->ShowDesktopNotification( | 55 service->ShowDesktopNotification( |
45 params, | 56 params, |
46 process->id(), | 57 process->id(), |
47 routing_id(), | 58 routing_id(), |
48 DesktopNotificationService::PageNotification); | 59 DesktopNotificationService::PageNotification); |
49 } | 60 } |
(...skipping 15 matching lines...) Expand all Loading... |
65 source_origin, callback_context)) { | 76 source_origin, callback_context)) { |
66 return; | 77 return; |
67 } | 78 } |
68 | 79 |
69 RenderProcessHost* process = render_view_host()->process(); | 80 RenderProcessHost* process = render_view_host()->process(); |
70 DesktopNotificationService* service = | 81 DesktopNotificationService* service = |
71 DesktopNotificationServiceFactory::GetForProfile(process->profile()); | 82 DesktopNotificationServiceFactory::GetForProfile(process->profile()); |
72 service->RequestPermission( | 83 service->RequestPermission( |
73 source_origin, process->id(), routing_id(), callback_context, NULL); | 84 source_origin, process->id(), routing_id(), callback_context, NULL); |
74 } | 85 } |
OLD | NEW |