Chromium Code Reviews| Index: content/renderer/notification_permission_dispatcher.cc |
| diff --git a/content/renderer/notification_permission_dispatcher.cc b/content/renderer/notification_permission_dispatcher.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..92d5529122b2dcbef19ce47de6de3a2ae09a24d0 |
| --- /dev/null |
| +++ b/content/renderer/notification_permission_dispatcher.cc |
| @@ -0,0 +1,52 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/renderer/notification_permission_dispatcher.h" |
| + |
| +#include "content/common/platform_notification_messages.h" |
| +#include "third_party/WebKit/public/platform/WebString.h" |
| +#include "third_party/WebKit/public/web/WebNotificationPermissionCallback.h" |
| +#include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
| +#include "url/gurl.h" |
| + |
| +namespace content { |
| + |
| +NotificationPermissionDispatcher::NotificationPermissionDispatcher( |
| + RenderFrame* render_frame) : RenderFrameObserver(render_frame) { |
| +} |
| + |
| +NotificationPermissionDispatcher::~NotificationPermissionDispatcher() { |
| +} |
| + |
| +void NotificationPermissionDispatcher::RequestPermission( |
| + const blink::WebSecurityOrigin& origin, |
| + blink::WebNotificationPermissionCallback* callback) { |
| + int request_id = pending_requests_.Add(callback); |
| + Send(new PlatformNotificationHostMsg_RequestPermission( |
| + routing_id(), GURL(origin.toString()), request_id)); |
|
Michael van Ouwerkerk
2014/07/10 10:53:11
Where is the check for origin.toString() == "null"
Peter Beverloo
2014/07/15 16:33:30
When does that occur? I wonder why we haven't had
jochen (gone - plz use gerrit)
2014/07/22 11:35:24
when you run from a file URL (or any other "unique
|
| +} |
| + |
| +bool NotificationPermissionDispatcher::OnMessageReceived( |
| + const IPC::Message& message) { |
| + bool handled = true; |
| + IPC_BEGIN_MESSAGE_MAP(NotificationPermissionDispatcher, message) |
| + IPC_MESSAGE_HANDLER(PlatformNotificationMsg_PermissionRequestComplete, |
| + OnPermissionRequestComplete); |
| + IPC_MESSAGE_UNHANDLED(handled = false) |
| + IPC_END_MESSAGE_MAP() |
| + |
| + return handled; |
| +} |
| + |
| +void NotificationPermissionDispatcher::OnPermissionRequestComplete( |
| + int request_id, blink::WebNotificationPermission result) { |
| + blink::WebNotificationPermissionCallback* callback = |
| + pending_requests_.Lookup(request_id); |
| + DCHECK(callback); |
| + |
| + callback->permissionRequestComplete(result); |
| + pending_requests_.Remove(request_id); |
| +} |
| + |
| +} // namespace content |