| 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/view_messages.h" |
| 10 #include "content/renderer/render_view_impl.h" | 10 #include "content/renderer/render_view_impl.h" |
| 11 #include "third_party/WebKit/public/platform/WebURL.h" | 11 #include "third_party/WebKit/public/platform/WebURL.h" |
| 12 #include "third_party/WebKit/public/web/WebDocument.h" | 12 #include "third_party/WebKit/public/web/WebDocument.h" |
| 13 #include "third_party/WebKit/public/web/WebFrame.h" | 13 #include "third_party/WebKit/public/web/WebFrame.h" |
| 14 #include "third_party/WebKit/public/web/WebNotificationPermissionCallback.h" | 14 #include "third_party/WebKit/public/web/WebNotificationPermissionCallback.h" |
| 15 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | 15 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
| 16 #include "third_party/WebKit/public/web/WebView.h" | 16 #include "third_party/WebKit/public/web/WebView.h" |
| 17 | 17 |
| 18 using blink::WebDocument; | 18 using blink::WebDocument; |
| 19 using blink::WebNotification; | 19 using blink::WebNotification; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 IPC_BEGIN_MESSAGE_MAP(NotificationProvider, message) | 94 IPC_BEGIN_MESSAGE_MAP(NotificationProvider, message) |
| 95 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostDisplay, OnDisplay); | 95 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostDisplay, OnDisplay); |
| 96 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostError, OnError); | 96 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostError, OnError); |
| 97 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostClose, OnClose); | 97 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostClose, OnClose); |
| 98 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostClick, OnClick); | 98 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostClick, OnClick); |
| 99 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PermissionRequestDone, | 99 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PermissionRequestDone, |
| 100 OnPermissionRequestComplete); | 100 OnPermissionRequestComplete); |
| 101 IPC_MESSAGE_UNHANDLED(handled = false) | 101 IPC_MESSAGE_UNHANDLED(handled = false) |
| 102 IPC_END_MESSAGE_MAP() | 102 IPC_END_MESSAGE_MAP() |
| 103 | 103 |
| 104 if (message.type() == FrameMsg_Navigate::ID) | 104 if (message.type() == ViewMsg_Navigate::ID) |
| 105 OnNavigate(); // Don't want to swallow the message. | 105 OnNavigate(); // Don't want to swallow the message. |
| 106 | 106 |
| 107 return handled; | 107 return handled; |
| 108 } | 108 } |
| 109 | 109 |
| 110 void NotificationProvider::OnDisplay(int id) { | 110 void NotificationProvider::OnDisplay(int id) { |
| 111 WebNotification notification; | 111 WebNotification notification; |
| 112 bool found = manager_.GetNotification(id, ¬ification); | 112 bool found = manager_.GetNotification(id, ¬ification); |
| 113 // |found| may be false if the WebNotification went out of scope in | 113 // |found| may be false if the WebNotification went out of scope in |
| 114 // the page before it was actually displayed to the user. | 114 // the page before it was actually displayed to the user. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 DCHECK(callback); | 150 DCHECK(callback); |
| 151 callback->permissionRequestComplete(); | 151 callback->permissionRequestComplete(); |
| 152 manager_.OnPermissionRequestComplete(id); | 152 manager_.OnPermissionRequestComplete(id); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void NotificationProvider::OnNavigate() { | 155 void NotificationProvider::OnNavigate() { |
| 156 manager_.Clear(); | 156 manager_.Clear(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 } // namespace content | 159 } // namespace content |
| OLD | NEW |