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

Unified Diff: content/browser/notifications/blink_notification_service_impl.cc

Issue 1904163002: Move Web Notifications to use Mojo Base URL: https://chromium.googlesource.com/chromium/src.git@skbitmap-blink
Patch Set: resolves the promise Created 4 years, 8 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/notifications/blink_notification_service_impl.cc
diff --git a/content/browser/notifications/blink_notification_service_impl.cc b/content/browser/notifications/blink_notification_service_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..79396a36de234cf0390d1d88583c04c9879641db
--- /dev/null
+++ b/content/browser/notifications/blink_notification_service_impl.cc
@@ -0,0 +1,79 @@
+// Copyright 2016 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/browser/notifications/blink_notification_service_impl.h"
+
+#include "base/logging.h"
+#include "base/strings/utf_string_conversions.h"
+#include "content/browser/notifications/platform_notification_context_impl.h"
+#include "content/browser/notifications/type_converters.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/content_browser_client.h"
+#include "content/public/browser/platform_notification_service.h"
+#include "content/public/common/content_client.h"
+#include "content/public/common/notification_resources.h"
+#include "content/public/common/platform_notification_data.h"
+#include "skia/public/type_converters.h"
+#include "third_party/WebKit/public/platform/modules/permissions/permission_status.mojom.h"
+
+namespace content {
+
+// TODO:
+// - Have some convenience getter for the PlatformNotificationService.
+// - Have some convenience getter for the browser context (member?)
+
+BlinkNotificationServiceImpl::BlinkNotificationServiceImpl(
+ PlatformNotificationContextImpl* notification_context,
+ mojo::InterfaceRequest<blink::mojom::NotificationService> request)
+ : notification_context_(notification_context),
+ binding_(this, std::move(request)) {
+}
+
+BlinkNotificationServiceImpl::~BlinkNotificationServiceImpl() {}
+
+void BlinkNotificationServiceImpl::GetPermissionStatus(
+ const mojo::String& origin,
+ const GetPermissionStatusCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ PlatformNotificationService* service =
+ GetContentClient()->browser()->GetPlatformNotificationService();
+ DCHECK(service);
+
+ blink::mojom::PermissionStatus permission_status =
+ service->CheckPermissionOnUIThread(
+ notification_context_->browser_context(),
+ GURL(origin.get()), 0 /* render_process_id */);
+
+ callback.Run(permission_status);
+}
+
+void BlinkNotificationServiceImpl::ShowPersistent(
+ const mojo::String& origin,
+ blink::mojom::NotificationPtr notification,
+ blink::mojom::NotificationResourcesPtr notification_resources,
+ const ShowPersistentCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ PlatformNotificationService* service =
+ GetContentClient()->browser()->GetPlatformNotificationService();
+ DCHECK(service);
+
+ PlatformNotificationData notification_data =
+ notification.To<PlatformNotificationData>();
+
+ NotificationResources resources;
+ resources.notification_icon = notification_resources->icon.To<SkBitmap>();
+
+ service->DisplayPersistentNotification(
+ notification_context_->browser_context(),
+ 42 /* persistent_notification_id */,
+ GURL(origin.get()),
+ notification_data,
+ resources);
+
+ callback.Run(blink::mojom::NotificationDisplayResult::SUCCESS);
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698