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 "content/renderer/notification_provider.h" | 5 #include "content/renderer/notification_provider.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/task.h" | 8 #include "base/task.h" |
9 #include "content/common/desktop_notification_messages.h" | 9 #include "content/common/desktop_notification_messages.h" |
10 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 void NotificationProvider::objectDestroyed( | 50 void NotificationProvider::objectDestroyed( |
51 const WebNotification& notification) { | 51 const WebNotification& notification) { |
52 int id; | 52 int id; |
53 bool id_found = manager_.GetId(notification, id); | 53 bool id_found = manager_.GetId(notification, id); |
54 // Won't be found if the notification has already been closed by the user. | 54 // Won't be found if the notification has already been closed by the user. |
55 if (id_found) | 55 if (id_found) |
56 manager_.UnregisterNotification(id); | 56 manager_.UnregisterNotification(id); |
57 } | 57 } |
58 | 58 |
59 WebNotificationPresenter::Permission NotificationProvider::checkPermission( | 59 WebNotificationPresenter::Permission NotificationProvider::checkPermission( |
60 const WebURL& url) { | 60 const WebURL& origin) { |
61 int permission; | 61 int permission; |
62 Send(new DesktopNotificationHostMsg_CheckPermission( | 62 Send(new DesktopNotificationHostMsg_CheckPermission( |
63 routing_id(), | 63 routing_id(), |
64 url, | 64 origin, |
65 &permission)); | 65 &permission)); |
66 return static_cast<WebNotificationPresenter::Permission>(permission); | 66 return static_cast<WebNotificationPresenter::Permission>(permission); |
67 } | 67 } |
68 | 68 |
69 void NotificationProvider::requestPermission( | 69 void NotificationProvider::requestPermission( |
70 const WebSecurityOrigin& origin, | 70 const WebSecurityOrigin& origin, |
71 WebNotificationPermissionCallback* callback) { | 71 WebNotificationPermissionCallback* callback) { |
72 // We only request permission in response to a user gesture. | 72 // We only request permission in response to a user gesture. |
73 if (!render_view()->GetWebView()->mainFrame()->isProcessingUserGesture()) | 73 if (!render_view()->GetWebView()->mainFrame()->isProcessingUserGesture()) |
74 return; | 74 return; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 void NotificationProvider::OnPermissionRequestComplete(int id) { | 167 void NotificationProvider::OnPermissionRequestComplete(int id) { |
168 WebNotificationPermissionCallback* callback = manager_.GetCallback(id); | 168 WebNotificationPermissionCallback* callback = manager_.GetCallback(id); |
169 DCHECK(callback); | 169 DCHECK(callback); |
170 callback->permissionRequestComplete(); | 170 callback->permissionRequestComplete(); |
171 manager_.OnPermissionRequestComplete(id); | 171 manager_.OnPermissionRequestComplete(id); |
172 } | 172 } |
173 | 173 |
174 void NotificationProvider::OnNavigate() { | 174 void NotificationProvider::OnNavigate() { |
175 manager_.Clear(); | 175 manager_.Clear(); |
176 } | 176 } |
OLD | NEW |