| 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/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "content/common/desktop_notification_messages.h" | 8 #include "content/common/desktop_notification_messages.h" |
| 9 #include "content/common/view_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/Source/Platform/chromium/public/WebURL.h" | 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" |
| 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPermis
sionCallback.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPermis
sionCallback.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserGestureIndicat
or.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 16 | 17 |
| 17 using WebKit::WebDocument; | 18 using WebKit::WebDocument; |
| 18 using WebKit::WebNotification; | 19 using WebKit::WebNotification; |
| 19 using WebKit::WebNotificationPresenter; | 20 using WebKit::WebNotificationPresenter; |
| 20 using WebKit::WebNotificationPermissionCallback; | 21 using WebKit::WebNotificationPermissionCallback; |
| 21 using WebKit::WebSecurityOrigin; | 22 using WebKit::WebSecurityOrigin; |
| 22 using WebKit::WebString; | 23 using WebKit::WebString; |
| 23 using WebKit::WebURL; | 24 using WebKit::WebURL; |
| 25 using WebKit::WebUserGestureIndicator; |
| 24 | 26 |
| 25 namespace content { | 27 namespace content { |
| 26 | 28 |
| 27 | 29 |
| 28 NotificationProvider::NotificationProvider(RenderViewImpl* render_view) | 30 NotificationProvider::NotificationProvider(RenderViewImpl* render_view) |
| 29 : RenderViewObserver(render_view) { | 31 : RenderViewObserver(render_view) { |
| 30 } | 32 } |
| 31 | 33 |
| 32 NotificationProvider::~NotificationProvider() { | 34 NotificationProvider::~NotificationProvider() { |
| 33 manager_.DetachAll(); | 35 manager_.DetachAll(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 routing_id(), | 67 routing_id(), |
| 66 GURL(origin.toString()), | 68 GURL(origin.toString()), |
| 67 &permission)); | 69 &permission)); |
| 68 return static_cast<WebNotificationPresenter::Permission>(permission); | 70 return static_cast<WebNotificationPresenter::Permission>(permission); |
| 69 } | 71 } |
| 70 | 72 |
| 71 void NotificationProvider::requestPermission( | 73 void NotificationProvider::requestPermission( |
| 72 const WebSecurityOrigin& origin, | 74 const WebSecurityOrigin& origin, |
| 73 WebNotificationPermissionCallback* callback) { | 75 WebNotificationPermissionCallback* callback) { |
| 74 // We only request permission in response to a user gesture. | 76 // We only request permission in response to a user gesture. |
| 75 if (!render_view()->GetWebView()->mainFrame()->isProcessingUserGesture()) | 77 if (!WebUserGestureIndicator::isProcessingUserGesture()) |
| 76 return; | 78 return; |
| 77 | 79 |
| 78 int id = manager_.RegisterPermissionRequest(callback); | 80 int id = manager_.RegisterPermissionRequest(callback); |
| 79 | 81 |
| 80 Send(new DesktopNotificationHostMsg_RequestPermission( | 82 Send(new DesktopNotificationHostMsg_RequestPermission( |
| 81 routing_id(), GURL(origin.toString()), id)); | 83 routing_id(), GURL(origin.toString()), id)); |
| 82 } | 84 } |
| 83 | 85 |
| 84 bool NotificationProvider::OnMessageReceived(const IPC::Message& message) { | 86 bool NotificationProvider::OnMessageReceived(const IPC::Message& message) { |
| 85 bool handled = true; | 87 bool handled = true; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 DCHECK(callback); | 173 DCHECK(callback); |
| 172 callback->permissionRequestComplete(); | 174 callback->permissionRequestComplete(); |
| 173 manager_.OnPermissionRequestComplete(id); | 175 manager_.OnPermissionRequestComplete(id); |
| 174 } | 176 } |
| 175 | 177 |
| 176 void NotificationProvider::OnNavigate() { | 178 void NotificationProvider::OnNavigate() { |
| 177 manager_.Clear(); | 179 manager_.Clear(); |
| 178 } | 180 } |
| 179 | 181 |
| 180 } // namespace content | 182 } // namespace content |
| OLD | NEW |