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

Unified Diff: content/browser/frame_host/render_frame_host_impl.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
Index: content/browser/frame_host/render_frame_host_impl.cc
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc
index f7f959e201905f974da72117752bd8f7bc42d220..cf290d6f85cbefbf47f1da29769616cc7a647e3d 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -26,8 +26,10 @@
#include "content/common/frame_messages.h"
#include "content/common/input_messages.h"
#include "content/common/inter_process_time_ticks_converter.h"
+#include "content/common/platform_notification_messages.h"
#include "content/common/render_frame_setup.mojom.h"
#include "content/common/swapped_out_messages.h"
+#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/desktop_notification_delegate.h"
@@ -335,6 +337,8 @@ bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) {
IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisownOpener, OnDidDisownOpener)
IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateTitle, OnUpdateTitle)
IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateEncoding, OnUpdateEncoding)
+ IPC_MESSAGE_HANDLER(PlatformNotificationHostMsg_RequestPermission,
+ OnRequestPlatformNotificationPermission)
IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission,
OnRequestDesktopNotificationPermission)
IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show,
@@ -700,6 +704,17 @@ void RenderFrameHostImpl::OnRunBeforeUnloadConfirm(
delegate_->RunBeforeUnloadConfirm(this, message, is_reload, reply_msg);
}
+void RenderFrameHostImpl::OnRequestPlatformNotificationPermission(
+ const GURL& origin, int request_id) {
+ base::Closure done_callback = base::Bind(
+ &RenderFrameHostImpl::PlatformNotificationPermissionRequestDone,
+ weak_ptr_factory_.GetWeakPtr(), origin, request_id);
+ GetContentClient()->browser()->RequestDesktopNotificationPermission(
+ origin, this, done_callback);
+}
+
+// TODO(peter): Remove this call and the associated IPC messages when Blink
+// has switched to the new Web Notification permission code-path.
void RenderFrameHostImpl::OnRequestDesktopNotificationPermission(
const GURL& source_origin, int callback_context) {
base::Closure done_callback = base::Bind(
@@ -929,6 +944,23 @@ void RenderFrameHostImpl::NotificationClosed(int notification_id) {
cancel_notification_callbacks_.erase(notification_id);
}
+void RenderFrameHostImpl::PlatformNotificationPermissionRequestDone(
+ const GURL& origin, int request_id) {
+ blink::WebNotificationPermission permission =
+ blink::WebNotificationPermissionAllowed;
+#if defined(ENABLE_NOTIFICATIONS)
+ permission = static_cast<blink::WebNotificationPermission>(
+ GetContentClient()->browser()->CheckDesktopNotificationPermission(
+ origin,
+ GetProcess()->GetBrowserContext()->GetResourceContext(),
+ GetProcess()->GetID()));
+#endif
+
+ Send(new PlatformNotificationMsg_PermissionRequestComplete(
+ routing_id_, request_id, permission));
+}
+
+// TODO(peter): Remove this method when Blink uses the new code-path.
void RenderFrameHostImpl::DesktopNotificationPermissionRequestDone(
int callback_context) {
Send(new DesktopNotificationMsg_PermissionRequestDone(

Powered by Google App Engine
This is Rietveld 408576698