| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/renderer/notification_provider.h" | 5 #include "chrome/renderer/notification_provider.h" |
| 6 | 6 |
| 7 #include "base/task.h" | 7 #include "base/task.h" |
| 8 #include "chrome/common/render_messages.h" | 8 #include "chrome/common/render_messages.h" |
| 9 #include "chrome/renderer/render_thread.h" | 9 #include "chrome/renderer/render_thread.h" |
| 10 #include "chrome/renderer/render_view.h" | 10 #include "chrome/renderer/render_view.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 int id; | 40 int id; |
| 41 bool id_found = manager_.GetId(notification, id); | 41 bool id_found = manager_.GetId(notification, id); |
| 42 DCHECK(id_found); | 42 DCHECK(id_found); |
| 43 if (id_found) | 43 if (id_found) |
| 44 manager_.UnregisterNotification(id); | 44 manager_.UnregisterNotification(id); |
| 45 } | 45 } |
| 46 | 46 |
| 47 WebNotificationPresenter::Permission NotificationProvider::checkPermission( | 47 WebNotificationPresenter::Permission NotificationProvider::checkPermission( |
| 48 const WebString& origin) { | 48 const WebString& origin) { |
| 49 int permission; | 49 int permission; |
| 50 Send(new ViewHostMsg_CheckNotificationPermission(view_->routing_id(), origin, | 50 Send(new ViewHostMsg_CheckNotificationPermission(view_->routing_id(), |
| 51 &permission)); | 51 GURL(origin), &permission)); |
| 52 return static_cast<WebNotificationPresenter::Permission>(permission); | 52 return static_cast<WebNotificationPresenter::Permission>(permission); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void NotificationProvider::requestPermission( | 55 void NotificationProvider::requestPermission( |
| 56 const WebString& origin, WebNotificationPermissionCallback* callback) { | 56 const WebString& origin, WebNotificationPermissionCallback* callback) { |
| 57 int id = manager_.RegisterPermissionRequest(callback); | 57 int id = manager_.RegisterPermissionRequest(callback); |
| 58 | 58 |
| 59 Send(new ViewHostMsg_RequestNotificationPermission(view_->routing_id(), | 59 Send(new ViewHostMsg_RequestNotificationPermission(view_->routing_id(), |
| 60 origin, id)); | 60 GURL(origin), id)); |
| 61 } | 61 } |
| 62 | 62 |
| 63 bool NotificationProvider::ShowHTML(const WebNotification& notification, | 63 bool NotificationProvider::ShowHTML(const WebNotification& notification, |
| 64 int id) { | 64 int id) { |
| 65 DCHECK(notification.isHTML()); | 65 DCHECK(notification.isHTML()); |
| 66 return Send(new ViewHostMsg_ShowDesktopNotification(view_->routing_id(), | 66 return Send(new ViewHostMsg_ShowDesktopNotification(view_->routing_id(), |
| 67 GURL(view_->webview()->mainFrame()->url()), | 67 GURL(view_->webview()->mainFrame()->url()), |
| 68 notification.url(), id)); | 68 notification.url(), id)); |
| 69 } | 69 } |
| 70 | 70 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 IPC_MESSAGE_HANDLER(ViewMsg_PermissionRequestDone, | 151 IPC_MESSAGE_HANDLER(ViewMsg_PermissionRequestDone, |
| 152 OnPermissionRequestComplete); | 152 OnPermissionRequestComplete); |
| 153 IPC_MESSAGE_UNHANDLED(handled = false) | 153 IPC_MESSAGE_UNHANDLED(handled = false) |
| 154 IPC_END_MESSAGE_MAP() | 154 IPC_END_MESSAGE_MAP() |
| 155 return handled; | 155 return handled; |
| 156 } | 156 } |
| 157 | 157 |
| 158 bool NotificationProvider::Send(IPC::Message* message) { | 158 bool NotificationProvider::Send(IPC::Message* message) { |
| 159 return RenderThread::current()->Send(message); | 159 return RenderThread::current()->Send(message); |
| 160 } | 160 } |
| OLD | NEW |