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

Unified Diff: content/renderer/notification_permission_dispatcher.cc

Issue 2258673002: Revert of Remove content::NotificationPermissionDispatcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permissions_typemaps
Patch Set: Created 4 years, 4 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..b94f5f3217fa972e1f93bca07e001a80f61bb492
--- /dev/null
+++ b/content/renderer/notification_permission_dispatcher.cc
@@ -0,0 +1,62 @@
+// 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 <utility>
+
+#include "base/bind.h"
+#include "content/public/renderer/render_frame.h"
+#include "services/shell/public/cpp/interface_provider.h"
+#include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
+#include "third_party/WebKit/public/platform/WebString.h"
+#include "third_party/WebKit/public/platform/modules/permissions/permission_status.mojom.h"
+#include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
+#include "third_party/WebKit/public/web/modules/notifications/WebNotificationPermissionCallback.h"
+
+using blink::WebNotificationPermissionCallback;
+
+namespace content {
+
+NotificationPermissionDispatcher::NotificationPermissionDispatcher(
+ RenderFrame* render_frame)
+ : RenderFrameObserver(render_frame) {}
+
+NotificationPermissionDispatcher::~NotificationPermissionDispatcher() {}
+
+void NotificationPermissionDispatcher::RequestPermission(
+ const blink::WebSecurityOrigin& origin,
+ WebNotificationPermissionCallback* callback) {
+ if (!permission_service_.get()) {
+ render_frame()->GetRemoteInterfaces()->GetInterface(&permission_service_);
+ }
+
+ std::unique_ptr<WebNotificationPermissionCallback> owned_callback(callback);
+
+ // base::Unretained is safe here because the Mojo channel, with associated
+ // callbacks, will be deleted before the "this" instance is deleted.
+ permission_service_->RequestPermission(
+ blink::mojom::PermissionName::NOTIFICATIONS, origin,
+ blink::WebUserGestureIndicator::isProcessingUserGesture(),
+ base::Bind(&NotificationPermissionDispatcher::OnPermissionRequestComplete,
+ base::Unretained(this),
+ base::Passed(std::move(owned_callback))));
+}
+
+void NotificationPermissionDispatcher::OnPermissionRequestComplete(
+ std::unique_ptr<WebNotificationPermissionCallback> callback,
+ blink::mojom::PermissionStatus status) {
+ DCHECK(callback);
+
+ // Blink can't use non-blink bindings so we need to cast to int32.
+ int32_t blink_status = static_cast<int32_t>(status);
+
+ callback->permissionRequestComplete(blink_status);
+}
+
+void NotificationPermissionDispatcher::OnDestruct() {
+ delete this;
+}
+
+} // 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