app_shell: Add version number in user agent
[chromium-blink-merge.git] / content / renderer / notification_permission_dispatcher.cc
blob92d5529122b2dcbef19ce47de6de3a2ae09a24d0
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.
5 #include "content/renderer/notification_permission_dispatcher.h"
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"
13 namespace content {
15 NotificationPermissionDispatcher::NotificationPermissionDispatcher(
16 RenderFrame* render_frame) : RenderFrameObserver(render_frame) {
19 NotificationPermissionDispatcher::~NotificationPermissionDispatcher() {
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));
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()
39 return handled;
42 void NotificationPermissionDispatcher::OnPermissionRequestComplete(
43 int request_id, blink::WebNotificationPermission result) {
44 blink::WebNotificationPermissionCallback* callback =
45 pending_requests_.Lookup(request_id);
46 DCHECK(callback);
48 callback->permissionRequestComplete(result);
49 pending_requests_.Remove(request_id);
52 } // namespace content