| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "content/common/desktop_notification_messages.h" | 8 #include "content/common/desktop_notification_messages.h" |
| 9 #include "content/common/frame_messages.h" | 9 #include "content/common/frame_messages.h" |
| 10 #include "content/renderer/render_frame_impl.h" | 10 #include "content/renderer/render_frame_impl.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 Send(new DesktopNotificationHostMsg_CheckPermission( | 71 Send(new DesktopNotificationHostMsg_CheckPermission( |
| 72 routing_id(), | 72 routing_id(), |
| 73 GURL(origin.toString()), | 73 GURL(origin.toString()), |
| 74 &permission)); | 74 &permission)); |
| 75 return static_cast<WebNotificationPresenter::Permission>(permission); | 75 return static_cast<WebNotificationPresenter::Permission>(permission); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void NotificationProvider::requestPermission( | 78 void NotificationProvider::requestPermission( |
| 79 const WebSecurityOrigin& origin, | 79 const WebSecurityOrigin& origin, |
| 80 WebNotificationPermissionCallback* callback) { | 80 WebNotificationPermissionCallback* callback) { |
| 81 // We only request permission in response to a user gesture. | |
| 82 if (!WebUserGestureIndicator::isProcessingUserGesture()) | |
| 83 return; | |
| 84 | |
| 85 int id = manager_.RegisterPermissionRequest(callback); | 81 int id = manager_.RegisterPermissionRequest(callback); |
| 86 | 82 |
| 87 Send(new DesktopNotificationHostMsg_RequestPermission( | 83 Send(new DesktopNotificationHostMsg_RequestPermission( |
| 88 routing_id(), GURL(origin.toString()), id)); | 84 routing_id(), GURL(origin.toString()), id)); |
| 89 } | 85 } |
| 90 | 86 |
| 91 bool NotificationProvider::OnMessageReceived(const IPC::Message& message) { | 87 bool NotificationProvider::OnMessageReceived(const IPC::Message& message) { |
| 92 bool handled = true; | 88 bool handled = true; |
| 93 IPC_BEGIN_MESSAGE_MAP(NotificationProvider, message) | 89 IPC_BEGIN_MESSAGE_MAP(NotificationProvider, message) |
| 94 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostDisplay, OnDisplay); | 90 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostDisplay, OnDisplay); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 DCHECK(callback); | 145 DCHECK(callback); |
| 150 callback->permissionRequestComplete(); | 146 callback->permissionRequestComplete(); |
| 151 manager_.OnPermissionRequestComplete(id); | 147 manager_.OnPermissionRequestComplete(id); |
| 152 } | 148 } |
| 153 | 149 |
| 154 void NotificationProvider::OnNavigate() { | 150 void NotificationProvider::OnNavigate() { |
| 155 manager_.Clear(); | 151 manager_.Clear(); |
| 156 } | 152 } |
| 157 | 153 |
| 158 } // namespace content | 154 } // namespace content |
| OLD | NEW |