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

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: 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
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | content/common/DEPS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a64e429f3ad924e2b52cc413ee8494daecb49862..ffe78d915895bb8047a41aeb19de2af4f1d4b3bb 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -27,8 +27,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"
@@ -336,6 +338,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,
@@ -701,6 +705,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(
@@ -931,6 +946,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;
Jun Mukai 2014/07/15 21:49:32 Should this be Denied? Allowing notifications if
Peter Beverloo 2014/07/15 21:53:48 I'm merely copying the logic in RenderMessageFilte
+#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(
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | content/common/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698