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

Unified Diff: content/renderer/notification_permission_dispatcher.h

Issue 381633005: Refactor Web Notification permission requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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
Index: content/renderer/notification_permission_dispatcher.h
diff --git a/content/renderer/notification_permission_dispatcher.h b/content/renderer/notification_permission_dispatcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..c68091eb6d3e931eda18913cbfe40227dee78298
--- /dev/null
+++ b/content/renderer/notification_permission_dispatcher.h
@@ -0,0 +1,50 @@
+// 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.
+
+#ifndef CONTENT_RENDERER_NOTIFICATION_PERMISSION_DISPATCHER_H_
+#define CONTENT_RENDERER_NOTIFICATION_PERMISSION_DISPATCHER_H_
+
+#include "base/id_map.h"
+#include "content/public/renderer/render_frame_observer.h"
+#include "ipc/ipc_message.h"
+#include "third_party/WebKit/public/platform/WebNotificationPermission.h"
+
+namespace blink {
+class WebNotificationPermissionCallback;
+class WebSecurityOrigin;
+}
+
+namespace content {
+
+// Dispatcher for Web Notification permission requests.
+class NotificationPermissionDispatcher : public RenderFrameObserver {
+ public:
+ explicit NotificationPermissionDispatcher(RenderFrame* render_frame);
+ virtual ~NotificationPermissionDispatcher();
+
+ // Requests permission to display Web Notifications for |origin|. The callback
+ // will be invoked when the permission status is available. This class will
+ // take ownership of |callback|.
+ void RequestPermission(
+ const blink::WebSecurityOrigin& origin,
+ blink::WebNotificationPermissionCallback* callback);
+
+ private:
+ // RenderFrameObserver implementation.
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+
+ void OnPermissionRequestComplete(
+ int request_id, blink::WebNotificationPermission result);
+
+ // Tracks the active notification permission requests. This class takes
+ // ownership of the created WebNotificationPermissionCallback objects.
+ IDMap<blink::WebNotificationPermissionCallback, IDMapOwnPointer>
+ pending_requests_;
+
+ DISALLOW_COPY_AND_ASSIGN(NotificationPermissionDispatcher);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_NOTIFICATION_PERMISSION_DISPATCHER_H_

Powered by Google App Engine
This is Rietveld 408576698