| 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
|
|
|