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 13 matching lines...) Expand all Loading... |
24 int notification_id = manager_.RegisterNotification(notification); | 24 int notification_id = manager_.RegisterNotification(notification); |
25 if (notification.isHTML()) | 25 if (notification.isHTML()) |
26 return ShowHTML(notification, notification_id); | 26 return ShowHTML(notification, notification_id); |
27 else | 27 else |
28 return ShowText(notification, notification_id); | 28 return ShowText(notification, notification_id); |
29 } | 29 } |
30 | 30 |
31 void NotificationProvider::cancel(const WebNotification& notification) { | 31 void NotificationProvider::cancel(const WebNotification& notification) { |
32 int id; | 32 int id; |
33 bool id_found = manager_.GetId(notification, id); | 33 bool id_found = manager_.GetId(notification, id); |
34 DCHECK(id_found); | 34 // Won't be found if the notification has already been closed by the user. |
35 if (id_found) | 35 if (id_found) |
36 Send(new ViewHostMsg_CancelDesktopNotification(view_->routing_id(), id)); | 36 Send(new ViewHostMsg_CancelDesktopNotification(view_->routing_id(), id)); |
37 } | 37 } |
38 | 38 |
39 void NotificationProvider::objectDestroyed( | 39 void NotificationProvider::objectDestroyed( |
40 const WebNotification& notification) { | 40 const WebNotification& notification) { |
41 int id; | 41 int id; |
42 bool id_found = manager_.GetId(notification, id); | 42 bool id_found = manager_.GetId(notification, id); |
43 DCHECK(id_found); | 43 // Won't be found if the notification has already been closed by the user. |
44 if (id_found) | 44 if (id_found) |
45 manager_.UnregisterNotification(id); | 45 manager_.UnregisterNotification(id); |
46 } | 46 } |
47 | 47 |
48 WebNotificationPresenter::Permission NotificationProvider::checkPermission( | 48 WebNotificationPresenter::Permission NotificationProvider::checkPermission( |
49 const WebString& origin) { | 49 const WebString& origin) { |
50 int permission; | 50 int permission; |
51 Send(new ViewHostMsg_CheckNotificationPermission(view_->routing_id(), | 51 Send(new ViewHostMsg_CheckNotificationPermission(view_->routing_id(), |
52 GURL(origin), &permission)); | 52 GURL(origin), &permission)); |
53 return static_cast<WebNotificationPresenter::Permission>(permission); | 53 return static_cast<WebNotificationPresenter::Permission>(permission); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 void NotificationProvider::OnPermissionRequestComplete(int id) { | 122 void NotificationProvider::OnPermissionRequestComplete(int id) { |
123 WebNotificationPermissionCallback* callback = manager_.GetCallback(id); | 123 WebNotificationPermissionCallback* callback = manager_.GetCallback(id); |
124 DCHECK(callback); | 124 DCHECK(callback); |
125 callback->permissionRequestComplete(); | 125 callback->permissionRequestComplete(); |
126 manager_.OnPermissionRequestComplete(id); | 126 manager_.OnPermissionRequestComplete(id); |
127 } | 127 } |
128 | 128 |
129 bool NotificationProvider::Send(IPC::Message* message) { | 129 bool NotificationProvider::Send(IPC::Message* message) { |
130 return RenderThread::current()->Send(message); | 130 return RenderThread::current()->Send(message); |
131 } | 131 } |
OLD | NEW |