Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1425)

Unified Diff: content/renderer/notification_permission_dispatcher.cc

Issue 381633005: Refactor Web Notification permission requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/notification_permission_dispatcher.h ('k') | content/renderer/render_frame_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « content/renderer/notification_permission_dispatcher.h ('k') | content/renderer/render_frame_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698