Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/renderer/notification_permission_dispatcher.h" | |
| 6 | |
| 7 #include "content/common/platform_notification_messages.h" | |
| 8 #include "third_party/WebKit/public/platform/WebString.h" | |
| 9 #include "third_party/WebKit/public/web/WebNotificationPermissionCallback.h" | |
| 10 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | |
| 11 #include "url/gurl.h" | |
| 12 | |
| 13 namespace content { | |
| 14 | |
| 15 NotificationPermissionDispatcher::NotificationPermissionDispatcher( | |
| 16 RenderFrame* render_frame) : RenderFrameObserver(render_frame) { | |
| 17 } | |
| 18 | |
| 19 NotificationPermissionDispatcher::~NotificationPermissionDispatcher() { | |
| 20 } | |
| 21 | |
| 22 void NotificationPermissionDispatcher::RequestPermission( | |
| 23 const blink::WebSecurityOrigin& origin, | |
| 24 blink::WebNotificationPermissionCallback* callback) { | |
| 25 int request_id = pending_requests_.Add(callback); | |
| 26 Send(new PlatformNotificationHostMsg_RequestPermission( | |
| 27 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
| |
| 28 } | |
| 29 | |
| 30 bool NotificationPermissionDispatcher::OnMessageReceived( | |
| 31 const IPC::Message& message) { | |
| 32 bool handled = true; | |
| 33 IPC_BEGIN_MESSAGE_MAP(NotificationPermissionDispatcher, message) | |
| 34 IPC_MESSAGE_HANDLER(PlatformNotificationMsg_PermissionRequestComplete, | |
| 35 OnPermissionRequestComplete); | |
| 36 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 37 IPC_END_MESSAGE_MAP() | |
| 38 | |
| 39 return handled; | |
| 40 } | |
| 41 | |
| 42 void NotificationPermissionDispatcher::OnPermissionRequestComplete( | |
| 43 int request_id, blink::WebNotificationPermission result) { | |
| 44 blink::WebNotificationPermissionCallback* callback = | |
| 45 pending_requests_.Lookup(request_id); | |
| 46 DCHECK(callback); | |
| 47 | |
| 48 callback->permissionRequestComplete(result); | |
| 49 pending_requests_.Remove(request_id); | |
| 50 } | |
| 51 | |
| 52 } // namespace content | |
| OLD | NEW |